Plugin flow
MkNodesPlugin
Activates new-style MkDocs plugin lifecycle.
Source
Hook info
The startup
event runs once at the very beginning of an mkdocs
invocation.
New in MkDocs 1.4.
The presence of an on_startup
method (even if empty) migrates the plugin to the new
system where the plugin object is kept across builds within one mkdocs serve
.
Note that for initializing variables, the __init__
method is still preferred.
For initializing per-build variables (and whenever in doubt), use the on_config
event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
Literal['build', 'gh-deploy', 'serve']
|
the command that MkDocs was invoked with, e.g. "serve" for |
required |
dirty |
bool
|
whether |
required |
Create the project based on MkDocs config.
Source
Hook info
The config
event is the first event called on build and is run immediately
after the user configuration is loaded and validated. Any alterations to the
config should be made here.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
MkDocsConfig
|
global configuration object |
required |
Returns:
Type | Description |
---|---|
MkDocsConfig | None
|
global configuration object |
Create the node tree and write files to build folder.
In this step we aggregate all files and info we need to build the website. This includes:
- Markdown pages (MkPages)
- Templates
- CSS files
Source
Hook info
The files
event is called after the files collection is populated from the
docs_dir
. Use this event to add, remove, or alter files in the
collection. Note that Page objects have not yet been associated with the
file objects in the collection. Use Page Events to manipulate page
specific data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files |
Files
|
global files collection |
required |
config |
MkDocsConfig
|
global configuration object |
required |
Returns:
Type | Description |
---|---|
Files | None
|
global files collection |
Populate LinkReplacer and build path->MkPage mapping for following steps.
Source
Hook info
The nav
event is called after the site navigation is created and can
be used to alter the site navigation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nav |
Navigation
|
global navigation object |
required |
config |
MkDocsConfig
|
global configuration object |
required |
files |
Files
|
global files collection |
required |
Returns:
Type | Description |
---|---|
Navigation | None
|
global navigation object |
Add our own info to the MkDocs environment.
Source
Hook info
The env
event is called after the Jinja template environment is created
and can be used to alter the
Jinja environment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env |
Environment
|
global Jinja environment |
required |
config |
MkDocsConfig
|
global configuration object |
required |
files |
Files
|
global files collection |
required |
Returns:
Type | Description |
---|---|
Environment | None
|
global Jinja Environment |
Delete the temporary template files.
Source
Hook info
The post_build
event does not alter any variables. Use this event to call
post-build scripts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
MkDocsConfig
|
global configuration object |
required |
During this phase we set the edit paths.
Source
Hook info
The pre_page
event is called before any actions are taken on the subject
page and can be used to alter the Page
instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page |
Page
|
|
required |
config |
MkDocsConfig
|
global configuration object |
required |
files |
Files
|
global files collection |
required |
Returns:
Type | Description |
---|---|
Page | None
|
|
During this phase links get replaced and jinja2
stuff get rendered.
Source
mkdocs_mknodes.plugin.MkNodesPlugin.on_page_markdown | |
---|---|
Hook info
The page_markdown
event is called after the page's markdown is loaded
from file and can be used to alter the Markdown source text. The meta-
data has been stripped off and is available as page.meta
at this point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
markdown |
str
|
Markdown source text of page as string |
required |
page |
Page
|
|
required |
config |
MkDocsConfig
|
global configuration object |
required |
files |
Files
|
global files collection |
required |
Returns:
Type | Description |
---|---|
str | None
|
Markdown source text of page as string |
Delete the temporary template files.
Source
Hook info
The post_build
event does not alter any variables. Use this event to call
post-build scripts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
MkDocsConfig
|
global configuration object |
required |
Page info
Code for this page
Resources
Resources(css=[],
markdown_extensions={'admonition': {},
'attr_list': {},
'md_in_html': {},
'pymdownx.details': {},
'pymdownx.emoji': {'emoji_generator': <function to_svg at 0x7f170970c540>,
'emoji_index': <function twemoji at 0x7f170970c400>},
'pymdownx.highlight': {'anchor_linenums': True,
'line_spans': '__span',
'pygments_lang_class': True},
'pymdownx.magiclink': {'repo': 'mkdocs_mknodes',
'repo_url_shorthand': True,
'user': 'phil65'},
'pymdownx.superfences': {}},
plugins=[Plugin('mkdocstrings')],
js=[],
assets=[Asset('speechbubble_10d5a72.css')],
packages=[])