2.3.2 • Published 18 days ago

@docgeni/ngdoc v2.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
18 days ago

@docgeni/ngdoc

Angular Component/Directive/Pipe/Service doc generator

Usage

import { NgDocParser } from '@docgeni/ngdoc';
const docs = NgDocParser.parse(__dirname + '/button.component.ts');
console.log(JSON.stringify(docs, null, 2));

Input:

/**
 * General Button Component description.
 * @name alib-button
 */
@Component({
    selector: 'alib-button,[alibButton]',
    template: '<ng-content></ng-content>'
})
export class AlibButtonComponent implements OnInit {
    @HostBinding(`class.dg-btn`) isBtn = true;

    private type: string;
    private loading = false;

    /**
     * Button Type: `'primary' | 'secondary' | 'danger'`
     * @description 按钮类型
     * @default primary
     * @type 'primary' | 'secondary' | 'danger'
     */
    @Input() set alibButton(value: string) {
        this.alibType = value;
    }

    /**
     * 和 alibButton 含义相同,一般使用 alibButton,为了减少参数输入, 设置按钮组件通过 alib-button 时,只能使用该参数控制类型
     * @default primary
     */
    @Input() set alibType(value: string) {
        if (this.type) {
            this.elementRef.nativeElement.classList.remove(`dg-btn-${this.type}`);
        }
        this.type = value;
        this.elementRef.nativeElement.classList.add(`dg-btn-${this.type}`);
    }

    /**
     * Button Size
     * @default md
     */
    @Input() alibSize: 'xs' | 'sm' | 'md' | 'lg' = 'xs';

    /**
     * Input  of alib button component
     * @type string
     */
    @Input('alibAliasName') alibLengthTooLongLengthTooLong: 'TypeLengthTooLongLengthTooLongLengthTooLong';

    /**
     * Button loading status
     * @default false
     */
    @Input() set thyLoading(loading: boolean) {
        this.loading = loading;
    }

    /**
     * Loading Event
     */
    @Output() thyLoadingEvent = new EventEmitter<boolean>();

    @ContentChild('template') templateRef: TemplateRef<unknown>;

    constructor(private elementRef: ElementRef<HTMLElement>) {}

    ngOnInit(): void {}
}

Output:

[
  {
    "type": "component",
    "name": "alib-button",
    "className": "AlibButtonComponent",
    "description": "General Button Component description.",
    "order": 9007199254740991,
    "selector": "alib-button,[alibButton]",
    "templateUrl": null,
    "template": "<ng-content></ng-content>",
    "styleUrls": null,
    "styles": null,
    "exportAs": null,
    "properties": [
      {
        "kind": "Input",
        "name": "alibButton",
        "aliasName": "",
        "type": {
          "name": " 'primary' | 'secondary' | 'danger'",
          "options": null
        },
        "description": "按钮类型",
        "default": "primary",
        "tags": {
          "description": {
            "name": "description",
            "text": [
              {
                "text": "按钮类型",
                "kind": "text"
              }
            ]
          },
          "default": {
            "name": "default",
            "text": [
              {
                "text": "primary",
                "kind": "text"
              }
            ]
          },
          "type": {
            "name": "type",
            "text": [
              {
                "text": "",
                "kind": "text"
              },
              {
                "text": " ",
                "kind": "space"
              },
              {
                "text": "'primary' | 'secondary' | 'danger'",
                "kind": "text"
              }
            ]
          }
        }
      },
      {
        "kind": "Input",
        "name": "alibType",
        "aliasName": "",
        "type": {
          "name": "string",
          "options": null
        },
        "description": "和 alibButton 含义相同,一般使用 alibButton,为了减少参数输入, 设置按钮组件通过 alib-button 时,只能使用该参数控制类型",
        "default": "primary",
        "tags": {
          "default": {
            "name": "default",
            "text": [
              {
                "text": "primary",
                "kind": "text"
              }
            ]
          }
        }
      },
      {
        "kind": "Input",
        "name": "alibSize",
        "aliasName": "",
        "type": {
          "name": "\"xs\" | \"sm\" | \"md\" | \"lg\"",
          "options": [
            "xs",
            "sm",
            "md",
            "lg"
          ],
          "kindName": "UnionType"
        },
        "description": "Button Size",
        "default": "md",
        "tags": {
          "default": {
            "name": "default",
            "text": [
              {
                "text": "md",
                "kind": "text"
              }
            ]
          }
        }
      },
      {
        "kind": "Input",
        "name": "alibLengthTooLongLengthTooLong",
        "aliasName": "alibAliasName",
        "type": {
          "name": "string",
          "options": null,
          "kindName": "LiteralType"
        },
        "description": "Input  of alib button component",
        "default": null,
        "tags": {
          "type": {
            "name": "type",
            "text": [
              {
                "text": "string",
                "kind": "text"
              }
            ]
          }
        }
      },
      {
        "kind": "Input",
        "name": "thyLoading",
        "aliasName": "",
        "type": {
          "name": "boolean",
          "options": null
        },
        "description": "Button loading status",
        "default": "false",
        "tags": {
          "default": {
            "name": "default",
            "text": [
              {
                "text": "false",
                "kind": "text"
              }
            ]
          }
        }
      },
      {
        "kind": "Output",
        "name": "thyLoadingEvent",
        "aliasName": "",
        "type": {
          "name": "EventEmitter<boolean>",
          "options": null
        },
        "description": "Loading Event",
        "default": "",
        "tags": {}
      },
      {
        "kind": "ContentChild",
        "name": "templateRef",
        "aliasName": "template",
        "type": {
          "name": "TemplateRef<unknown>",
          "options": null,
          "kindName": "TypeReference"
        },
        "description": "",
        "default": "",
        "tags": {}
      }
    ]
  } 
]

NgParserHost

import { NgDocParser, createNgParserHost } from '@docgeni/ngdoc';

const ngParserHost = createNgParserHost({
    tsConfigPath: '/lib/src/tsconfig.json',
    rootDir: '/lib/src',
    watch: true,
    watcher: (event, filename) => {}
});

const ngParser = NgDocParser.create({
    ngParserHost: ngParserHost
});

const docs = ngParser.parse(__dirname + '/button/*.ts');
console.log(JSON.stringify(docs, null, 2));

createNgParserHost Options:

  • tsConfigPath: the abs path of tsconfig
  • rootDir: component source root dir
  • watch?: whether watch all source files change
  • watcher?: event changed when watch is true
2.3.2-next.1

19 days ago

2.3.2

18 days ago

2.3.2-next.0

19 days ago

2.3.1

30 days ago

2.3.0

5 months ago

2.3.0-next.0

5 months ago

2.2.1

7 months ago

2.2.2

6 months ago

2.0.2

1 year ago

2.1.0-next.2

1 year ago

2.1.0-next.1

1 year ago

2.1.0-next.4

1 year ago

2.1.0-next.3

1 year ago

2.1.0-next.11

1 year ago

2.1.0-next.0

1 year ago

2.1.0-next.10

1 year ago

2.1.0-next.9

1 year ago

2.1.0-next.6

1 year ago

2.1.0-next.5

1 year ago

2.1.0-next.8

1 year ago

2.1.0-next.7

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.0-next.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.0-next.26

2 years ago

1.2.0-next.27

2 years ago

1.2.0-next.24

2 years ago

1.2.0-next.25

2 years ago

1.2.0-next.15

2 years ago

1.2.0-next.17

2 years ago

1.2.0-next.19

2 years ago

1.2.0-next.18

2 years ago

1.2.0-next.20

2 years ago

1.2.0-next.22

2 years ago

1.2.0-next.21

2 years ago

1.2.0-next.23

2 years ago

1.2.0-next.14

2 years ago

1.2.0-next.11

2 years ago

1.2.0-next.13

2 years ago

1.2.0-next.12

2 years ago

1.2.0-next.9

2 years ago

1.2.0-next.6

2 years ago

1.2.0-next.10

2 years ago

1.2.0-next.5

2 years ago

1.2.0-next.8

2 years ago

1.2.0-next.7

2 years ago

1.2.0-next.4

2 years ago

1.2.0-next.3

2 years ago

1.2.0-next.2

2 years ago

1.2.0-next.1

2 years ago

1.1.3

2 years ago

1.1.4

2 years ago

1.2.0-next.0

2 years ago