Skip to content

Commit 39b0465

Browse files
committed
feat: Allow namespace packages for handlers
1 parent 2029035 commit 39b0465

9 files changed

Lines changed: 15 additions & 37 deletions

File tree

docs/handlers/overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
A handler is what makes it possible to collect and render documentation for a particular language.
44
It is composed of a collector and a renderer.
55
See the documentation for
6-
[`BaseHandler`][mkdocstrings.handlers.BaseHandler],
7-
[`BaseCollector`][mkdocstrings.handlers.BaseCollector] and
8-
[`BaseRenderer`][mkdocstrings.handlers.BaseRenderer].
6+
[`BaseHandler`][mkdocstrings.handlers.base.BaseHandler],
7+
[`BaseCollector`][mkdocstrings.handlers.base.BaseCollector] and
8+
[`BaseRenderer`][mkdocstrings.handlers.base.BaseRenderer].
99

1010
## Available handlers
1111

docs/reference/handlers/__init__.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/reference/handlers/base.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
::: mkdocstrings.handlers.base
2+
rendering:
3+
show_root_heading: false

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ nav:
1313

1414
- API Reference:
1515
- handlers:
16-
- __init__.py: reference/handlers/__init__.md
16+
- base.py: reference/handlers/base.md
1717
- python.py: reference/handlers/python.md
1818
- extension.py: reference/extension.md
1919
- plugin.py: reference/plugin.md

src/mkdocstrings/__init__.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/mkdocstrings/extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
The extension is composed of a Markdown [block processor](https://python-markdown.github.io/extensions/api/#blockparser)
55
that matches indented blocks starting with a line like '::: identifier'.
66
7-
For each of these blocks, it uses a [handler][mkdocstrings.handlers.BaseHandler] to collect documentation about
7+
For each of these blocks, it uses a [handler][mkdocstrings.handlers.base.BaseHandler] to collect documentation about
88
the given identifier and render it with Jinja templates.
99
1010
Both the collection and rendering process can be configured by adding YAML configuration under the "autodoc"
@@ -34,7 +34,7 @@
3434
from markdown.extensions import Extension
3535
from markdown.util import AtomicString
3636

37-
from mkdocstrings.handlers import CollectionError, get_handler
37+
from mkdocstrings.handlers.base import CollectionError, get_handler
3838
from mkdocstrings.logging import get_logger
3939

4040
log = get_logger(__name__)

src/mkdocstrings/handlers/python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from markdown import Markdown
1414

15-
from mkdocstrings.handlers import BaseCollector, BaseHandler, BaseRenderer, CollectionError
15+
from mkdocstrings.handlers.base import BaseCollector, BaseHandler, BaseRenderer, CollectionError
1616
from mkdocstrings.logging import get_logger
1717

1818
log = get_logger(__name__)
@@ -23,7 +23,7 @@ class PythonRenderer(BaseRenderer):
2323
The class responsible for loading Jinja templates and rendering them.
2424
2525
It defines some configuration options, implements the `render` method,
26-
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.BaseRenderer].
26+
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.base.BaseRenderer].
2727
2828
Attributes:
2929
fallback_theme: The theme to fallback to.
@@ -91,7 +91,7 @@ class PythonCollector(BaseCollector):
9191
The class responsible for loading Jinja templates and rendering them.
9292
9393
It defines some configuration options, implements the `render` method,
94-
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.BaseRenderer].
94+
and overrides the `update_env` method of the [`BaseRenderer` class][mkdocstrings.handlers.base.BaseRenderer].
9595
"""
9696

9797
default_config: dict = {"filters": ["!^_[^_]"]}

src/mkdocstrings/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
and fixes them using the previously stored identifier-URL mapping.
1616
1717
Once the documentation is built, the [`on_post_build` event hook](https://www.mkdocs.org/user-guide/plugins/#on_post_build)
18-
is triggered and calls the [`handlers.teardown()` method][mkdocstrings.handlers.teardown]. This method is used
19-
to teardown the [handlers][mkdocstrings.handlers] that were instantiated during documentation buildup.
18+
is triggered and calls the [`handlers.teardown()` method][mkdocstrings.handlers.base.teardown]. This method is used
19+
to teardown the handlers that were instantiated during documentation buildup.
2020
2121
Finally, when serving the documentation, it can add directories to watch
2222
during the [`on_serve` event hook](https://www.mkdocs.org/user-guide/plugins/#on_serve).
@@ -34,7 +34,7 @@
3434
from mkdocs.structure.toc import AnchorLink
3535

3636
from mkdocstrings.extension import MkdocstringsExtension
37-
from mkdocstrings.handlers import teardown
37+
from mkdocstrings.handlers.base import teardown
3838
from mkdocstrings.logging import get_logger
3939
from mkdocstrings.references import fix_refs
4040

0 commit comments

Comments
 (0)