typeorm-markdown
v1.0.1
Published
TypeORM Markdown documents generator including ERD diagrams and comment descriptions
Downloads
515
Maintainers
Readme
TypeORM Markdown
TypeORM markdown documents generator.
- Mermaid ERD diagrams
- Descriptions by JSDoc
- Separations by
@namespace
comments
If you want to see how markdown document being generated, visit below examples:
- Markdown Content: yiy0ung/typeorm-markdown/test/erd.md
- TypeORM Entity Class: yiy0ung/typeorm-markdown/test/entities
Set up
npm i -D typeorm-markdown
Command Line Interface
typeorm-markdown version 1.0.0
Usage: typeorm-markdown [options]
Options:
-v, --version Print the current version
-i, --input <input_regex> Input entity files as a glob pattern
-o, --output <dir_path> Directory path where the erd document will be output (default: "./")
-t, --title <title> Title of the generated erd document (default: "ERD")
--project <project_path> Use --project to explicitly specify the path to a tsconfig.json (default: "tsconfig.json")
-h, --help display help for command
Comment Tags
This package is inspired by prisma-markdown, so it has similar usage.
@namespace <name>
- Both ERD and markdown content
- If
@namespace
is not set, it will be classified into theDefault
namespace.
@erd <name>
: Only ERD@describe <name>
: Only markdown content, without ERD@hidden
: Neither ERD nor markdown content
/**
* Both description and ERD on User chapter.
* Also, only ERD on Blog chapter.
*
* @namespace User
* @erd Blog
*/
@Entity()
class User {}
/**
* Only description on User chapter.
*
* @describe User
*/
@Entity()
class UserProfile {}
/**
* Only erd on Blog chapter.
*
* @erd Blog
*/
@Entity()
class BlogPost {}
/**
* Never be shown.
*
* @hidden
*/
@Entity()
class BlogPostHit {}
Notice
typeorm-markdown
will generate markdown as specified in the ORM, so any columns that are auto-generated by TypeORM (such as fk columns) cannot be reflected in the markdown documents.
Therefore, it is recommended to write N:M tables and fk columns specifically in the ORM.