shell ¤
Shell handler for mkdocstrings.
Modules:
-
config–Deprecated. Import from
mkdocstrings_handlers.shelldirectly. -
handler–Deprecated. Import from
mkdocstrings_handlers.shelldirectly.
Classes:
-
ShellConfig–Shell handler configuration.
-
ShellHandler–The Shell handler class.
-
ShellInputConfig–Shell handler configuration.
-
ShellInputOptions–Accepted input options.
-
ShellOptions–Final options passed as template context.
Functions:
-
get_handler–Simply return an instance of
ShellHandler.
ShellConfig dataclass ¤
Bases: ShellInputConfig
Shell handler configuration.
Methods:
Attributes:
options class-attribute instance-attribute ¤
Global options in mkdocs.yml.
coerce classmethod ¤
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
173 174 175 176 | |
from_data classmethod ¤
Create an instance from a dictionary.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
159 160 161 162 | |
ShellHandler ¤
ShellHandler(
config: ShellConfig, base_dir: Path, **kwargs: Any
)
Bases: BaseHandler
The Shell handler class.
Methods:
-
collect–Collect data from a shell script/library.
-
do_convert_markdown–Render Markdown text; for use inside templates.
-
do_heading–Render an HTML heading and register it for the table of contents. For use inside templates.
-
get_aliases–Return the possible aliases for a given identifier.
-
get_extended_templates_dirs–Load template extensions for the given handler, return their templates directories.
-
get_headings–Return and clear the headings gathered so far.
-
get_inventory_urls–Return the URLs (and configuration options) of the inventory files to download.
-
get_options–Get the combined (global and local) options.
-
get_templates_dir–Return the path to the handler's templates directory.
-
load_inventory–Yield items and their URLs from an inventory file streamed from
in_file. -
render–Render the collected data.
-
render_backlinks–Render backlinks.
-
teardown–Teardown the handler.
-
update_env–Update the Jinja environment.
Attributes:
-
base_dir–The base directory for the handler.
-
config–The handler configuration.
-
custom_templates–The path to custom templates.
-
domain(str) –The cross-documentation domain/language for this handler.
-
enable_inventory(bool) –Whether this handler is interested in enabling the creation of the
objects.invSphinx inventory file. -
env–The Jinja environment.
-
extra_css(str) –Extra CSS.
-
fallback_theme(str) –The theme to fallback to.
-
global_options–The global options for the handler.
-
md(Markdown) –The Markdown instance.
-
mdx–The Markdown extensions to use.
-
mdx_config–The configuration for the Markdown extensions.
-
name(str) –The handler's name.
-
outer_layer(bool) –Whether we're in the outer Markdown conversion layer.
-
theme–The selected theme.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
39 40 41 42 43 44 45 46 | |
custom_templates instance-attribute ¤
custom_templates = custom_templates
The path to custom templates.
domain class-attribute ¤
domain: str = 'shell'
The cross-documentation domain/language for this handler.
enable_inventory class-attribute ¤
enable_inventory: bool = False
Whether this handler is interested in enabling the creation of the objects.inv Sphinx inventory file.
env instance-attribute ¤
env = Environment(
autoescape=True,
loader=FileSystemLoader(paths),
auto_reload=False,
)
The Jinja environment.
global_options instance-attribute ¤
global_options = config.options
The global options for the handler.
md property ¤
md: Markdown
mdx_config instance-attribute ¤
mdx_config = mdx_config
The configuration for the Markdown extensions.
collect ¤
collect(
identifier: str, options: ShellOptions
) -> CollectorItem
Collect data from a shell script/library.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
57 58 59 60 61 62 63 | |
do_convert_markdown ¤
do_convert_markdown(
text: str,
heading_level: int,
html_id: str = "",
*,
strip_paragraph: bool = False,
autoref_hook: AutorefsHookInterface | None = None,
) -> Markup
Render Markdown text; for use inside templates.
Parameters:
-
text(str) –The text to convert.
-
heading_level(int) –The base heading level to start all Markdown headings from.
-
html_id(str, default:'') –The HTML id of the element that's considered the parent of this element.
-
strip_paragraph(bool, default:False) –Whether to exclude the
<p>tag from around the whole output.
Returns:
-
Markup–An HTML string.
Source code in mkdocstrings/_internal/handlers/base.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
do_heading ¤
do_heading(
content: Markup,
heading_level: int,
*,
role: str | None = None,
hidden: bool = False,
toc_label: str | None = None,
skip_inventory: bool = False,
**attributes: str,
) -> Markup
Render an HTML heading and register it for the table of contents. For use inside templates.
Parameters:
-
content(Markup) –The HTML within the heading.
-
heading_level(int) –The level of heading (e.g. 3 ->
h3). -
role(str | None, default:None) –An optional role for the object bound to this heading.
-
hidden(bool, default:False) –If True, only register it for the table of contents, don't render anything.
-
toc_label(str | None, default:None) –The title to use in the table of contents ('data-toc-label' attribute).
-
skip_inventory(bool, default:False) –Flag element to not be registered in the inventory (by setting a
data-skip-inventoryattribute). -
**attributes(str, default:{}) –Any extra HTML attributes of the heading.
Returns:
-
Markup–An HTML string.
Source code in mkdocstrings/_internal/handlers/base.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
get_aliases ¤
Return the possible aliases for a given identifier.
Parameters:
-
identifier(str) –The identifier to get the aliases of.
Returns:
Source code in mkdocstrings/_internal/handlers/base.py
323 324 325 326 327 328 329 330 331 332 | |
get_extended_templates_dirs ¤
Load template extensions for the given handler, return their templates directories.
Parameters:
-
handler(str) –The name of the handler to get the extended templates directory of.
Returns:
Source code in mkdocstrings/_internal/handlers/base.py
311 312 313 314 315 316 317 318 319 320 321 | |
get_headings ¤
Return and clear the headings gathered so far.
Returns:
Source code in mkdocstrings/_internal/handlers/base.py
454 455 456 457 458 459 460 461 462 | |
get_inventory_urls ¤
Return the URLs (and configuration options) of the inventory files to download.
Source code in mkdocstrings/_internal/handlers/base.py
194 195 196 | |
get_options ¤
get_options(
local_options: Mapping[str, Any],
) -> HandlerOptions
Get the combined (global and local) options.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
48 49 50 51 52 53 54 55 | |
get_templates_dir ¤
Return the path to the handler's templates directory.
Override to customize how the templates directory is found.
Parameters:
-
handler(str | None, default:None) –The name of the handler to get the templates directory of.
Raises:
-
ModuleNotFoundError–When no such handler is installed.
-
FileNotFoundError–When the templates directory cannot be found.
Returns:
-
Path–The templates directory path.
Source code in mkdocstrings/_internal/handlers/base.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
load_inventory classmethod ¤
load_inventory(
in_file: BinaryIO,
url: str,
base_url: str | None = None,
**kwargs: Any,
) -> Iterator[tuple[str, str]]
Yield items and their URLs from an inventory file streamed from in_file.
Parameters:
-
in_file(BinaryIO) –The binary file-like object to read the inventory from.
-
url(str) –The URL that this file is being streamed from (used to guess
base_url). -
base_url(str | None, default:None) –The URL that this inventory's sub-paths are relative to.
-
**kwargs(Any, default:{}) –Ignore additional arguments passed from the config.
Yields:
Source code in mkdocstrings/_internal/handlers/base.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
render ¤
render(
data: CollectorItem,
options: ShellOptions,
*,
locale: str | None = None,
) -> str
Render the collected data.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
65 66 67 68 69 70 71 72 73 74 | |
render_backlinks ¤
render_backlinks(
backlinks: Mapping[str, Iterable[Backlink]],
*,
locale: str | None = None,
) -> str
Render backlinks.
Parameters:
-
backlinks(Mapping[str, Iterable[Backlink]]) –A mapping of identifiers to backlinks.
-
locale(str | None, default:None) –The locale to use for translations, if any.
Returns:
-
str–The rendered backlinks as HTML.
Source code in mkdocstrings/_internal/handlers/base.py
264 265 266 267 268 269 270 271 272 273 274 | |
teardown ¤
teardown() -> None
Teardown the handler.
This method should be implemented to, for example, terminate a subprocess that was started when creating the handler instance.
Source code in mkdocstrings/_internal/handlers/base.py
276 277 278 279 280 281 | |
update_env ¤
update_env(config: MkDocsConfig) -> None
Update the Jinja environment.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
76 77 78 79 80 81 | |
ShellInputConfig dataclass ¤
ShellInputConfig(
*,
options: Annotated[
ShellInputOptions,
_Field(
description="Configuration options for collecting and rendering objects."
),
] = ShellInputOptions(),
)
Shell handler configuration.
Methods:
Attributes:
-
options(Annotated[ShellInputOptions, _Field(description='Configuration options for collecting and rendering objects.')]) –Configuration options for collecting and rendering objects.
options class-attribute instance-attribute ¤
options: Annotated[
ShellInputOptions,
_Field(
description="Configuration options for collecting and rendering objects."
),
] = field(default_factory=ShellInputOptions)
Configuration options for collecting and rendering objects.
coerce classmethod ¤
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
154 155 156 157 | |
from_data classmethod ¤
Create an instance from a dictionary.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
159 160 161 162 | |
ShellInputOptions dataclass ¤
ShellInputOptions(
*,
extra: Annotated[
dict[str, Any],
_Field(
group="general", description="Extra options."
),
] = dict(),
heading: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated heading of the root object.",
),
] = "",
heading_level: Annotated[
int,
_Field(
group="headings",
description="The initial heading level to use.",
),
] = 2,
show_symbol_type_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in headings (e.g. mod, class, meth, func and attr).",
),
] = False,
show_symbol_type_toc: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).",
),
] = False,
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = "",
)
Accepted input options.
Methods:
Attributes:
-
extra(Annotated[dict[str, Any], _Field(group='general', description='Extra options.')]) –Extra options.
-
heading(Annotated[str, _Field(group='headings', description='A custom string to override the autogenerated heading of the root object.')]) –A custom string to override the autogenerated heading of the root object.
-
heading_level(Annotated[int, _Field(group='headings', description='The initial heading level to use.')]) –The initial heading level to use.
-
show_symbol_type_heading(Annotated[bool, _Field(group='headings', description='Show the symbol type in headings (e.g. mod, class, meth, func and attr).')]) –Show the symbol type in headings (e.g. mod, class, meth, func and attr).
-
show_symbol_type_toc(Annotated[bool, _Field(group='headings', description='Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).')]) –Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).
-
toc_label(Annotated[str, _Field(group='headings', description='A custom string to override the autogenerated toc label of the root object.')]) –A custom string to override the autogenerated toc label of the root object.
extra class-attribute instance-attribute ¤
extra: Annotated[
dict[str, Any],
_Field(group="general", description="Extra options."),
] = field(default_factory=dict)
Extra options.
heading class-attribute instance-attribute ¤
heading: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated heading of the root object.",
),
] = ""
A custom string to override the autogenerated heading of the root object.
heading_level class-attribute instance-attribute ¤
heading_level: Annotated[
int,
_Field(
group="headings",
description="The initial heading level to use.",
),
] = 2
The initial heading level to use.
show_symbol_type_heading class-attribute instance-attribute ¤
show_symbol_type_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in headings (e.g. mod, class, meth, func and attr).",
),
] = False
Show the symbol type in headings (e.g. mod, class, meth, func and attr).
show_symbol_type_toc class-attribute instance-attribute ¤
show_symbol_type_toc: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).",
),
] = False
Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).
toc_label class-attribute instance-attribute ¤
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = ""
A custom string to override the autogenerated toc label of the root object.
coerce classmethod ¤
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
119 120 121 122 | |
from_data classmethod ¤
Create an instance from a dictionary.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
124 125 126 127 | |
ShellOptions dataclass ¤
ShellOptions(
*,
extra: Annotated[
dict[str, Any],
_Field(
group="general", description="Extra options."
),
] = dict(),
heading: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated heading of the root object.",
),
] = "",
heading_level: Annotated[
int,
_Field(
group="headings",
description="The initial heading level to use.",
),
] = 2,
show_symbol_type_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in headings (e.g. mod, class, meth, func and attr).",
),
] = False,
show_symbol_type_toc: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).",
),
] = False,
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = "",
)
Bases: ShellInputOptions
Final options passed as template context.
Methods:
Attributes:
-
extra(Annotated[dict[str, Any], _Field(group='general', description='Extra options.')]) –Extra options.
-
heading(Annotated[str, _Field(group='headings', description='A custom string to override the autogenerated heading of the root object.')]) –A custom string to override the autogenerated heading of the root object.
-
heading_level(Annotated[int, _Field(group='headings', description='The initial heading level to use.')]) –The initial heading level to use.
-
show_symbol_type_heading(Annotated[bool, _Field(group='headings', description='Show the symbol type in headings (e.g. mod, class, meth, func and attr).')]) –Show the symbol type in headings (e.g. mod, class, meth, func and attr).
-
show_symbol_type_toc(Annotated[bool, _Field(group='headings', description='Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).')]) –Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).
-
toc_label(Annotated[str, _Field(group='headings', description='A custom string to override the autogenerated toc label of the root object.')]) –A custom string to override the autogenerated toc label of the root object.
extra class-attribute instance-attribute ¤
extra: Annotated[
dict[str, Any],
_Field(group="general", description="Extra options."),
] = field(default_factory=dict)
Extra options.
heading class-attribute instance-attribute ¤
heading: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated heading of the root object.",
),
] = ""
A custom string to override the autogenerated heading of the root object.
heading_level class-attribute instance-attribute ¤
heading_level: Annotated[
int,
_Field(
group="headings",
description="The initial heading level to use.",
),
] = 2
The initial heading level to use.
show_symbol_type_heading class-attribute instance-attribute ¤
show_symbol_type_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in headings (e.g. mod, class, meth, func and attr).",
),
] = False
Show the symbol type in headings (e.g. mod, class, meth, func and attr).
show_symbol_type_toc class-attribute instance-attribute ¤
show_symbol_type_toc: Annotated[
bool,
_Field(
group="headings",
description="Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).",
),
] = False
Show the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr).
toc_label class-attribute instance-attribute ¤
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = ""
A custom string to override the autogenerated toc label of the root object.
coerce classmethod ¤
coerce(**data: Any) -> MutableMapping[str, Any]
Create an instance from a dictionary.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
136 137 138 139 140 | |
from_data classmethod ¤
Create an instance from a dictionary.
Source code in src/mkdocstrings_handlers/shell/_internal/config.py
124 125 126 127 | |
get_handler ¤
get_handler(
*,
handler_config: MutableMapping[str, Any],
tool_config: MkDocsConfig,
**kwargs: Any,
) -> ShellHandler
Simply return an instance of ShellHandler.
Parameters:
-
handler_config(MutableMapping[str, Any]) –The handler configuration.
-
tool_config(MkDocsConfig) –The tool (SSG) configuration.
-
**kwargs(Any, default:{}) –Keyword arguments for the base handler constructor.
Returns:
-
ShellHandler–An instance of the handler.
Source code in src/mkdocstrings_handlers/shell/_internal/handler.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |