Clang-Doc¶
clang-doc 是一个从源代码和注释生成 C 和 C++ 文档的工具。
该工具处于非常早期的开发阶段,因此您可能会遇到错误和崩溃。向 LLVM 错误跟踪器 提交有关如何重现问题的报告将无疑对项目有所帮助。如果您有任何想法或建议,请在那里提出功能请求。
使用¶
clang-doc 是一个基于 LibTooling 的工具,因此需要您的项目编译命令数据库(有关如何执行此操作的示例,请参见 如何为 LLVM 设置工具)。
该工具默认情况下将处理文件列表
$ clang-doc File1.cpp File2.cpp ... FileN.cpp
该工具也可以与编译命令数据库一起使用
$ clang-doc --executor=all-TUs compile_commands.json
要仅从数据库中选择文件子集,请使用 --filter 标志
$ clang-doc --executor=all-TUs --filter=File[0-9]+.cpp compile_commands.json
输出¶
clang-doc 生成一个文档目录。为项目源代码中的每个命名空间和记录生成一个文件,其中包含该项目的全部文档(包括包含的函数、方法和枚举)。
顶层目录可以通过 output 标志进行配置
$ clang-doc --output=output/directory/ compile_commands.json
配置¶
目前,clang-doc 的配置仅限于命令行选项。将来,它可能会开发使用配置文件的能力,但目前尚无此类工作。
选项¶
clang-doc 提供以下选项
$ clang-doc --help
OVERVIEW: Generates documentation from source code and comments.
Example usage for files without flags (default):
  $ clang-doc File1.cpp File2.cpp ... FileN.cpp
Example usage for a project using a compile commands database:
  $ clang-doc --executor=all-TUs compile_commands.json
USAGE: clang-doc [options] <source0> [... <sourceN>]
OPTIONS:
Generic Options:
  -help                      - Display available options (-help-hidden for more)
  -help-list                 - Display list of available options (-help-list-hidden for more)
  -version                   - Display the version of this program
clang-doc options:
  --doxygen                   - Use only doxygen-style comments to generate docs.
  --extra-arg=<string>        - Additional argument to append to the compiler command line
                                Can be used several times.
  --extra-arg-before=<string> - Additional argument to prepend to the compiler command line
                                Can be used several times.
  --format=<value>            - Format for outputted docs.
    =yaml                     -   Documentation in YAML format.
    =md                       -   Documentation in MD format.
    =html                     -   Documentation in HTML format.
  --ignore-map-errors         - Continue if files are not mapped correctly.
  --output=<string>           - Directory for outputting generated files.
  -p <string>                 - Build path
  --project-name=<string>     - Name of project.
  --public                    - Document only public declarations.
  --repository=<string>       -
                                URL of repository that hosts code.
                                Used for links to definition locations.
  --source-root=<string>      -
                                Directory where processed files are stored.
                                Links to definition locations will only be
                                generated if the file is in this dir.
  --stylesheets=<string>      - CSS stylesheets to extend the default styles.
如果 format 设置为 html,则以下标志仅应使用: - repository - source-root - stylesheets