Skip to main content

Load Python objects documentation.

Project description

pytkdocs

ci documentation pypi version conda version gitter

Load Python objects documentation.

Requirements

pytkdocs requires Python 3.6 or above.

To install Python 3.6, I recommend using pyenv.
# install pyenv
git clone https://github.com/pyenv/pyenv ~/.pyenv

# setup pyenv (you should also put these three lines in .bashrc or similar)
export PATH="${HOME}/.pyenv/bin:${PATH}"
export PYENV_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

Installation

With pip:

python3.6 -m pip install pytkdocs

With pipx:

python3.6 -m pip install --user pipx

pipx install --python python3.6 pytkdocs

With conda:

conda install -c conda-forge pytkdocs

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

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

Running pytkdocs --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 use pytkdocs in a subprocess, feeding it single lines of JSON, and reading back single lines of JSON as well. This mode was actually implemented specifically for mkdocstrings.

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. If True, select every members that passes filters. If False, 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 and numpy2.

  • docstring_options: options to pass to the docstring parser.

    • google accepts a replace_admonitions boolean option (default: true). When enabled, this option will replace titles of an indented block by their Markdown admonition equivalent: AdmonitionType: Title will become !!! admonitiontype "Title".
    • restructured-text does not accept any options.
    • numpy 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 and References.

Details on new_path_syntax

Example:

New syntax package.module:Class.attribute
Old syntax package.module.Class.attribute
  • If there is a colon is an object's path, pytkdocs splits the path accordingly, regardless of the value of new_path_syntax.
  • If there isn't a colon, and new_path_syntax is false, pytkdocs uses the old importing behavior.
  • If there isn't a colon, and new_path_syntax is true, pytkdocs uses the new importing behavior and therefore considers that the path points to a module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytkdocs-0.12.0.tar.gz (54.5 kB view details)

Uploaded Source

Built Distribution

pytkdocs-0.12.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file pytkdocs-0.12.0.tar.gz.

File metadata

  • Download URL: pytkdocs-0.12.0.tar.gz
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for pytkdocs-0.12.0.tar.gz
Algorithm Hash digest
SHA256 746905493ff79482ebc90816b8c397c096727a1da8214a0ccff662a8412e91b3
MD5 de0429d121e3f47a1bff43593cd4860d
BLAKE2b-256 76b1d1bbdae7ebf6ee1683e93c68271baa5cdc73dfe1f38033d81b641b5bf573

See more details on using hashes here.

File details

Details for the file pytkdocs-0.12.0-py3-none-any.whl.

File metadata

  • Download URL: pytkdocs-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for pytkdocs-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12cb4180d5eafc7819dba91142948aa7b85ad0a3ad0e956db1cdc6d6c5d0ef56
MD5 c59fbda2399454053042b89c13ae2be7
BLAKE2b-256 a824ea33bd0c4cffed8f2a45d9af9b5909a65661561bd2e0c96f9cbc60c29a20

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page