Docstub will automatically look for configuration files in the current directory. These files must be named
pyproject.tomldocstub.toml
Alternatively, config files can also be passed in the command line with the --config option.
In this case, docstub will not look for configuration files in the current directory.
When multiple configuration files are passed explicitly, their content is merged.
Out of the box, docstub makes use of an internal configuration files are always loaded.
One such file is numpy_config.toml which provides defaults for NumPy types.
All configuration must be declared inside a [tool.docstub] table.
TOML type: array of string(s)
Ignore files and directories matching these glob-style patterns. Patterns that don't start with "/" are interpreted as relative to the directory that contains the Python package for which stubs are generated.
Example:
[tool.docstub]
ignore_files = [
"**/tests",
]- Will ignore any directory anywhere that is named
tests.
TOML type: table, mapping string to string
Types and their external modules to use in docstrings. Docstub can't yet automatically discover where to import types from other packages from. Instead, you can provide this information explicitly. Any type on the left side will be associated with the given "module" on the right side.
Example:
[tool.docstub.types]
Path = "pathlib"
NDArray = "numpy.typing"- Will allow using
Pathin docstrings and will usefrom pathlib import Pathto import the type. - Will allow using
NDarrayin docstrings and will usefrom numpy.typing import NDArrayto import the type.
TOML type: table, mapping string to string
Prefixes for external modules to match types in docstrings. Docstub can't yet automatically discover where to import types from other packages from. Instead, you can provide this information explicitly. Any type in a docstring whose prefix matches the name given on the left side, will be associated with the given "module" on the right side.
Example:
[tool.docstub.type_prefixes]
np = "numpy"
plt = "matplotlib.pyplot- Will match
np.uint8andnp.typing.NDarrayand useimport numpy as np. - Will match
plt.Figureuseimport matplotlib.pyplot as plt.
TOML type: table, mapping string to string
Nicknames for types that can be used in docstrings to describe valid Python types or annotations.
Example:
[tool.docstub.type_nicknames]
func = "Callable"
buffer = "collections.abc.Buffer"- Will map
functo theCallable. - Will map
buffertocollections.abc.Buffer.