Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-05-03 19:16:07 +0300
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-05-04 12:42:22 +0300
commitb93f53c7e4c84922a77f63cc0e1dca0a60a72201 (patch)
tree526e9684c36b97e04ae3dfecf9db5d1eab9b2632 /sphinx/templates
parente41d6f3651416ca6ce31d637b572895264661f00 (diff)
apidoc: Use a template for generating package file
Diffstat (limited to 'sphinx/templates')
-rw-r--r--sphinx/templates/apidoc/package.rst52
-rw-r--r--sphinx/templates/apidoc/toc.rst1
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 %}