Skip to content

Commit 891fd08

Browse files
committed
sphinx init and templates
1 parent e899006 commit 891fd08

File tree

16 files changed

+512
-1
lines changed

16 files changed

+512
-1
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/_templates/autoapi/macros.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{% import 'macros.rst' as macros %}
2+
{% macro auto_summary(objs, title='') -%}
3+
4+
.. list-table:: {{ title }}
5+
:header-rows: 0
6+
:widths: auto
7+
8+
{% for obj in objs %}
9+
* - obj.name
10+
- obj.summary
11+
{% endfor %}
12+
{% endmacro %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "python/data.rst" %}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{% import 'macros.rst' as macros %}
2+
{% if obj.display %}
3+
{% if is_own_page %}
4+
{{ obj.id }}
5+
{{ "=" * obj.id | length }}
6+
7+
{% endif %}
8+
{% set visible_children = obj.children|selectattr("display")|list %}
9+
{% set own_page_children = visible_children|selectattr("type", "in", own_page_types)|list %}
10+
{% if is_own_page and own_page_children %}
11+
.. toctree::
12+
:hidden:
13+
14+
{% for child in own_page_children %}
15+
{{ child.include_path }}
16+
{% endfor %}
17+
18+
{% endif %}
19+
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}{% if obj.args %}({{ obj.args }}){% endif %}
20+
21+
{% for (args, return_annotation) in obj.overloads %}
22+
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}
23+
24+
{% endfor %}
25+
{% if obj.bases %}
26+
{% if "show-inheritance" in autoapi_options %}
27+
28+
Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
29+
{% endif %}
30+
31+
32+
{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
33+
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
34+
:parts: 1
35+
{% if "private-members" in autoapi_options %}
36+
:private-bases:
37+
{% endif %}
38+
39+
{% endif %}
40+
{% endif %}
41+
{% if obj.docstring %}
42+
43+
{{ obj.docstring|indent(3) }}
44+
{% endif %}
45+
{% for obj_item in visible_children %}
46+
{% if obj_item.type not in own_page_types %}
47+
48+
{{ obj_item.render()|indent(3) }}
49+
{% endif %}
50+
{% endfor %}
51+
{% if is_own_page and own_page_children %}
52+
{% set visible_attributes = own_page_children|selectattr("type", "equalto", "attribute")|list %}
53+
{% if visible_attributes %}
54+
Attributes
55+
----------
56+
57+
.. autoapisummary::
58+
59+
{% for attribute in visible_attributes %}
60+
{{ attribute.id }}
61+
{% endfor %}
62+
63+
64+
{% endif %}
65+
{% set visible_exceptions = own_page_children|selectattr("type", "equalto", "exception")|list %}
66+
{% if visible_exceptions %}
67+
Exceptions
68+
----------
69+
70+
.. autoapisummary::
71+
72+
{% for exception in visible_exceptions %}
73+
{{ exception.id }}
74+
{% endfor %}
75+
76+
77+
{% endif %}
78+
{% set visible_classes = own_page_children|selectattr("type", "equalto", "class")|list %}
79+
{% if visible_classes %}
80+
Classes
81+
-------
82+
83+
.. autoapisummary::
84+
85+
{{ macros.auto_summary(visible_classes, title="Classes") }}
86+
87+
88+
{% endif %}
89+
{% set visible_methods = own_page_children|selectattr("type", "equalto", "method")|list %}
90+
{% if visible_methods %}
91+
Methods
92+
-------
93+
94+
.. autoapisummary::
95+
96+
{% for method in visible_methods %}
97+
{{ method.id }}
98+
{% endfor %}
99+
100+
101+
{% endif %}
102+
{% endif %}
103+
{% endif %}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{% if obj.display %}
2+
{% if is_own_page %}
3+
{{ obj.id }}
4+
{{ "=" * obj.id | length }}
5+
6+
{% endif %}
7+
.. py:{{ obj.type }}:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.name }}{% endif %}
8+
{% if obj.annotation is not none %}
9+
10+
:type: {% if obj.annotation %} {{ obj.annotation }}{% endif %}
11+
{% endif %}
12+
{% if obj.value is not none %}
13+
14+
{% if obj.value.splitlines()|count > 1 %}
15+
:value: Multiline-String
16+
17+
.. raw:: html
18+
19+
<details><summary>Show Value</summary>
20+
21+
.. code-block:: python
22+
23+
{{ obj.value|indent(width=6,blank=true) }}
24+
25+
.. raw:: html
26+
27+
</details>
28+
29+
{% else %}
30+
:value: {{ obj.value|truncate(100) }}
31+
{% endif %}
32+
{% endif %}
33+
34+
{% if obj.docstring %}
35+
36+
{{ obj.docstring|indent(3) }}
37+
{% endif %}
38+
{% endif %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "python/class.rst" %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% if obj.display %}
2+
{% if is_own_page %}
3+
{{ obj.id }}
4+
{{ "=" * obj.id | length }}
5+
6+
{% endif %}
7+
.. py:function:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
8+
{% for (args, return_annotation) in obj.overloads %}
9+
10+
{%+ if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
11+
{% endfor %}
12+
{% for property in obj.properties %}
13+
14+
:{{ property }}:
15+
{% endfor %}
16+
17+
{% if obj.docstring %}
18+
19+
{{ obj.docstring|indent(3) }}
20+
{% endif %}
21+
{% endif %}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
API Reference
2+
=============
3+
4+
This page contains auto-generated API reference documentation [#f1]_.
5+
6+
.. toctree::
7+
:titlesonly:
8+
9+
{% for page in pages|selectattr("is_top_level_object") %}
10+
{{ page.include_path }}
11+
{% endfor %}
12+
13+
.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% if obj.display %}
2+
{% if is_own_page %}
3+
{{ obj.id }}
4+
{{ "=" * obj.id | length }}
5+
6+
{% endif %}
7+
.. py:method:: {% if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}
8+
{% for (args, return_annotation) in obj.overloads %}
9+
10+
{%+ if is_own_page %}{{ obj.id }}{% else %}{{ obj.short_name }}{% endif %}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}
11+
{% endfor %}
12+
{% for property in obj.properties %}
13+
14+
:{{ property }}:
15+
{% endfor %}
16+
17+
{% if obj.docstring %}
18+
19+
{{ obj.docstring|indent(3) }}
20+
{% endif %}
21+
{% endif %}

0 commit comments

Comments
 (0)