轻量级降价代码文档生成器
markdowndocs的Python项目详细描述
降价文档
markdowndocs
是一个轻量级的降价文档生成器,它生成一个简单的.md
文件,该文件基于docstring和原始代码记录代码。在
Installation and usage| Usage| Using markdowndocs with pre-commit| Contributor guidelines| Code documentation
安装和使用
安装
安装方式:
pip install markdowndocs
用法
选项
要在工作目录中的所有模块上运行markdowndocs
,请执行以下操作:
要在工作目录中的特定模块上运行markdowndocs
,请执行以下操作:
$ markdowndocs --module-names <my_module>
要在工作目录中的所有模块上运行markdowndocs
,除了特定的模块,请执行以下操作:
$ markdowndocs --exclude-modules <my_module>
完整选项和使用:
$ markdowndocs --help usage: markdowndocs [-h] [--output-file-name NAME] [--add-to-readme] [--exclude-dependencies] [--exclude-code] [--version] (-a | -m NAME [NAME ...] | -e NAME [NAME ...]) Markdown documentation package. optional arguments: -h, --help show this help message and exit --output-file-name NAME Use this option to specify a custom output file name for the .md documentation [default: code_documentation.md] --add-to-readme If enabled, adds a link to your documentation file to your README.md file with the following format: ## Code documentation [Code Documentation](code_documentation.md) [default: False] --exclude-dependencies If enabled, includes a list of dependencies for each module. [default: False] --exclude-code If enabled, excludes the raw code for each function. [default: False] --version Show version information and exit. -a, --all Use this option to generate documentation for all modules in your current working directory [default: False] -m NAME [NAME ...], --module-names NAME [NAME ...] Use this option to generate documentation for a specific module or modules -e NAME [NAME ...], --exclude-modules NAME [NAME ...] Use this option to exclude a specific module or multiple modules from the documentation generator
输出
默认情况下,生成的降价文档存储在名为code_documentation.md
的文件中。可以使用--output-file-name
参数设置自定义文件名。
默认情况下,输出中包含以下内容:
- 用于模块、类和函数(包括私有方法)的用户定义docstring
- 所有模块、类和函数的内部链接和嵌套内容表
- 每个模块的依赖项(即导入)列表
- 每个函数的原始代码。在
示例
Markdowndocs输出:
- a single function
- multiple_functions
- class and functions
- class and private functions
- multiple_modules
- markdowndocs code documentation
已知限制
markdowndocs
将只在工作目录中的目录中拾取模块,而不会在子目录中拾取模块(即当前只支持一个级别的“嵌套”)markdowndocs
假设代码中的所有导入都正常工作,即不引用不存在的模块。在markdowndocs
不能很好地与{a12}配合。在
将markdowndocs
与预提交挂钩一起使用
要在每次新提交时使用markdowndocs
生成最新文档,请将以下配置添加到.pre-commit-config.yaml
文件中(并在args
字段中添加首选配置选项):
repos: - repo: https://github.com/ngoet/markdowndocs rev: 0.1.0 hooks: - id: markdowndocs pass_filenames: false args: ["-m", "<my-module-name>", "--add-to-readme"]
贡献者指南
欢迎提出改进建议。如果您发现任何内容已损坏,或希望提出更改建议,请打开问题。在
代码文档
- 项目
标签: