extension ¤
This module holds the code of the Markdown extension responsible for matching "autodoc" instructions.
The extension is composed of a Markdown block processor that matches indented blocks starting with a line like ::: identifier
.
For each of these blocks, it uses a handler to collect documentation about the given identifier and render it with Jinja templates.
Both the collection and rendering process can be configured by adding YAML configuration under the "autodoc" instruction:
::: some.identifier
handler: python
options:
option1: value1
option2:
- value2a
- value2b
option_x: etc
Classes:
-
AutoDocProcessor
–Our "autodoc" Markdown block processor.
-
MkdocstringsExtension
–Our Markdown extension.
AutoDocProcessor ¤
AutoDocProcessor(
parser: BlockParser,
md: Markdown,
config: dict,
handlers: Handlers,
autorefs: AutorefsPlugin,
)
Bases: BlockProcessor
Our "autodoc" Markdown block processor.
It has a test
method that tells if a block matches a criterion, and a run
method that processes it.
It also has utility methods allowing to get handlers and their configuration easily, useful when processing a matched block.
Parameters:
-
parser
¤BlockParser
) –A
markdown.blockparser.BlockParser
instance. -
md
¤Markdown
) –A
markdown.Markdown
instance. -
config
¤dict
) –The configuration of the
mkdocstrings
plugin. -
handlers
¤Handlers
) –The handlers container.
-
autorefs
¤AutorefsPlugin
) –The autorefs plugin instance.
Methods:
run ¤
run(parent: Element, blocks: MutableSequence[str]) -> None
Run code on the matched blocks.
The identifier and configuration lines are retrieved from a matched block and used to collect and render an object.
Parameters:
-
parent
¤Element
) –The parent element in the XML tree.
-
blocks
¤MutableSequence[str]
) –The rest of the blocks to be processed.
MkdocstringsExtension ¤
Bases: Extension
Our Markdown extension.
It cannot work outside of mkdocstrings
.
Parameters:
-
config
¤dict
) –The configuration items from
mkdocs
andmkdocstrings
that must be passed to the block processor when instantiated inextendMarkdown
. -
handlers
¤Handlers
) –The handlers container.
-
autorefs
¤AutorefsPlugin
) –The autorefs plugin instance.
-
**kwargs
¤Any
, default:{}
) –Keyword arguments used by
markdown.extensions.Extension
.
Methods:
-
extendMarkdown
–Register the extension.