twincat
¶
Twincat handler for mkdocstrings.
Classes:
-
TwincatConfig
–Twincat handler configuration.
-
TwincatHandler
–The Twincat handler class.
-
TwincatInputConfig
–Twincat handler configuration.
-
TwincatInputOptions
–Accepted input options.
-
TwincatOptions
–Final options passed as template context.
Functions:
-
get_handler
–Simply return an instance of
TwincatHandler
.
TwincatConfig
dataclass
¶
TwincatConfig(
paths: Annotated[
list[str],
_Field(
description="The paths to the twincat files."
),
] = lambda: ["."](),
default_strategy: Annotated[
str | None,
_Field(description="Strategy to parse the files"),
] = None,
options: Annotated[
dict[str, Any],
_Field(
description="Configuration options for collecting and rendering objects."
),
] = dict(),
)
Bases: TwincatInputConfig
Twincat handler configuration.
Methods:
coerce
classmethod
¶
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
446 447 448 449 |
|
from_data
classmethod
¶
from_data(**data: Any) -> Self
Create an instance from a dictionary.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
427 428 429 430 |
|
TwincatHandler
¶
TwincatHandler(
config: TwincatConfig, base_dir: Path, **kwargs: Any
)
Bases: BaseHandler
The Twincat handler class.
Parameters:
-
config
(TwincatConfig
) –The handler configuration.
-
base_dir
(Path
) –The base directory of the project.
-
**kwargs
(Any
, default:{}
) –Arguments passed to the parent constructor.
Methods:
-
collect
–Collect data given an identifier and selection configuration.
-
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
–Get 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 combined default, 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 a template using provided data and configuration options.
-
render_backlinks
–Render backlinks.
-
teardown
–Teardown the handler.
-
update_env
–Update the Jinja environment with any custom settings/filters/options for this handler.
Attributes:
-
base_dir
–The base directory of the project.
-
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.inv
Sphinx inventory file. -
env
–The Jinja environment.
-
extra_css
(str
) –Extra CSS.
-
fallback_config
(dict
) –Fallback configuration when searching anchors for identifiers.
-
fallback_theme
(str
) –The theme to fallback to.
-
global_options
–The global configuration options.
-
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\twincat\_internal\handler.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
custom_templates
instance-attribute
¶
custom_templates = custom_templates
The path to custom templates.
domain
class-attribute
¶
domain: str = 'twincat'
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.
fallback_config
class-attribute
¶
fallback_config: dict = {}
Fallback configuration when searching anchors for identifiers.
md
property
¶
md: Markdown
mdx_config
instance-attribute
¶
mdx_config = mdx_config
The configuration for the Markdown extensions.
collect
¶
collect(
identifier: str, options: TwincatOptions
) -> CollectorItem
Collect data given an identifier and selection configuration.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
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 .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
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 |
|
do_heading
¶
do_heading(
content: Markup,
heading_level: int,
*,
role: str | None = None,
hidden: bool = False,
toc_label: str | None = None,
**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).
-
**attributes
(str
, default:{}
) –Any extra HTML attributes of the heading.
Returns:
-
Markup
–An HTML string.
Source code in .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
get_aliases
¶
Get aliases for a given identifier.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
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 .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
373 374 375 376 377 378 379 380 381 382 383 |
|
get_headings
¶
Return and clear the headings gathered so far.
Returns:
Source code in .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
512 513 514 515 516 517 518 519 520 |
|
get_inventory_urls
¶
Return the URLs (and configuration options) of the inventory files to download.
Source code in .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
265 266 267 |
|
get_options
¶
get_options(
local_options: Mapping[str, Any],
) -> HandlerOptions
Get combined default, global and local options.
Parameters:
Returns:
-
HandlerOptions
–The combined options.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
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 .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
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 |
|
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 .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
render
¶
render(data: CollectorItem, options: TwincatOptions) -> str
Render a template using provided data and configuration options.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
render_backlinks
¶
Render backlinks.
Source code in .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
334 335 336 |
|
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 .venv\Lib\site-packages\mkdocstrings\_internal\handlers\base.py
338 339 340 341 342 343 |
|
update_env
¶
update_env(config: dict) -> None
Update the Jinja environment with any custom settings/filters/options for this handler.
Parameters:
-
config
(dict
) –MkDocs configuration, read from
mkdocs.yml
.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
201 202 203 204 205 206 207 208 209 |
|
TwincatInputConfig
dataclass
¶
TwincatInputConfig(
paths: Annotated[
list[str],
_Field(
description="The paths to the twincat files."
),
] = lambda: ["."](),
default_strategy: Annotated[
str | None,
_Field(description="Strategy to parse the files"),
] = None,
options: Annotated[
TwincatInputOptions,
_Field(
description="Configuration options for collecting and rendering objects."
),
] = TwincatInputOptions(),
)
Twincat handler configuration.
Methods:
coerce
classmethod
¶
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
422 423 424 425 |
|
from_data
classmethod
¶
from_data(**data: Any) -> Self
Create an instance from a dictionary.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
427 428 429 430 |
|
TwincatInputOptions
dataclass
¶
TwincatInputOptions(
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,
show_root_members_full_path: Annotated[
bool,
_Field(
group="headings",
description="Show the full twincat path of the root members.",
),
] = False,
show_object_full_path: Annotated[
bool,
_Field(
group="docstrings",
description="Show the full twincat path of every object.",
),
] = False,
show_root_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the heading of the object at the root of the documentation tree.\n\n The root object is the object referenced by the identifier after `:::`.\n ",
),
] = False,
show_source: Annotated[
bool,
_Field(
group="general",
description="Show the source code of this object.",
),
] = True,
show_implements: Annotated[
bool,
_Field(
group="general",
description="if the pou implements something.",
),
] = True,
show_extends: Annotated[
bool,
_Field(
group="general",
description="show if the pou extends something",
),
] = True,
show_access_modifier: Annotated[
bool,
_Field(
group="general",
description="show the access modifier of the method",
),
] = True,
show_return: Annotated[
bool,
_Field(
group="general",
description="show the return of the method",
),
] = True,
show_root_toc_entry: Annotated[
bool,
_Field(
group="headings",
description="If the root heading is not shown, at least add a ToC entry for it.",
),
] = True,
show_labels: Annotated[
bool,
_Field(
group="docu",
description="Whether to show labels of the members.",
),
] = True,
variable_headings: Annotated[
bool,
_Field(
group="headings",
description="Whether to render headings for variables (therefore showing variables in the ToC).",
),
] = False,
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = "",
summary: Annotated[
bool | SummaryOption,
_Field(
group="members",
description="Whether to render summaries of tcplc proj, pous, duts, itfs, methods.",
),
] = SummaryOption(),
show_category_heading: Annotated[
bool,
_Field(
group="headings",
description="When grouped by categories, show a heading for each category.",
),
] = False,
variable_section_style: Annotated[
Literal["table", "list"],
_Field(
group="variable",
description="The style used to render variable sections.",
),
] = "table",
summary_section_style: Annotated[
Literal["table", "list"],
_Field(
group="variable",
description="The style used to render summarys.",
),
] = "table",
)
Accepted input options.
Methods:
coerce
classmethod
¶
coerce(**data: Any) -> MutableMapping[str, Any]
Coerce data.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
from_data
classmethod
¶
from_data(**data: Any) -> Self
Create an instance from a dictionary.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
378 379 380 381 |
|
TwincatOptions
dataclass
¶
TwincatOptions(
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,
show_root_members_full_path: Annotated[
bool,
_Field(
group="headings",
description="Show the full twincat path of the root members.",
),
] = False,
show_object_full_path: Annotated[
bool,
_Field(
group="docstrings",
description="Show the full twincat path of every object.",
),
] = False,
show_root_heading: Annotated[
bool,
_Field(
group="headings",
description="Show the heading of the object at the root of the documentation tree.\n\n The root object is the object referenced by the identifier after `:::`.\n ",
),
] = False,
show_source: Annotated[
bool,
_Field(
group="general",
description="Show the source code of this object.",
),
] = True,
show_implements: Annotated[
bool,
_Field(
group="general",
description="if the pou implements something.",
),
] = True,
show_extends: Annotated[
bool,
_Field(
group="general",
description="show if the pou extends something",
),
] = True,
show_access_modifier: Annotated[
bool,
_Field(
group="general",
description="show the access modifier of the method",
),
] = True,
show_return: Annotated[
bool,
_Field(
group="general",
description="show the return of the method",
),
] = True,
show_root_toc_entry: Annotated[
bool,
_Field(
group="headings",
description="If the root heading is not shown, at least add a ToC entry for it.",
),
] = True,
show_labels: Annotated[
bool,
_Field(
group="docu",
description="Whether to show labels of the members.",
),
] = True,
variable_headings: Annotated[
bool,
_Field(
group="headings",
description="Whether to render headings for variables (therefore showing variables in the ToC).",
),
] = False,
toc_label: Annotated[
str,
_Field(
group="headings",
description="A custom string to override the autogenerated toc label of the root object.",
),
] = "",
summary: SummaryOption = SummaryOption(),
show_category_heading: Annotated[
bool,
_Field(
group="headings",
description="When grouped by categories, show a heading for each category.",
),
] = False,
variable_section_style: Annotated[
Literal["table", "list"],
_Field(
group="variable",
description="The style used to render variable sections.",
),
] = "table",
summary_section_style: Annotated[
Literal["table", "list"],
_Field(
group="variable",
description="The style used to render summarys.",
),
] = "table",
)
Bases: TwincatInputOptions
Final options passed as template context.
Methods:
Attributes:
-
summary
(SummaryOption
) –Whether to render summaries of modules, classes, functions (methods) and attributes.
summary
class-attribute
instance-attribute
¶
summary: SummaryOption = field(
default_factory=SummaryOption
)
Whether to render summaries of modules, classes, functions (methods) and attributes.
coerce
classmethod
¶
coerce(**data: Any) -> MutableMapping[str, Any]
Create an instance from a dictionary.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
393 394 395 396 397 |
|
from_data
classmethod
¶
from_data(**data: Any) -> Self
Create an instance from a dictionary.
Source code in src\mkdocstrings_handlers\twincat\_internal\config.py
378 379 380 381 |
|
get_handler
¶
get_handler(
handler_config: MutableMapping[str, Any],
tool_config: MkDocsConfig,
**kwargs: Any,
) -> TwincatHandler
Simply return an instance of TwincatHandler
.
Parameters:
-
handler_config
(MutableMapping[str, Any]
) –The handler configuration.
-
tool_config
(MkDocsConfig
) –The tool (SSG) configuration.
Returns:
-
TwincatHandler
–An instance of
TwincatHandler
.
Source code in src\mkdocstrings_handlers\twincat\_internal\handler.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|