如何从源代码解析角度元素元数据

最近,我一直在尝试根据角度元素的输入/输出和注释自动生成文档,但是我什么也没找到。我要寻找的是类似于compodocs的东西,但是它将输出带有组件描述(注释)的我的角度组件的数据结构,以及将它们的输入/输出与它们的关联类型/注释合并在一起,以便我可以将它们与angular元素并生成适当的文档。 例如,假设我具有以下组件:

import { Component } from '@angular/core';

/*
  Component displaying "Hello {{nameInput}}" where nameInput is an input
*/
@Component({
  selector: 'hello',template: `
        Hello {{nameInput}}
      `
})
export class HelloComponent {
  /*
    name that should be displayed after 'Hello '
  */
  @Input()
  public nameInput: string;

  constructor(){}
}

我想要一个看起来像json的输出:

[
  {
    "HelloComponent":
      {
        "description": "Component displaying \"Hello {{name}}\" where name is an input","inputs": [
          {
            "name": "nameInput","type": "string","description": "name that should be displayed after 'Hello '"
          }
        ]
      }
  }
]

是否有一个已经在执行类似操作的库?

编辑:我仔细查看了Compodoc,它实际上使能够在json中生成文档,而这正是我想要的: compodoc src / tsconfig.json -e json

hohoman610 回答:如何从源代码解析角度元素元数据

我仔细查看了Compodoc,它实际上使能够在json中生成文档,而这正是我所需要的:compodoc src / tsconfig.json -e json

本文链接:https://www.f2er.com/3040575.html

大家都在问