Using decorators
Code for this section¶
MkNav.route Docstrings¶
Class used for MkNav decorator routing.
__call__
¶
Decorator method to use for routing.
The decorated functions need to return either a MkPage or an MkNav. They will get registered to the router-MkNav then.
In comparison to page()
and nav()
, it is not required to know in advance what
will be returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The section path for the returned |
()
|
__init__
¶
__init__(nav: MkNav)
Constructor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nav
|
MkNav
|
MkNav to use for routing |
required |
nav
¶
Decorator method to use for routing Navs.
The decorated functions will get passed an MkNav as an argument which can be modified then. They will get registered to the router-MkNav afterwards.
There is also the possibility to create a new MkNav and return it in the decorated method, that MkNav takes preference then over the modified one.
Examples:
@nav.route.nav("Routed nav")
def _(nav: mk.MkNav):
nav += ...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The section path for the returned MkNav |
()
|
kwargs
|
Any
|
Keyword arguments passed to the MkNav constructor. |
{}
|
page
¶
Decorator method to use for routing Pages.
The decorated functions will get passed an MkPage as an argument which can be modified then. The resulting page will get registered to the router-MkNav afterwards.
There is also the possibility to create a new MkPage and return it in the decorated method, that MkPage takes preference then over the modified one.
The keyword arguments can be used to pass metadata-related keyword arguments to the MkPage constructor.
Examples:
@nav.route.page("Routed page", icon=...)
def _(page: mk.MkPage):
page += ...
Args: path: The section path for the returned MkPage kwargs: Keyword arguments passed to the MkPage constructor.
Page info
Code for this section
Resources
Resources(css=[],
markdown_extensions={'attr_list': {},
'md_in_html': {},
'pymdownx.emoji': {'emoji_generator': <function to_svg at 0x7fd7a6931800>,
'emoji_index': <function twemoji at 0x7fd7a69316c0>},
'pymdownx.highlight': {'anchor_linenums': True,
'line_spans': '__span',
'pygments_lang_class': True},
'pymdownx.magiclink': {'repo': 'mknodes',
'repo_url_shorthand': True,
'user': 'phil65'},
'pymdownx.superfences': {}},
plugins=[Plugin('mkdocstrings')],
js=[],
assets=[],
packages=[])