isqx.mkdocs
plugin
¤
A MkDocs
plugin bundling a default KaTeX
configuration necessary to
render mathematical expressions in the documentation.
isqx.mkdocs.extension.IsqxExtension
is responsible for injecting
cross-referenced details into the docstrings of
attributes and functions. This module also comes with an optional client-side JS
script detail-highlight.js
that searches for matching symbols within
isqx.details.Detail
blocks and highlights them.
Note
You must install isqx
with the docs
extra optional dependencies
to use this module.
IsqxPluginConfig
¤
Bases: Config
definitions
¤
definitions = Type(list, default=[])
Modules that contain the definitions, e.g. isqx.iso80000
, isqx.aerospace
.
This is used to provide cross-references within the isqx.details.Detail
blocks.
Note that griffe
will dynamically import these modules.
To reduce build time, avoid expensive imports like torch
.
details
¤
details = Type(list, default=[])
Paths to the details mapping, e.g. isqx.details.iso80000.TIME_AND_SPACE
.
IsqxPlugin
¤
Bases: BasePlugin[IsqxPluginConfig]
on_config
¤
on_config(config: MkDocsConfig) -> MkDocsConfig
Source code in src/isqx/mkdocs/plugin.py
59 60 61 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 |
|
on_post_build
¤
on_post_build(*, config: MkDocsConfig) -> None
Source code in src/isqx/mkdocs/plugin.py
93 94 95 96 97 98 |
|
katex_js
¤
Source code in src/isqx/mkdocs/plugin.py
101 102 103 104 105 106 107 108 109 110 |
|
katex_css
¤
Source code in src/isqx/mkdocs/plugin.py
126 127 |
|
maybe_copy_asset
¤
Source code in src/isqx/mkdocs/plugin.py
130 131 132 133 134 135 136 137 |
|
extension
¤
A griffe
extension to dynamically collect isqx
definitions/details.
Details are injected into the docstrings of attributes
and functions in the documentation generated by mkdocstrings-python
.
Note
You must install isqx
with the docs
extra optional dependencies
to use this module.
get_templates_path
¤
get_templates_path() -> Path
See: https://mkdocstrings.github.io/usage/handlers/#handler-extensions
Source code in src/isqx/mkdocs/extension.py
85 86 87 |
|
Unit
¤
Unit: TypeAlias = Union[tuple[StrFragment, ...], None]
The unit of measurement rendered as string fragments.
KaTeXWhere
¤
SymbolDetail
¤
EquationDetail
¤
EquationDetail(
katex: str,
where: tuple[Where, ...] | None = None,
assumptions: tuple[
StrFragment | tuple[StrFragment, ...], ...
]
| None = None,
)
Bases: KaTeXWhere
QtyKindDetail
¤
QtyKindDetail(
parent: str | None = None,
unit_si_coherent: Unit = None,
tags: tuple[str, ...] = tuple(),
wikidata: list[WikidataDetail] = list(),
symbols: list[SymbolDetail] = list(),
equations: list[EquationDetail] = list(),
)
Several quantities can share the same unit. Two cases:
- Explicit inheritance: when a quantity is defined by subscripting
another, like
POTENTIAL_ENERGY = ENERGY["potential"]
: this is a strong signal of a parent-child relationship. we can detect this during the griffe AST walking - Implicit grouping: some quantities are related by their physical dimension but not defined via subscripting (e.g., SPEED and VELOCITY). we can group them by their underlying SI dimension. the hierarchy can be inferred from the tags.
IsqxExtension
¤
IsqxExtension(
config: IsqxPluginConfig,
objects_out_path: str | None = None,
)
Bases: Extension
Source code in src/isqx/mkdocs/extension.py
163 164 165 166 167 168 169 170 171 172 |
|
possible_parent_maps
¤
Note that items in this map are not guaranteed to be isqx objects because griffe works with static analysis.
on_instance
¤
on_instance(
*,
node: ast.AST | ObjectNode,
obj: Object,
agent: Visitor | Inspector,
**kwargs: Any,
) -> None
Source code in src/isqx/mkdocs/extension.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
on_module_instance
¤
on_module_instance(
*,
node: ast.AST | ObjectNode,
mod: Module,
agent: Visitor | Inspector,
**kwargs: Any,
) -> None
Populate definitions from the current module being visited using runtime analysis, if it is matches the path under the configured definitions.
Note that if module a
contains FOO: Annotated[float, isqx.M] = 1.0
and module b
contains from a import FOO
, then self.definitions
will contain both (which points to the same object):
a.FOO
: Definition(value=1.0, annotated_metadata=M)b.FOO
: Definition(value=1.0, annotated_metadata=None)
which is not ideal. When griffe
visits b
, on_alias
will make sure
the definition for b.FOO
is removed.
Source code in src/isqx/mkdocs/extension.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
on_alias
¤
on_alias(
*,
node: ast.AST | ObjectNode,
alias: Alias,
agent: Visitor | Inspector,
**kwargs: Any,
) -> None
Source code in src/isqx/mkdocs/extension.py
230 231 232 233 234 235 236 237 238 239 240 |
|
on_package_loaded
¤
on_package_loaded(
*, pkg: Module, loader: GriffeLoader, **kwargs: Any
) -> None
Source code in src/isqx/mkdocs/extension.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 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 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
to_dict
¤
Source code in src/isqx/mkdocs/extension.py
337 338 |
|
Definition
¤
Bases: NamedTuple
MkdocsFormatter
¤
MkdocsFormatter(reverse_definitions: _ReverseDefinitions)
Bases: BasicFormatter
Source code in src/isqx/mkdocs/extension.py
362 363 364 365 366 367 |
|
visit_named
¤
visit_named(
expr: NamedExpr, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/mkdocs/extension.py
369 370 371 372 373 374 375 376 377 378 379 |
|
fmt
¤
fmt(expr: Expr) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
visit_exp
¤
visit_exp(
expr: Exp, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
299 300 301 302 303 304 |
|
visit_mul
¤
visit_mul(
expr: Mul, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
306 307 308 309 310 311 312 313 314 |
|
visit_scaled
¤
visit_scaled(
expr: Scaled, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
316 317 318 319 320 321 322 323 324 325 |
|
visit_tagged
¤
visit_tagged(
expr: Tagged, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
visit_translated
¤
visit_translated(
expr: Translated, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
327 328 329 330 |
|
visit_log
¤
visit_log(
expr: Log, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
332 333 334 335 336 337 338 339 340 341 342 343 |
|
visit
¤
visit(
expr: Expr, state: _BasicFormatterState
) -> Generator[StrFragment, None, None]
Source code in src/isqx/_fmt.py
223 224 225 226 227 228 229 230 231 232 |
|
parse_katex_where_static
¤
parse_katex_where_static(
katex_where_rt: HasKaTeXWhere,
katex_where_st: str | Expr,
) -> tuple[str, ExprDict | None]
Source code in src/isqx/mkdocs/extension.py
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 |
|
parse_where
¤
parse_where(
key_rt: DetailKey | Callable[..., DetailKey],
detail_rt: HasKaTeXWhere,
where_st: ExprDict,
*,
self_path: str,
reverse_definitions: _ReverseDefinitions,
formatter: MkdocsFormatter,
mut_self_symbols: list[str],
) -> Generator[Where, None, None]
Source code in src/isqx/mkdocs/extension.py
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 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
screaming_to_normal
¤
Source code in src/isqx/mkdocs/extension.py
656 657 658 659 |
|
inject_citation_into_docstring
¤
Source code in src/isqx/mkdocs/extension.py
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
|