Skip to main content

Load Python objects documentation.

Project description

pytkdocs

ci documentation pypi version

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.8

# make it available globally
pyenv global system 3.6.8

Installation

With pip:

python3.6 -m pip install pytkdocs

With pipx:

python3.6 -m pip install --user pipx

pipx install --python python3.6 pytkdocs

Usage

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

Input format:

{
  "objects": [
    {
      "path": "pytkdocs",
      "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:

  • 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.

  • docstring_style: the docstring style to use when parsing the docstring. Only one parser available: google.

  • 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".
  • inherited_members: true or false (default). When enabled, inherited members will be selected as well.

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.6.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

pytkdocs-0.6.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytkdocs-0.6.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.6.15-arch1-1

File hashes

Hashes for pytkdocs-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4dec18d0465aa84e38629ea3b32c2215e2bc4714c611b0b64c35b786aae1f180
MD5 a5ad33d1e5c61a38421d99d7f27d3ae1
BLAKE2b-256 f9720e5402d6a9f4575360280b8f13648cdf43b3ad414d7d54ea3db567a416b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytkdocs-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.8.3 Linux/5.6.15-arch1-1

File hashes

Hashes for pytkdocs-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5675088061ab1950688e52e581d21a98f5d4945b92fe55ad26ba4a0670359ef
MD5 4b7a94bc96cb7cdc13a71579aa854ab4
BLAKE2b-256 4789008354d3ef4f853e2d8e3e0a7086670e0f766397a9be8d020f714bebb4d0

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