diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-05-04 01:16:07 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-05-04 18:42:22 +0900 |
commit | b93f53c7e4c84922a77f63cc0e1dca0a60a72201 (patch) | |
tree | 526e9684c36b97e04ae3dfecf9db5d1eab9b2632 /sphinx/templates | |
parent | e41d6f3651416ca6ce31d637b572895264661f00 (diff) | |
download | sphinx-git-b93f53c7e4c84922a77f63cc0e1dca0a60a72201.tar.gz |
apidoc: Use a template for generating package file
Diffstat (limited to 'sphinx/templates')
-rw-r--r-- | sphinx/templates/apidoc/package.rst | 52 | ||||
-rw-r--r-- | sphinx/templates/apidoc/toc.rst | 1 |
2 files changed, 52 insertions, 1 deletions
diff --git a/sphinx/templates/apidoc/package.rst b/sphinx/templates/apidoc/package.rst new file mode 100644 index 000000000..0026af34c --- /dev/null +++ b/sphinx/templates/apidoc/package.rst @@ -0,0 +1,52 @@ +{%- macro automodule(modname, options) -%} +.. automodule:: {{ modname }} +{%- for option in options %} + :{{ option }}: +{%- endfor %} +{%- endmacro %} + +{%- macro toctree(docnames) -%} +.. toctree:: +{% for docname in docnames %} + {{ docname }} +{%- endfor %} +{%- endmacro %} + +{%- if is_namespace %} +{{- [pkgname, "namespace"] | join(" ") | e | heading }} +{% else %} +{{- [pkgname, "package"] | join(" ") | e | heading }} +{% endif %} + +{%- if modulefirst and not is_namespace %} +{{ automodule(pkgname, automodule_options) }} +{% endif %} + +{%- if subpackages %} +Subpackages +----------- + +{{ toctree(subpackages) }} +{% endif %} + +{%- if submodules %} +Submodules +---------- +{% if separatemodules %} +{{ toctree(submodules) }} +{%- else %} +{%- for submodule in submodules %} +{% if show_headings %} +{{- [submodule, "module"] | join(" ") | e | heading(2) }} +{% endif %} +{{ automodule(submodule, automodule_options) }} +{%- endfor %} +{% endif %} +{% endif %} + +{%- if not modulefirst and not is_namespace %} +Module contents +--------------- + +{{ automodule(pkgname, automodule_options) }} +{% endif %} diff --git a/sphinx/templates/apidoc/toc.rst b/sphinx/templates/apidoc/toc.rst index 291a19402..f0877eeb2 100644 --- a/sphinx/templates/apidoc/toc.rst +++ b/sphinx/templates/apidoc/toc.rst @@ -2,7 +2,6 @@ .. toctree:: :maxdepth: {{ maxdepth }} - {% for docname in docnames %} {{ docname }} {%- endfor %} |