加载Python对象文档。
pytkdocs的Python项目详细描述
pytkdocs公司
加载Python对象文档。在
要求
pytkdocs
需要Python3.6或更高版本。在
# install pyenv git clone https://github.com/pyenv/pyenv ~/.pyenv # setup pyenv (you should also put these three lines in .bashrc or similar)exportPATH="${HOME}/.pyenv/bin:${PATH}"exportPYENV_ROOT="${HOME}/.pyenv"eval"$(pyenv init -)"# install Python 3.6 pyenv install 3.6.12 # make it available globally pyenv global system 3.6.12详细信息>
安装
使用pip
:
使用^{
python3.6 -m pip install --user pipx pipx install --python python3.6 pytkdocs
使用conda
:
condainstall-cconda-forgepytkdocs
使用
pytkdocs
在标准输入上接受JSON,在标准输出上写入JSON。在
输入格式:
{"objects":[{"path":"pytkdocs","new_path_syntax":false,"members":true,"inherited_members":false,"filters":["!^_[^_]"],"docstring_style":"google","docstring_options":{"replace_admonitions":true}}]}
输出格式:
{"loading_errors":["string (message)"],"parsing_errors":{"string (object)":["string (message)"]},"objects":[{"name":"pytkdocs","path":"pytkdocs","category":"module","file_path":"/media/data/dev/pawamoy/pytkdocs/src/pytkdocs/__init__.py","relative_file_path":"pytkdocs/__init__.py","properties":["special"],"parent_path":"pytkdocs","has_contents":true,"docstring":"pytkdocs package.\n\nLoad Python objects documentation.","docstring_sections":[{"type":"markdown","value":"pytkdocs package.\n\nLoad Python objects documentation."}],"source":{"code":"\"\"\"\npytkdocs package.\n\nLoad Python objects documentation.\n\"\"\"\n\nfrom typing import List\n\n__all__: List[str] = []\n","line_start":1},"children":{"pytkdocs.__all__":{"name":"__all__","path":"pytkdocs.__all__","category":"attribute","file_path":"/media/data/dev/pawamoy/pytkdocs/src/pytkdocs/__init__.py","relative_file_path":"pytkdocs/__init__.py","properties":["special"],"parent_path":"pytkdocs","has_contents":false,"docstring":null,"docstring_sections":[],"source":{},"children":{},"attributes":[],"methods":[],"functions":[],"modules":[],"classes":[]}},"attributes":["pytkdocs.__all__"],"methods":[],"functions":[],"modules":["pytkdocs.__main__","pytkdocs.cli","pytkdocs.loader","pytkdocs.objects","pytkdocs.parsers","pytkdocs.properties","pytkdocs.serializer"],"classes":[]}]}
命令行
不带参数运行pytkdocs
将读取整个标准输入,
并输出一次结果。在
运行pytkdocs --line-by-line
将进入无限循环,
每次迭代时,在标准输入上读取一行,
结果写回一行。
这允许其他程序在子进程中使用pytkdocs
,
给它输入一行JSON,并读回一行JSON。
这种模式实际上是专门为
mkdocstrings。在
配置
可用的配置选项包括:
- 在
new_path_syntax
:当设置为true时,此选项强制使用新的对象路径语法, 它使用冒号(:
)将模块与其他对象分隔开来。在 - 在
filters
:过滤器是允许根据对象名称选择或取消选择对象的正则表达式。 它们递归地应用(在每个对象的每个子对象上)。 如果表达式以感叹号开头, 它将过滤出与之匹配的对象(在求值之前去掉感叹号)。 否则,将选择与之匹配的对象。 每个正则表达式都针对每个名称执行。 它允许细粒度过滤。示例:!^_
:筛选出名称以_
(private/protected)开头的每个对象^__
:但仍然选择那些以两个开头的_
(class private)!^__.*__$
:除了那些同时以两个_
(特价)结尾的人
- 在
members
:此选项允许显式选择top对象的成员。 如果True
,请选择通过筛选器的每个成员。如果False
,则不选择任何内容。 如果是名称列表,请仅选择这些成员,并仅对其子级应用筛选器。在 - 在
inherited_members
:true或false(默认值)。启用时,也将选择继承的成员。在 - 在
docstring_style
:解析docstring时要使用的docstring样式。google
和restructured-text
1。在 - 在
docstring_options
:传递给docstring解析器的选项。在google
接受replace_admonitions
布尔选项(默认值:true)。启用后,此选项将 将缩进块的标题替换为等效的标记警告:AdmonitionType: Title
将变成{}。 restructured-text
不接受任何选项。
1:重组文本解析正在积极开发中,功能尚未完成。在
关于new_path_syntax
示例:
New syntax | ^{ |
Old syntax | ^{ |
- 如果冒号是对象的路径,
pytkdocs
会相应地拆分路径, 不管new_path_syntax
的值。 - 如果没有冒号,并且
new_path_syntax
为false,pytkdocs
使用 旧的导入行为。 - 如果没有冒号,并且
new_path_syntax
为真,pytkdocs
使用新的 导入行为,因此认为路径指向模块。
!!!警告“new_path_syntax
选项是临时的。”
它的存在只是为了简化到新路径语法的转换。在
Here is an idea of its life time:
- **version 0.9:** the default value for `new_path_syntax` is false.
A pending deprecation warning is emmitted to tell users to switch to the new path syntax.
- **once version 0.10 is published:** [`mkdocstrings`](https://github.com/pawamoy/mkdocstrings)
will log an MkDocs warning, making the builds fail
when `new_path_syntax` is false and strict mode is enabled.
- **version 0.11:** the default value for `new_path_syntax` becomes true,
and the warning becomes a deprecation warning.
- **version 0.13:** the `new_path_syntax` option is removed.
Please update your paths to use the new colon syntax as soon as possible.
- 项目
标签: