Tools and guide for documenting TypeScript code?

后端 未结 6 473
一向
一向 2021-01-30 20:00

Are there any tools for generating documentation for TypeScript source code? Or should I use something generic like NaturalDocs? What would be the recommended style of the block

6条回答
  •  太阳男子
    2021-01-30 20:25

    I'm compiling to JavaScript and use jsduck (https://github.com/senchalabs/jsduck) to generate api documentation based on the JavaScript files. As long as you don't tell tsc to remove comments that works perfectly, except of fields without a default value(!).

    module example {
    
    /**
     * My class description
     * @class example.MyClass
     */
    export class MyClass {
        /**
         * Description of my property
         * @property {String} myProperty
         */
        myProperty: string = null;
    
        /**
         * This property will be removed in compiled JavaScript, that's why
         * this documentation will not be visible in jsduck.
         */
        willNotWork: string;
    
        /**
         * Description of my method
         * @method myFunction
         * @param {String} myParam
         */
        myFunction(myParam: string): void {
        }
    }
    
    } // end of module
    

提交回复
热议问题