mkdocs_manpage
¤
MkDocs Manpage package.
MkDocs plugin to generate a manpage from the documentation site.
Classes:
-
MkdocsManpagePlugin–The MkDocs plugin to generate manpages.
-
PageConfig–Sub-config for each manual page.
-
PluginConfig–Configuration options for the plugin.
-
PluginLogger–A logger adapter to prefix messages with the originating package name.
Functions:
-
get_logger–Return a logger for plugins.
-
preprocess–Pre-process HTML with user-defined functions.
MkdocsManpagePlugin
¤
MkdocsManpagePlugin()
Bases: BasePlugin[PluginConfig]
The MkDocs plugin to generate manpages.
This plugin defines the following event hooks:
on_page_contenton_post_build
Check the Developing Plugins page of mkdocs
for more information about its plugin system.
Methods:
-
on_config–Save the global MkDocs configuration.
-
on_files–Expand inputs for manual pages.
-
on_page_content–Record pages contents.
-
on_post_build–Combine all recorded pages contents and convert it to a manual page with Pandoc.
Source code in src/mkdocs_manpage/_internal/plugin.py
83 84 | |
on_config
¤
on_config(config: MkDocsConfig) -> MkDocsConfig | None
Save the global MkDocs configuration.
Hook for the on_config event.
In this hook, we save the global MkDocs configuration into an instance variable,
to re-use it later.
Parameters:
-
(config¤MkDocsConfig) –The MkDocs config object.
Returns:
-
MkDocsConfig | None–The same, untouched config.
Source code in src/mkdocs_manpage/_internal/plugin.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
on_files
¤
Expand inputs for manual pages.
Hook for the on_files event.
In this hook we expand inputs for each manual pages (glob patterns using *).
Parameters:
-
(files¤Files) –The collection of MkDocs files.
-
(config¤MkDocsConfig) –The MkDocs configuration.
Returns:
-
Files | None–Modified collection or none.
Source code in src/mkdocs_manpage/_internal/plugin.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
on_page_content
¤
Record pages contents.
Hook for the on_page_content event.
In this hook we simply record the HTML of the pages into a dictionary whose keys are the pages' URIs.
Parameters:
Source code in src/mkdocs_manpage/_internal/plugin.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
on_post_build
¤
Combine all recorded pages contents and convert it to a manual page with Pandoc.
Hook for the on_post_build event.
In this hook we concatenate all previously recorded HTML, and convert it to a manual page with Pandoc.
Parameters:
-
(config¤MkDocsConfig) –MkDocs configuration.
Source code in src/mkdocs_manpage/_internal/plugin.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
PageConfig
¤
Bases: Config
Sub-config for each manual page.
Attributes:
-
header–Header to show in the manual page; defaults to the standard section header.
-
inputs–Source page URIs to include, with optional
*patterns. -
output–Path of the generated manual page, relative to the MkDocs config file.
-
title–Title to show in the manual page; defaults to the site name.
header
class-attribute
instance-attribute
¤
header = mkconf.Optional(mkconf.Type(str))
Header to show in the manual page; defaults to the standard section header.
inputs
class-attribute
instance-attribute
¤
inputs = mkconf.ListOfItems(mkconf.Type(str))
Source page URIs to include, with optional * patterns.
output
class-attribute
instance-attribute
¤
output = mkconf.File(exists=False)
Path of the generated manual page, relative to the MkDocs config file.
PluginConfig
¤
Bases: Config
Configuration options for the plugin.
Attributes:
-
enabled–Whether to generate manual pages.
-
pages–Configuration for the manual pages to generate.
-
preprocess–Path to a Python file that preprocesses each manual page's HTML.
enabled
class-attribute
instance-attribute
¤
enabled = mkconf.Type(bool, default=True)
Whether to generate manual pages.
pages
class-attribute
instance-attribute
¤
pages = mkconf.ListOfItems(mkconf.SubConfig(PageConfig))
Configuration for the manual pages to generate.
preprocess
class-attribute
instance-attribute
¤
preprocess = mkconf.Optional(mkconf.File(exists=True))
Path to a Python file that preprocesses each manual page's HTML.
PluginLogger
¤
Bases: LoggerAdapter
A logger adapter to prefix messages with the originating package name.
Parameters:
-
(prefix¤str) –The string to insert in front of every message.
-
(logger¤Logger) –The logger instance.
Methods:
-
process–Process the message.
Source code in src/mkdocs_manpage/_internal/logger.py
31 32 33 34 35 36 37 38 39 | |
process
¤
Process the message.
Parameters:
Returns:
Source code in src/mkdocs_manpage/_internal/logger.py
41 42 43 44 45 46 47 48 49 50 51 | |
get_logger
¤
get_logger(name: str) -> PluginLogger
Return a logger for plugins.
Parameters:
Returns:
-
PluginLogger–A logger configured to work well in MkDocs, prefixing each message with the plugin package name.
Source code in src/mkdocs_manpage/_internal/logger.py
54 55 56 57 58 59 60 61 62 63 64 65 | |
preprocess
¤
Pre-process HTML with user-defined functions.
Parameters:
-
(html¤str) –The HTML to process before conversion to a manpage.
-
(module_path¤str) –The path of a Python module containing a
preprocessfunction. The function must accept one and only one argument calledsoup. Thesoupargument is an instance ofbs4.BeautifulSoup. -
(output¤str) –The output path of the relevant manual page.
Returns:
-
str–The processed HTML.
Source code in src/mkdocs_manpage/_internal/preprocess.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |