isqx.mkdocs¤
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.
IsqxExtensionConfig
¤
get_templates_path
¤
get_templates_path() -> Path
See: https://mkdocstrings.github.io/usage/handlers/#handler-extensions
Source code in src/isqx/mkdocs/extension.py
98 99 100 | |
Where
¤
Where(
symbol: str,
description: StrFragment | tuple[StrFragment, ...],
unit: UnitExprJson | None,
)
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: UnitExprJson | None = 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
¤
Bases: Extension
Source code in src/isqx/mkdocs/extension.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
config
¤
config = (
IsqxExtensionConfig(
definitions=tuple(config.get("definitions", ())),
details=tuple(config.get("details", ())),
)
if config is not None
else IsqxExtensionConfig()
)
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
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
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 list.
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
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
on_alias_instance
¤
on_alias_instance(
*,
node: ast.AST | ObjectNode,
alias: Alias,
agent: Visitor | Inspector,
**kwargs: Any,
) -> None
Source code in src/isqx/mkdocs/extension.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
on_package
¤
on_package(
*, pkg: Module, loader: GriffeLoader, **kwargs: Any
) -> None
Source code in src/isqx/mkdocs/extension.py
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 335 336 337 338 339 340 341 342 | |
write_objects
¤
Source code in src/isqx/mkdocs/extension.py
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 382 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 | |
write_objects_from_config
¤
Write objects.json explicitly after a Zensical docs build.
objects.json used to be emitted as a side effect of the Griffe walk
performed inside the mkdocstrings rendering path. That was fragile under
Zensical: each build starts by deleting the whole site directory, while warm
cached builds may skip the expensive markdown and API extraction stages.
The build still succeeds, but custom generated artifacts from those skipped
stages disappear from the final site.
Zensical currently regenerates a small fixed set of built in artifacts such
as objects.inv, but it does not expose a supported hook for repository
owned custom non-page artifacts like this file. Therefore just docs-build
must call this helper explicitly after zensical build so both cold and
warm builds deterministically recreate site/assets/objects.json.
Source code in src/isqx/mkdocs/extension.py
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 453 454 455 456 457 458 459 | |
to_dict
¤
Source code in src/isqx/mkdocs/extension.py
515 516 | |
Definition
¤
Bases: NamedTuple
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
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 | |
parse_where
¤
parse_where(
key_rt: DetailKey | Callable[..., DetailKey],
detail_rt: HasKaTeXWhere,
where_st: ExprDict,
*,
self_path: str,
definitions: Definitions,
path_resolver: _PathResolver,
unit_decls: UnitRegistry,
mut_self_symbols: list[str],
) -> Generator[Where, None, None]
Source code in src/isqx/mkdocs/extension.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 | |
screaming_to_normal
¤
Source code in src/isqx/mkdocs/extension.py
1077 1078 1079 1080 | |
inject_citation_into_docstring
¤
Source code in src/isqx/mkdocs/extension.py
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | |