Releases: mkdocstrings/mkdocstrings
1.0.0
1.0.0 - 2025-11-27
Breaking Changes
BaseHandler.name: Attribute value was changed:''-> unsetBaseHandler.domain: Attribute value was changed:''-> unsetBaseHandler.fallback_config: Public object was removedBaseHandler.__init__(args): Parameter was removedBaseHandler.__init__(kwargs): Parameter was removedBaseHandler.__init__(theme): Parameter was added as requiredBaseHandler.__init__(custom_templates): Parameter was added as requiredBaseHandler.__init__(mdx): Parameter was added as requiredBaseHandler.__init__(mdx_config): Parameter was added as requiredBaseHandler.update_env(args): Parameter was removedBaseHandler.update_env(kwargs): Parameter was removedBaseHandler.update_env(config): Parameter was added as requiredHandlers.get_anchors: Public object was removed (import frommkdocstringsdirectly)mkdocstrings.plugin: Public module was removed (import frommkdocstringsdirectly)mkdocstrings.loggers: Public module was removed (import frommkdocstringsdirectly)mkdocstrings.inventory: Public module was removed (import frommkdocstringsdirectly)mkdocstrings.extension: Public module was removed (import frommkdocstringsdirectly)mkdocstrings.handlers: Public module was removed (import frommkdocstringsdirectly)
Code Refactoring
- Remove deprecated code before v1 (de34044 by Timothée Mazzucotelli).
- Expect Zensical to pass extension configuration instead of loading it again from YAML (6b73d5a by Timothée Mazzucotelli).
- Expose the Markdown extension, to make mkdocstrings compatible with Zensical (6de2667 by Timothée Mazzucotelli).
0.30.1
0.30.0
0.30.0 - 2025-07-23
Features
0.29.1
0.29.0
0.28.3
0.28.3 - 2025-03-08
Deprecations
All public objects must now be imported from the top-level mkdocstrings module. Importing from submodules is deprecated, and will raise errors starting with v1. This should be the last deprecation before v1.
Build
- Make
pythonextra depend on latest mkdocstrings-python (1.16.2) (ba9003e by Timothée Mazzucotelli).
Code Refactoring
0.28.2
0.28.1
0.28.1 - 2025-02-14
Bug Fixes
- Renew MkDocs'
relpathprocessor instead of using same instance (4ab180d by Timothée Mazzucotelli). Issue-mkdocs-3919
0.28.0
0.28.0 - 2025-02-03
Breaking Changes
Although the following changes are "breaking" in terms of public API, we didn't find any public use of these classes and methods on GitHub.
mkdocstrings.extension.AutoDocProcessor.__init__(parser): Parameter was removedmkdocstrings.extension.AutoDocProcessor.__init__(md): Positional parameter was movedmkdocstrings.extension.AutoDocProcessor.__init__(config): Parameter was removedmkdocstrings.extension.AutoDocProcessor.__init__(handlers): Parameter kind was changed:positional or keyword->keyword-onlymkdocstrings.extension.AutoDocProcessor.__init__(autorefs): Parameter kind was changed:positional or keyword->keyword-onlymkdocstrings.extension.MkdocstringsExtension.__init__(config): Parameter was removedmkdocstrings.extension.MkdocstringsExtension.__init__(handlers): Positional parameter was movedmkdocstrings.extension.MkdocstringsExtension.__init__(autorefs): Positional parameter was movedmkdocstrings.handlers.base.Handlers.__init__(config): Parameter was removedmkdocstrings.handlers.base.Handlers.__init__(theme): Parameter was added as requiredmkdocstrings.handlers.base.Handlers.__init__(default): Parameter was added as requiredmkdocstrings.handlers.base.Handlers.__init__(inventory_project): Parameter was added as requiredmkdocstrings.handlers.base.Handlers.__init__(tool_config): Parameter was added as required
Similarly, the following parameters were renamed, but the methods are only called from our own code, using positional arguments.
mkdocstrings.handlers.base.BaseHandler.collect(config): Parameter was renamedoptionsmkdocstrings.handlers.base.BaseHandler.render(config): Parameter was renamedoptions
Finally, the following method was removed, but this is again taken into account in our own code:
mkdocstrings.handlers.base.BaseHandler.get_anchors: Public object was removed
For these reasons, and because we're still in v0, we do not bump to v1 yet. See following deprecations.
Deprecations
mkdocstrings 0.28 will start emitting these deprecations warnings:
The
handlerargument is deprecated. The handler name must be specified as a class attribute.
Previously, the get_handler function would pass a handler (name) argument to the handler constructor. This name must now be set on the handler's class directly.
class MyHandler:
name = "myhandler"The
domainattribute must be specified as a class attribute.
The domain class attribute on handlers is now mandatory and cannot be an empty string.
class MyHandler:
domain = "mh"The
themeargument must be passed as a keyword argument.
This argument could previously be passed as a positional argument (from the get_handler function), and must now be passed as a keyword argument.
The
custom_templatesargument must be passed as a keyword argument.
Same as for theme, but with custom_templates.
The
mdxargument must be provided (as a keyword argument).
The get_handler function now receives a mdx argument, which it must forward to the handler constructor and then to the base handler, either explicitly or through **kwargs:
=== "Explicitly"
def get_handler(..., mdx, ...):
return MyHandler(..., mdx=mdx, ...)
class MyHandler:
def __init__(self, ..., mdx, ...):
super().__init__(..., mdx=mdx, ...)=== "Through **kwargs"
def get_handler(..., **kwargs):
return MyHandler(..., **kwargs)
class MyHandler:
def __init__(self, ..., **kwargs):
super().__init__(**kwargs)In the meantime we still retrieve this mdx value at a different moment, by reading it from the MkDocs configuration.
The
mdx_configargument must be provided (as a keyword argument).
Same as for mdx, but with mdx_config.
mkdocstrings v1 will stop handling 'import' in handlers configuration. Instead your handler must define a
get_inventory_urlsmethod that returns a list of URLs to download.
Previously, mkdocstrings would pop the import key from a handler's configuration to download each item (URLs). Items could be strings, or dictionaries with a url key. Now mkdocstrings gives back control to handlers, which must store this inventory configuration within them, and expose it again through a get_inventory_urls method. This method returns a list of tuples: an URL, and a dictionary of options that will be passed again to their load_inventory method. Handlers have now full control over the "inventory" setting.
from copy import deepcopy
def get_handler(..., handler_config, ...):
return MyHandler(..., config=handler_config, ...)
class MyHandler:
def __init__(self, ..., config, ...):
self.config = config
def get_inventory_urls(self):
config = deepcopy(self.config["import"])
return [(inv, {}) if isinstance(inv, str) else (inv.pop("url"), inv) for inv in config]Changing the name of the key (for example from import to inventories) involves a change in user configuration, and both keys will have to be supported by your handler for some time.
def get_handler(..., handler_config, ...):
if "inventories" not in handler_config and "import" in handler_config:
warn("The 'import' key is renamed 'inventories'", FutureWarning)
handler_config["inventories"] = handler_config.pop("import")
return MyHandler(..., config=handler_config, ...)Setting a fallback anchor function is deprecated and will be removed in a future release.
This comes from mkdocstrings and mkdocs-autorefs, and will disappear with mkdocstrings v0.28.
mkdocstrings v1 will start using your handler's
get_optionsmethod to build options instead of merging the global and local options (dictionaries).
Handlers must now store their own global options (in an instance attribute), and implement a get_options method that receives local_options (a dict) and returns combined options (dict or custom object). These combined options are then passed to collect and render, so that these methods can use them right away.
def get_handler(..., handler_config, ...):
return MyHandler(..., config=handler_config, ...)
class MyHandler:
def __init__(self, ..., config, ...):
self.config = config
def get_options(local_options):
return {**self.default_options, **self.config["options"], **local_options}The
update_env(md)parameter is deprecated. Useself.mdinstead.
Handlers can remove the md parameter from their update_env method implementation, and use self.md instead, if they need it.
No need to call
super().update_env()anymore.
Handlers don't have to call the parent update_env method from their own implementation anymore, and can just drop the call.
The
get_anchorsmethod is deprecated. Declare aget_aliasesmethod instead, accepting a string (identifier) instead of a collected object.
Previously, handlers would implement a get_anchors method that received a data object (typed CollectorItem) to return aliases for this object. This forced mkdocstrings to collect this object through the handler's collect method, which then required some logic with "fallback config" as to prevent unwanted collection. mkdocstrings gives back control to handlers and now calls get_aliases instead, which accepts an identifier (string) and lets the handler decide how to return aliases for this identifier. For example, it can replicate previous behavior by calling its own collect method with its own "fallback config", or do something different (cache lookup, etc.).
class MyHandler:
def get_aliases(identifier):
try:
obj = self.collect(identifier, self.fallback_config)
# or obj = self._objects_cache[identifier]
except CollectionError: # or KeyError
return ()
return ... # previous logic in `get_anchors`The
config_file_pathargument inget_handlerfunctions is deprecated. Usetool_config.get('config_file_path')instead.
The config_file_path argument is now deprecated and only passed to get_handler functions if they accept it. If you used it to compute a "base directory", you can now use the tool_config argument instead, which is the configuration of the SSG tool in use (here MkDocs):
base_dir = Path(tool_config.config_file_path or "./mkdocs.yml").parentMost of these warnings will disappear with the next version of mkdocstrings-python.
Bug Fixes
- Update handlers in JSON schema to be an object instead of an array (3cf7d51 by Matthew Messinger). Issue-733, PR-734
- Fix broken table of contents when nesting autodoc instructions (12c8f82 by Timothée Mazzucotelli). Issue-348
Code Refactoring
- Pass
config_file_pathtoget_handlerif it expects it (8c476ee by Timothée Mazzucotelli). - Give back inventory control to handlers (b84653f by Timothée Mazzucotelli). Related-to-issue-719
- Give back control to handlers on how they want to handle global/local options (c00de7a by Timothée Mazzucotelli). [Issue-719](#719...
0.27.0
0.27.0 - 2024-11-08
Features
- Add support for authentication in inventory file URLs (1c23c1b by Stefan Mejlgaard). Issue-707, PR-710
Performance Improvements
- Reduce footprint of template debug messages (5648e5a by Timothée Mazzucotelli).
Code Refactoring
- Use %-formatting for logging messages (0bbb8ca by Timothée Mazzucotelli).