{"id":9262,"library":"pytkdocs","title":"PyTKDocs","description":"PyTKDocs is a Python library designed to load and parse documentation for Python objects. It serves as the powerful backend for `mkdocstrings`, enabling it to extract and render API documentation directly from Python source code. It is currently at version 0.16.5 and typically releases bug fixes and minor improvements frequently, with major version bumps being less common.","status":"active","version":"0.16.5","language":"en","source_language":"en","source_url":"https://github.com/mkdocstrings/pytkdocs","tags":["documentation","parser","mkdocs","mkdocstrings","inspection","api-docs"],"install":[{"cmd":"pip install pytkdocs","lang":"bash","label":"Install PyTKDocs"}],"dependencies":[],"imports":[{"symbol":"Loader","correct":"from pytkdocs.loader import Loader"}],"quickstart":{"code":"from pytkdocs.loader import Loader\n\n# Example: Load documentation for a Python object\n# Ensure 'your_module' is importable in your environment.\n# For demonstration, we'll use a placeholder or common library if available.\n# In a real scenario, you'd point to your own code.\n\n# To make this runnable without specific external dependencies, \n# we'll create a dummy module temporarily if needed, or use a built-in concept.\n# However, pytkdocs usually works on actual code.\n\n# Let's assume a simple module structure to document:\n# # my_package/my_module.py\n# class MyClass:\n#     \"\"\"A sample class.\"\"\"\n#     def __init__(self, name: str): \n#         \"\"\"Initialize the class.\"\"\"\n#         self.name = name\n\n# For this quickstart, we'll try to document 'os.path'\n# If you were documenting your own code, ensure it's in PYTHONPATH.\n\nloader = Loader()\n\ntry:\n    # Try to document a common stdlib module\n    data = loader.get_object_documentation(\n        objects=[\"os.path\"],\n        # You can add options like 'members', 'docstring_style', etc.\n        # Example: members={\"os.path\": [\"abspath\", \"join\"]}\n    )\n    print(\"Successfully loaded documentation for os.path:\")\n    # In real usage, 'data' would be processed. Here, we just print parts.\n    if data and data[0].get('members'):\n        print(f\"Found {len(data[0]['members'])} members.\")\n    else:\n        print(\"No detailed members found (might need 'members' option or different object).\")\nexcept Exception as e:\n    print(f\"Could not load documentation for os.path: {e}\")\n\n# To document your own module, ensure it's importable:\n# For example, if you have 'my_package.my_module.MyClass' and 'my_package' is on PYTHONPATH:\n# my_own_data = loader.get_object_documentation(\n#     objects=[\"my_package.my_module.MyClass\"],\n#     members={\"my_package.my_module.MyClass\": True} # To get all members\n# )\n# print(my_own_data)","lang":"python","description":"This quickstart demonstrates how to initialize the `Loader` and use `get_object_documentation` to extract structured documentation from a Python object. The example uses `os.path` from the standard library. For documenting your own code, ensure your package is correctly installed or discoverable in the Python path."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer to ensure full compatibility and support.","message":"PyTKDocs versions 0.16.3 and newer have dropped official support for Python 3.8. While it might still function, issues are not guaranteed to be fixed, and installation might become problematic.","severity":"breaking","affected_versions":">=0.16.3"},{"fix":"Upgrade `pytkdocs` to version 0.16.4 or newer: `pip install --upgrade pytkdocs`. These versions contain fixes to use the modern `ast.Constant` node.","message":"Older `pytkdocs` versions (pre-0.16.4) used deprecated attributes from Python's `ast` module (`ast.Str`, `ast.Num`, `ast.Bytes`, `ast.Ellipsis`, `ast.NameConstant`). Running these versions with newer Python interpreters (e.g., Python 3.12+) can lead to warnings or unexpected behavior.","severity":"gotcha","affected_versions":"<0.16.4"},{"fix":"Double-check the import path for typos. If documenting local code, ensure the root of your package is in `PYTHONPATH` or install your package in editable mode (`pip install -e .`). Ensure all necessary dependencies for the target module are installed.","message":"When using `get_object_documentation`, ensure that the object paths you provide are fully qualified (e.g., `your_package.your_module.YourClass`) and that the corresponding Python module is importable in the environment where `pytkdocs` is running.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Upgrade `pytkdocs` to version 0.16.4 or newer: `pip install --upgrade pytkdocs`.","cause":"`pytkdocs` versions prior to 0.16.4 used deprecated `ast` module features that are removed or changed in newer Python versions.","error":"TypeError: ast.Str is deprecated and will be removed in Python 3.12"},{"fix":"Verify the exact object path for typos. Ensure the Python package/module is correctly installed and discoverable. If developing locally, ensure your package is in editable mode (`pip install -e .`) or its parent directory is in `PYTHONPATH`.","cause":"The Python interpreter could not locate or import the specified object path. This commonly happens if the module is not installed, not in `PYTHONPATH`, or the path is incorrect.","error":"RuntimeError: Cannot import object 'my_package.my_module.MyClass' from module"},{"fix":"Upgrade your Python environment to version 3.9 or newer. You can use tools like `pyenv` or `conda` to manage multiple Python versions.","cause":"`pytkdocs` dropped support for Python 3.8 starting from version 0.16.3, and later versions enforce this requirement during installation.","error":"ERROR: Package 'pytkdocs' requires Python '>=3.9' but the running Python is 3.8.x"}]}