You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/guides/docs.md
+9-22Lines changed: 9 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -274,7 +274,6 @@ docs = [
274
274
"pyyaml>=6.0.1",
275
275
"mdx-include>=1.4.2",
276
276
"mkdocstrings-python>=1.18.2",
277
-
"mkdocs-gallery>=0.10.4",
278
277
]
279
278
```
280
279
@@ -321,7 +320,7 @@ plugins:
321
320
handlers:
322
321
python:
323
322
paths: [.]
324
-
import:
323
+
inventories:
325
324
- https://docs.python.org/3/objects.inv
326
325
- https://docs.pydantic.dev/latest/objects.inv
327
326
options:
@@ -331,18 +330,12 @@ plugins:
331
330
show_root_heading: true
332
331
show_if_no_docstring: true
333
332
show_signature_annotations: true
334
-
gallery:
335
-
examples_dirs: docs/examples # path to your example scripts
336
-
gallery_dirs: docs/generated/gallery # where to save generated gallery
337
-
image_srcset: ['2x']
338
-
within_subsection_order: FileNameSortKey
339
333
search: {}
340
334
341
335
342
336
nav:
343
337
- Home: index.md
344
338
- Python API: api.md
345
-
- Examples: generated/gallery
346
339
```
347
340
348
341
First, the basic site metadata contains authors, repository details, URLs, etc:
@@ -394,7 +387,7 @@ Onto the best part of MkDocs: it's many plugins!
394
387
* `search` enabled search functionality.
395
388
* [`autorefs`](https://mkdocstrings.github.io/autorefs/) allows easier linking across pages and anchors.
396
389
* [`mkdocstrings`](https://mkdocstrings.github.io/) lets you generate reference API documentation from your docstring.
397
-
* [`gallery`](https://smarie.github.io/mkdocs-gallery/) turns an `example` directory inside your `docs` folder into accessible documentation, capturing output (such as print statements or generated `matplotlib` figures).
390
+
398
391
399
392
```yaml
400
393
plugins:
@@ -403,7 +396,7 @@ plugins:
403
396
handlers:
404
397
python:
405
398
paths: [.]
406
-
import:
399
+
inventories:
407
400
- https://docs.python.org/3/objects.inv
408
401
- https://docs.pydantic.dev/latest/objects.inv
409
402
options:
@@ -413,21 +406,15 @@ plugins:
413
406
show_root_heading: true
414
407
show_if_no_docstring: true
415
408
show_signature_annotations: true
416
-
gallery:
417
-
examples_dirs: docs/examples # path to your example scripts
418
-
gallery_dirs: docs/generated/gallery # where to save generated gallery
419
-
image_srcset: ['2x']
420
-
within_subsection_order: FileNameSortKey
421
409
search: {}
422
410
```
423
411
424
-
Finally, we have to define the actual structure of our site by providing the primary navigation sidebar layout. Here we have three top-level links, one for the home page, one where all the generated API documentation from `mkdocstrings` will live, and a final entry for any examples showing how to use the package.
412
+
Finally, we have to define the actual structure of our site by providing the primary navigation sidebar layout. Here we have three top-level links, one for the home page and one where all the generated API documentation from `mkdocstrings` will live.
425
413
426
414
```yaml
427
415
nav:
428
416
- Home: index.md
429
417
- Python API: api.md
430
-
- Examples: generated/gallery
431
418
```
432
419
433
420
{% endtab %} {% endtabs %}
@@ -651,15 +638,15 @@ Note that your docstrings are still parsed as reStructuredText.
651
638
652
639
API documentation can be built from your docstring using the `mkdocstrings` plugin, as referenced previously. Unlike with Sphinx, which requires a direct invocation of `sphinx-apidoc`, MkDocs plugins are integrated into the MkDocs build.
653
640
654
-
All `mkdocstrings` requires is your markdown files to specify what package, module, or class you would like documented in said file. See the [`mkdocstring` Usage page](https://mkdocstrings.github.io/usage/) for more details, but for a minimal example, if you add an `api.md` file and set its contents to:
641
+
All `mkdocstrings` requires is your markdown files to specify what module, class, or function you would like documented in said file. See the [`mkdocstring` Usage page](https://mkdocstrings.github.io/usage/) for more details, but for a minimal example, if you add an `api.md` file and set its contents to:
655
642
656
643
```markdown
657
-
# Documentation for `my_package.MyClass`
644
+
# Documentation for `my_package.my_module`
658
645
659
-
::: my_package.MyClass
646
+
::: my_package.my_module
660
647
```
661
648
662
-
Where the triple colon syntax is used to specify what documentation you would like built. In this case, we are asking for the class `MyClass` which is located in `my_package`, and a user would be able to import this class via `from my_package` import `MyClass`. If the class is not exposed in the package `__init__.py` and is only importable from a module (such that a user would have to write `from my_package.my_module import MyClass`) then you would update the identifier to `my_package.my_module.MyClass`.
649
+
Where the triple colon syntax is used to specify what documentation you would like built. In this case, we are asking to document the entire module `my_class` (and all classes and functions within it) which is located in `my_package`. You could instead ask for only a single component inside your module by being more specific, like `::: my_package.my_module.MyClass`.
663
650
664
651
{% endtab %}
665
652
{% endtabs %}
@@ -712,7 +699,7 @@ plugins:
712
699
- mkdocs-jupyter
713
700
```
714
701
715
-
Note that the `mkdocs-jupyter` plugin allows you to include both python scripts and notebooks. If you have a directory of example python files to run, consider [`mkdocs-gallery`](https://smarie.github.io/mkdocs-gallery/) as an alternative.
702
+
Note that the `mkdocs-jupyter` plugin allows you to include both python scripts and notebooks. If you have a directory of example python files to run, consider [`mkdocs-gallery`](https://smarie.github.io/mkdocs-gallery/) as an alternative. For an external example, the [ChainConsumer docs](https://samreay.github.io/ChainConsumer/generated/gallery/) show `mkdocs-gallery` in action.
0 commit comments