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

A Python handler for mkdocstrings.

License

NotificationsYou must be signed in to change notification settings

mkdocstrings/python

Repository files navigation

A Python handler formkdocstrings.

cidocumentationpypi versiongitter


The Python handler usesGriffeto collect documentation from Python source code.The word "griffe" can sometimes be used instead of "signature" in French.Griffe is able to visit the Abstract Syntax Tree (AST) of the source code to extract useful information.It is also able to execute the code (by importing it) and introspect objects in memorywhen source code is not available. Finally, it can parse docstrings following different styles.

Installation

You can install this handler as amkdocstrings extra:

# PEP 621 dependencies declaration# adapt to your dependencies manager[project]dependencies = ["mkdocstrings[python]>=0.18",]

You can also explicitly depend on the handler:

# PEP 621 dependencies declaration# adapt to your dependencies manager[project]dependencies = ["mkdocstrings-python",]

Preview

mkdocstrings_python_gif

Features

  • Data collection from source code: collection of the object-tree and the docstrings is done thanks toGriffe.

  • Support for type annotations: Griffe collects your type annotations andmkdocstrings uses themto display parameter types or return types. It is even able to automatically add cross-referencesto other objects from your API, from the standard library or third-party libraries!Seehow to load inventories to enable it.

  • Recursive documentation of Python objects: just use the module dotted-path as an identifier, and you get the fullmodule docs. You don't need to inject documentation for each class, function, etc.

  • Support for documented attributes: attributes (variables) followed by a docstring (triple-quoted string) willbe recognized by Griffe in modules, classes and even in__init__ methods.

  • Multiple docstring-styles support: common support for Google-style, Numpydoc-style,and Sphinx-style docstrings. SeeGriffe's documentation on docstrings support.

  • Admonition support in Google docstrings: blocks likeNote: orWarning: will be transformedto theiradmonition equivalent.We do not support nested admonitions in docstrings!

  • Every object has a TOC entry: we render a heading for each object, meaningMkDocs picks them into the Tableof Contents, which is nicely displayed by the Material theme. Thanks tomkdocstrings cross-reference ability,you can reference other objects within your docstrings, with the classic Markdown syntax:[this object][package.module.object] or directly with[package.module.object][]

  • Source code display:mkdocstrings can add a collapsible div containing the highlighted source codeof the Python object.


[8]ページ先頭

©2009-2025 Movatter.jp