目录

Document Generation

DevEco Studio makes it easy to create ArkTSDoc documentation using the Generate ArkTSDoc feature. With this feature, you can quickly generate reference documents for variables, methods, APIs, classes, and other information that you want to expose from your code.

Since DevEco Studio 6.1.0 Beta1, ArkTSDoc supports multi-module export and allows you to exclude specific directories from the export.

  • You can generate ArkTSDoc documentation for .ets, .ts, .js, and .md files in your project or directory.
  • Only exported variables, methods, APIs, and classes are included in the generated ArkTSDoc documentation. Unexported items are not included.
  • If you choose to export documentation for the entire project or directory, the generated ArkTSDoc documentation will maintain the same directory structure as the original.

Procedure

  1. On the menu bar, choose Tools > Generate ArkTSDoc... to open the Generate ArkTSDoc dialog box.
  2. Set the scope for generating ArkTSDoc documentation. You can export the entire project, a single module, multiple modules, a specific directory, or a single file.

    Click the drop-down arrow next to Modules to display all modules, and select one or more modules as the export scope. When there are many modules, you can use the search feature to quickly locate a module.

  3. During export, exclude target directories via Command line arguments with the -e subcommand. Separate multiple directories with semicolons (;). Paths starting with ./ denote the project root directory.

    Since DevEco Studio 6.1.0 Release, the Command line arguments field supports Ant-style path patterns, where ? matches a single character, * matches a single directory or file name, and ** matches zero or more directories at any level.

  4. After entering the destination path in the Output directory field, click Generate.
  5. To enable the ArkTSDoc documentation to automatically open in the browser after being generated, select Open generated documentation in browser. When you are done, click Generate to start the scanning and documentation generation.

    The left panel of the generated ArkTSDoc mirrors your project's directory structure, while the right panel allows you to navigate to specific variables, methods, APIs, or classes in the documentation.

    If the Open generated documentation in browser option is not selected, a notification will pop up in the lower right corner of DevEco Studio after the documentation is generated. You can click Go to Folder to navigate to the generated ArkTSDoc folder and open the index.html file in a browser to view the documentation.

Example of Generated Documentation

Comment format: Currently, only the /** */ comment format is supported. It also supports standard tags such as param and custom tags such as myTag for generating documentation.
/**
 * Prints "log" logs.
 *
 * @param { string } message - Text to print.
 * @myTag
 * @since 11
 */

Sample code:

/**
 * Defines the demo class
 *
 * @since 11
 */
export class Demo {
    /**
     * Prints "log" logs.
     *
     * @param { string } message - Text to print.
     * @myTag
     * @since 11
     */
    static log(message: string): void {
        
    }
}

Example of generated ArkTSDoc