Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for autodoc --templatedir option #19

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ The *apidoc* extension uses the following configuration values:

**Optional**, defaults to ``api``.

``apidoc_template_dir``
A directory containing user-defined templates. Template files in this
directory that match the default apidoc templates (``module.rst_t``,
``package.rst_t``, ``toc.rst_t``) will overwrite them. The default templates
can be found in ``site-packages/sphinx/templates/apidoc/``. This path is
relative to the documentation source directory.

**Optional**, defaults to ``'templates'``.

``apidoc_excluded_paths``
An optional list of modules to exclude. These should be paths relative to
``apidoc_module_dir``. fnmatch-style wildcarding is supported.
Expand Down
1 change: 1 addition & 0 deletions sphinxcontrib/apidoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.connect('builder-inited', ext.builder_inited)
app.add_config_value('apidoc_module_dir', None, 'env', [str])
app.add_config_value('apidoc_output_dir', 'api', 'env', [str])
app.add_config_value('apidoc_template_dir', 'templates', 'env', [str])
app.add_config_value('apidoc_excluded_paths', [], 'env', [[str]])
app.add_config_value('apidoc_separate_modules', False, 'env', [bool])
app.add_config_value('apidoc_toc_file', None, 'env', [str, bool])
Expand Down
4 changes: 4 additions & 0 deletions sphinxcontrib/apidoc/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
def builder_inited(app: Sphinx) -> None:
module_dir = app.config.apidoc_module_dir
output_dir = path.join(app.srcdir, app.config.apidoc_output_dir)
template_dir = path.join(app.srcdir, app.config.apidoc_template_dir)
excludes = app.config.apidoc_excluded_paths
separate_modules = app.config.apidoc_separate_modules
toc_file = app.config.apidoc_toc_file
Expand Down Expand Up @@ -65,6 +66,9 @@ def cmd_opts():
yield '--output-dir'
yield output_dir

yield '--templatedir'
yield template_dir

for arg in extra_args:
yield arg

Expand Down