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.
mkdocstrings 0.28 will start emitting these deprecations warnings:
The handler argument 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.
classMyHandler:name="myhandler"
The domain attribute must be specified as a class attribute.
The domain class attribute on handlers is now mandatory and cannot be an empty string.
classMyHandler:domain="mh"
The theme argument 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_templates argument must be passed as a keyword argument.
Same as for theme, but with custom_templates.
The mdx argument 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:
In the meantime we still retrieve this mdx value at a different moment, by reading it from the MkDocs configuration.
The mdx_config argument 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_urls method 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.
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.
defget_handler(...,handler_config,...):if"inventories"notinhandler_configand"import"inhandler_config:warn("The 'import' key is renamed 'inventories'",FutureWarning)handler_config["inventories"]=handler_config.pop("import")returnMyHandler(...,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_options method 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.
The update_env(md) parameter is deprecated. Use self.md instead.
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_anchors method is deprecated. Declare a get_aliases method 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.).
classMyHandler:defget_aliases(identifier):try:obj=self.collect(identifier,self.fallback_config)# or obj = self._objects_cache[identifier]exceptCollectionError:# or KeyErrorreturn()return...# previous logic in `get_anchors`
The config_file_path argument in get_handler functions is deprecated. Use tool_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):
Make custom_templates relative to the config file (370a61d by Waylan Limberg). Issue #477, PR #627
Remove duplicated headings for docstrings nested in tabs/admonitions (e2123a9 by Perceval Wajsburt, f4a94f7 by Oleh Prypin). Issue #609, PR #610, PR #613
We decided to deprecate a few things to pave the way towards a more stable code base, bringing us closer to a v1.
Selection and rendering options are now combined into a single options key. Using the old keys will emit a deprecation warning.
The BaseCollector and BaseRenderer classes are deprecated in favor of BaseHandler, which merges their functionality. Using the old classes will emit a deprecation warning.
New versions of the Python handler and the legacy Python handler were also released in coordination with mkdocstrings 0.19. See their respective changelogs: python, python-legacy. Most notably, the Python handler gained the members and filters options that prevented many users to switch to it.
mkdocstrings stopped depending directly on the legacy Python handler. It means you now have to explicitely depend on it, directly or through the extra provided by mkdocstrings, if you want to continue using it.
We provide a new, experimental Python handler based on Griffe. This new handler brings automatic cross-references for every annotation in your code, including references to third-party libraries' APIs if they provide objects inventories and you explicitely load them in mkdocs.yml. See migration notes in the documentation.
The following items are possible breaking changes:
Cross-linking to arbitrary headings now requires to opt-in to the autorefs plugin, which is installed as a dependency of mkdocstrings. See Cross-references to any Markdown heading.
mkdocstrings now respects your configured code highlighting method, so if you are using the CodeHilite extension, the .highlight CSS class in the rendered HTML will become .codehilite. So make sure to adapt your extra CSS accordingly. Or just switch to using pymdownx.highlight, it's better supported by mkdocstrings anyway. See Syntax highlighting.
Most of the CSS rules that mkdocstrings used to recommend for manual addition, now become mandatory (auto-injected into the site). This shouldn't break any of your styles, but you are welcome to remove the now-redundant lines that you had copied into extra_css, similarly to this diff.
Special thanks to Oleh @oprypin Prypin who did an amazing job (this is a euphemism) at improving mkdocstrings, fixing hard-to-fix bugs with clever solutions, implementing great new features and refactoring the code for better performance and readability! Thanks Oleh!
Accept pytkdocs version up to 0.5.x (changelog). If it breaks your docs, please open issues on pytkdocs' bug-tracker, or pin pytkdocs version to while waiting for bug fixes <0.5.0 .
This version increases the accepted range of versions for the pytkdocs dependency to >=0.2.0, <0.4.0. The pytkdocs project just released version 0.3.0 which:
adds support for complex markup in docstrings sections items descriptions
adds support for different indentations in docstrings sections (tabulations or less/more than 4 spaces)
fixes docstring parsing for arguments whose names start with *, like *args and **kwargs
This version increases the accepted range of versions for the pymdown-extensions dependency, as well as for the mkdocs-material development dependency. Indeed, both these projects recently released major versions 7 and 5 respectively. Users who wish to use these new versions will be able to. See issue #74.
This version is a big refactor. We will just list the new features without pointing to particular commits. The documentation rendering looks slightly different, and should be better than before. No identified breaking changes for end-users.
Language agnostic: we moved the code responsible for loading Python documentation into a new project, pytkdocs, and implemented a "handlers" logic, effectively allowing to support any given language. Waiting for your handlers contributions !
Multiple themes support: handlers can offer templates for multiple mkdocs themes.
Better cross-references: cross-references now not only work between documented objects (between all languages, given the objects' identifiers are unique), but also for every heading of your Markdown pages.
Configuration options: the rendering of Python documentation can now be configured, (globally and locally thanks to the handlers system), check the docs! Also see the recommended CSS.
Proper logging messages:mkdocstrings now logs debug, warning and error messages, useful when troubleshooting.
Be compatible with Mkdocs >= 1.1 (5a974a4). This is a breaking change as we're not compatible with versions of Mkdocs below 1.1 anymore. If you cannot upgrade Mkdocs to 1.1, pin mkdocstrings' version to 0.7.2.