diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-05-06 15:08:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-06 15:08:30 +0300 |
commit | a9b3ec532276b7dc0ef35273177a1c6716796d73 (patch) | |
tree | 8455c55f08a00154e904abe279ddea4f331a8ed2 /sphinx/templates | |
parent | 2b8c76c6c2a7baf9b90cdac0c6f45bf1c1f417aa (diff) | |
parent | fa560ebf958e0319353db1da04e36ccef45c76c4 (diff) |
Merge pull request #6338 from tk0miya/template_for_apidoc
refactor apidoc: Add templates for generating reST files
Diffstat (limited to 'sphinx/templates')
-rw-r--r-- | sphinx/templates/apidoc/module.rst | 9 | ||||
-rw-r--r-- | sphinx/templates/apidoc/package.rst | 52 | ||||
-rw-r--r-- | sphinx/templates/apidoc/toc.rst | 8 |
3 files changed, 69 insertions, 0 deletions
diff --git a/sphinx/templates/apidoc/module.rst b/sphinx/templates/apidoc/module.rst new file mode 100644 index 000000000..249027855 --- /dev/null +++ b/sphinx/templates/apidoc/module.rst @@ -0,0 +1,9 @@ +{%- if show_headings %} +{{- [basename, "module"] | join(' ') | e | heading }} + +{% endif -%} +.. automodule:: {{ qualname }} +{%- for option in automodule_options %} + :{{ option }}: +{%- endfor %} + 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 new file mode 100644 index 000000000..f0877eeb2 --- /dev/null +++ b/sphinx/templates/apidoc/toc.rst @@ -0,0 +1,8 @@ +{{ header | heading }} + +.. toctree:: + :maxdepth: {{ maxdepth }} +{% for docname in docnames %} + {{ docname }} +{%- endfor %} + |