Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Load Python objects documentation.

License

NotificationsYou must be signed in to change notification settings

mkdocstrings/pytkdocs

cidocumentationpypi versionconda versiongitter

Load Python objects documentation.

Important

This project is deprecated in favor of the much more powerfulGriffe project.

Installation

pip install pytkdocs

Withuv:

uv tool install pytkdocs

Withconda:

condainstall-cconda-forgepytkdocs

Usage

pytkdocs accepts JSON on standard input and writes JSON on standard output.

Input format:

{"objects": [    {"path":"pytkdocs","new_path_syntax":false,"members":true,"inherited_members":false,"filters": ["!^_[^_]"      ],"docstring_style":"google","docstring_options": {"replace_admonitions":true      }    }  ]}

Output format:

{"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": []    }  ]}

Command-line

Runningpytkdocs without argument will read the whole standard input,and output the result once.

Runningpytkdocs --line-by-line will enter an infinite loop,where at each iteration one line is read on the standard input,and the result is written back on one line.This allows other programs to usepytkdocs in a subprocess,feeding it single lines of JSON, and reading back single lines of JSON as well.This mode was actually implemented specifically formkdocstrings.

Configuration

The configuration options available are:

  • new_path_syntax: when set to true, this option forces the use of the new object path syntax,which uses a colon (:) to delimit modules from other objects.

  • filters: filters are regular expressions that allow to select or un-select objects based on their name.They are applied recursively (on every child of every object).If the expression starts with an exclamation mark,it will filter out objects matching it (the exclamation mark is removed before evaluation).If not, objects matching it are selected.Every regular expression is performed against every name.It allows fine-grained filtering. Example:

    • !^_: filter out every object whose name starts with_ (private/protected)
    • ^__: but still select those who start with two_ (class-private)
    • !^__.*__$: except those who also end with two_ (specials)
  • members: this option allows to explicitly select the members of the top-object.IfTrue, select every members that passes filters. IfFalse, select nothing.If it's a list of names, select only those members, and apply filters on their children only.

  • inherited_members: true or false (default). When enabled, inherited members will be selected as well.

  • docstring_style: the docstring style to use when parsing the docstring.google,restructured-text1 andnumpy2.

  • docstring_options: options to pass to the docstring parser.

    • replace_admonitions boolean option (default: true). When enabled, this option willreplace titles of an indented block by their Markdown admonition equivalent:AdmonitionType: Title will become!!! admonitiontype "Title".
    • trim_doctest_flags boolean option (default: true). When enabled, all doctestflags (of the form# doctest: +FLAG and<BLANKLINE>) located within pythonexample blocks will be removed from the parsed output.

    Thegoogle docstring style accepts both options. Thenumpy style only acceptstrim_doctest_flags. Therestructured-text style does not accept any options.

1: reStructured Text parsing is in active development and is not feature complete yet.
2: The following sections are currently not supported :Notes,See Also,Warns andReferences.

Details onnew_path_syntax

Example:

New syntaxpackage.module:Class.attribute
Old syntaxpackage.module.Class.attribute
  • If there is a colon is an object's path,pytkdocs splits the path accordingly,regardless of the value ofnew_path_syntax.
  • If there isn't a colon, andnew_path_syntax is false,pytkdocs uses theold importing behavior.
  • If there isn't a colon, andnew_path_syntax is true,pytkdocs uses the newimporting behavior and therefore considers that the path points to a module.

Sponsor this project

  •  

Packages

No packages published

Contributors23

Languages


[8]ページ先頭

©2009-2025 Movatter.jp