Usageยค
Installationยค
You can install this handler by specifying it as a dependency:
# PEP 621 dependencies declaration
# adapt to your dependencies manager
[project]
dependencies = [
"mkdocstrings-matlab>=0.X.Y",
]
Configurationยค
For mkdocstrings the default will be the Python handler. You can change the default handler,
or explicitely set the MATLAB handler as default by defining the default_handler
configuration option of mkdocstrings
in mkdocs.yml
:
plugins:
- mkdocstrings:
default_handler: matlab
matlab:
... # the MATLAB handler configuration
When using the material theme, it is best to also configure the mkdocs_material_matlab
plugin. This additional plugin, which is installed together with mkdocstrings-matlab, will overrule the symbols shown with show_symbol_type_heading
and show_symbol_type_toc
to show the correct symbols as per MATLAB nomenclature.
plugins:
- mkdocs_material_matlab
- mkdocstrings:
default_handler: matlab
matlab:
... # the MATLAB handler configuration
I want to document both MATLAB and Python
The mkdocs_material_matlab
plugin will also change the symbols for the Python handler. This means that Python modules will not be tagged with symbol mod
but name
(namespace), and attributes are not tagged with symbol attr
but prop
(property).
Injecting documentationยค
With the MATLAB handler installed and configured as default handler, you can inject documentation for a module, class, function, or any other MATLAB object with mkdocstrings' [autodoc syntax], in your Markdown pages:
::: path.to.object
If another handler was defined as default handler, you can explicitely ask for the MATLAB handler to be used when injecting documentation with the handler
option:
::: path.to.object
handler: matlab
Entire namespaces can be fully documented by prefixing the +
character to the namespace that is to be documented. E.g. the following namespace
๐ +mynamespace
โโโ ๐ Contents.m
โโโ ๐ readme.md
โโโ ๐ myclass.m
โโโ ๐ +subnamespace
โโโ ๐ mfunction.m
is documented with:
::: +mynamespace
The docstring of the namespace is taken from either the Contents.m
or a readme.md
that resides at the root level of the namespace, with Contents.m
taking precedence over readme.md
.
Documenting a nested namespace requires only a single prefixed +
at the start of the fully resolved path, e.g.
::: +mynamespace.subnamespace
Global-only optionsยค
Some options are global only, and go directly under the handler's name.
paths
ยค
This option is used to set the MATLAB search path. The MATLAB search path is a subset of all the folders in the file system. The order of folders on the search path is important. When files with the same name appear in multiple folders on the search path, MATLAB uses the one found in the folder nearest to the top of the search path.
Non-absolute paths are computed as relative to MkDocs configuration file. Example:
plugins:
- mkdocstrings:
handlers:
matlab:
paths: [src] # search files in the src folder
paths_recursive
ยค
This option allows you to specify whether the handler should recursively search through the directories specified in the paths
option. When set to true
, the handler will look for MATLAB files in all subdirectories of the specified paths.
Example:
plugins:
- mkdocstrings:
handlers:
matlab:
paths: [src] # search files in the src folder
paths_recursive: true # search recursively in subfolders
Global/local optionsยค
The other options can be used both globally and locally, under the options
key.
For example, globally:
plugins:
- mkdocstrings:
handlers:
matlab:
options:
do_something: true
...and locally, overriding the global configuration:
::: package.module.class
options:
do_something: false
These options affect how the documentation is collected from sources and rendered. See the following tables summarizing the options, and get more details for each option in the following pages:
- General options: various options that do not fit in the other categories
- Headings options: options related to headings and the table of contents (or sidebar, depending on the theme used)
- Members options: options related to filtering or ordering members in the generated documentation
- Docstrings options: options related to docstrings (parsing and rendering)
- Signature options: options related to signatures and type annotations
Options summaryยค
Default handler configuration.
General options:
-
show_bases
(bool
) โShow the base classes of a class. Default:
True
. -
show_inheritance_diagram
(bool
) โShow the inheritance diagram of a class using Mermaid. Default:
False
. -
show_source
(bool
) โShow the source code of this object. Default:
True
.
Headings options:
-
heading_level
(int
) โThe initial heading level to use. Default:
2
. -
parameter_headings
(bool
) โWhether to render headings for parameters (therefore showing parameters in the ToC). Default:
False
. -
show_root_heading
(bool
) โShow the heading of the object at the root of the documentation tree (i.e. the object referenced by the identifier after
:::
). Default:False
. -
show_root_toc_entry
(bool
) โIf the root heading is not shown, at least add a ToC entry for it. Default:
True
. -
show_root_full_path
(bool
) โShow the full path for the root object heading. Default:
True
. -
show_root_members_full_path
(bool
) โShow the full path of the root members. Default:
False
. -
show_object_full_path
(bool
) โShow the full path of every object. Default:
False
. -
show_category_heading
(bool
) โWhen grouped by categories, show a heading for each category. Default:
False
. -
show_symbol_type_heading
(bool
) โShow the symbol type in headings (e.g. mod, class, meth, func and attr). Default:
False
. -
show_symbol_type_toc
(bool
) โShow the symbol type in the Table of Contents (e.g. mod, class, methd, func and attr). Default:
False
.
Members options:
-
members
(list[str] | bool | None
) โA boolean, or an explicit list of members to render. If true, select all members without further filtering. If false or empty list, do not render members. If none, select all members and apply further filtering with filters and docstrings. Default:
None
. -
hidden_members
(list[str] | bool | None
) โA boolean, or an explicit list of hidden members to render. If true, select all inherited members, which can then be filtered with
members
. If false or empty list, do not select any hidden member. Default:False
. -
private_members
(list[str] | bool | None
) โA boolean, or an explicit list of private members to render. If true, select all inherited members, which can then be filtered with
members
. If false or empty list, do not select any private member. Default:False
. -
inherited_members
(list[str] | bool | None
) โA boolean, or an explicit list of inherited members to render. If true, select all inherited members, which can then be filtered with
members
. If false or empty list, do not select any inherited member. Default:False
. -
members_order
(str
) โThe members ordering to use. Options:
alphabetical
- order by the members names,source
- order members as they appear in the source file. Default:"alphabetical"
. -
filters
(list[str] | None
) โA list of filters applied to filter objects based on their name. A filter starting with
!
will exclude matching objects instead of including them. Themembers
option takes precedence overfilters
(filters will still be applied recursively to lower members in the hierarchy). Default:["!^delete$|^disp$"]
. -
group_by_category
(bool
) โGroup the object's children by categories: properties, classes, functions, and namespaces. Default:
True
. -
show_subnamespaces
(bool
) โWhen rendering a namespace, show its subnamespaces recursively. Default:
False
. -
summary
(bool | dict[str, bool]
) โWhether to render summaries of namespaces, classes, functions (methods) and properties. Default:
False
. -
show_labels
(bool
) โWhether to show labels of the members. Default:
True
.
Docstrings options:
-
docstring_style
(str
) โThe docstring style to use:
google
,numpy
,sphinx
, orNone
. Default:"google"
. -
docstring_options
(dict
) โThe options for the docstring parser. See docstring parsers and their options in Griffe docs.
-
docstring_section_style
(str
) โThe style used to render docstring sections. Options:
table
,list
,spacy
. Default:"table"
. -
parse_arguments
(bool
) โWhether to load inputs and output parameters based on argument validation blocks. Default:
True
. -
merge_constructor_into_class
(bool
) โWhether to merge the constructor method into the class' signature and docstring. Default:
False
. -
merge_constructor_ignore_summary
(bool
) โWhether to ignore the constructor summary when merging it into the class. Default:
False
. -
show_if_no_docstring
(bool
) โShow the object heading even if it has no docstring or children with docstrings. Default:
False
. -
show_docstring_properties
(bool
) โWhether to display the "Properties" section in the object's docstring. Default:
True
. -
show_docstring_functions
(bool
) โWhether to display the "Functions" or "Methods" sections in the object's docstring. Default:
True
. -
show_docstring_classes
(bool
) โWhether to display the "Classes" section in the object's docstring. Default:
True
. -
show_docstring_namespaces
(bool
) โWhether to display the "Namespaces" section in the object's docstring. Default:
True
. -
show_docstring_description
(bool
) โWhether to display the textual block (including admonitions) in the object's docstring. Default:
True
. -
show_docstring_examples
(bool
) โWhether to display the "Examples" section in the object's docstring. Default:
True
. -
show_docstring_input_arguments
(bool
) โWhether to display the "Input arguments" section in the object's docstring. Default:
True
. -
show_docstring_name_value_arguments
(bool
) โWhether to display the "Name-value pairs" section in the object's docstring. Default:
True
. -
show_docstring_output_arguments
(bool
) โWhether to display the "Output arguments" section in the object's docstring. Default:
True
.
Signatures/annotations options:
-
show_signature
(bool
) โShow methods and functions signatures. Default:
True
. -
show_signature_annotations
(bool
) โShow the type annotations in methods and functions signatures. Default:
False
. -
separate_signature
(bool
) โWhether to put the whole signature in a code block below the heading.
-
signature_crossrefs
(bool
) โWhether to render cross-references for type annotations in signatures. Default:
False
.