Skip to content

Commit ff86d06

Browse files
authored
Merge pull request #138 from scaleapi/drake-sphinx
[docs] set up sphinx
2 parents db42274 + 4f34d18 commit ff86d06

File tree

14 files changed

+338
-1
lines changed

14 files changed

+338
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ instance/
7070

7171
# Sphinx documentation
7272
docs/_build/
73+
docs/_autosummary/
7374

7475
# PyBuilder
7576
target/
@@ -136,4 +137,4 @@ dmypy.json
136137
poetry.lock
137138

138139
# vscode
139-
.vscode/
140+
.vscode/

.readthedocs.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
3+
python:
4+
install:
5+
- requirements: docs/requirements.txt
6+
- method: pip
7+
path: .

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 = source
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/autosummary/base.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. auto{{ objtype }}:: {{ objname }}

docs/_templates/autosummary/class.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{ objname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:
9+
:inherited-members:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{ objname | escape | underline }}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autofunction:: {{ name }}
6+
:members:
7+
:show-inheritance:
8+
:inherited-members:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{ objname | escape | underline }}
2+
3+
.. automodule:: {{ fullname }}
4+
:members:
5+
:undoc-members:
6+
:show-inheritance:
7+
:inherited-members:
8+
9+
{% block attributes %}
10+
{% if attributes %}
11+
.. rubric:: Module Attributes
12+
13+
.. autoattribute::
14+
{% for item in attributes %}
15+
{{ item }}
16+
{%- endfor %}
17+
{% endif %}
18+
{% endblock %}
19+
20+
{% block functions %}
21+
{% if functions %}
22+
.. rubric:: {{ _('Functions') }}
23+
24+
.. autofunction::
25+
{% for item in functions %}
26+
{{ item }}
27+
{%- endfor %}
28+
{% endif %}
29+
{% endblock %}
30+
31+
{% block classes %}
32+
{% if classes %}
33+
.. rubric:: {{ _('Classes') }}
34+
35+
.. autosummary::
36+
:toctree:
37+
{% for item in classes %}
38+
{{ item }}
39+
{%- endfor %}
40+
{% endif %}
41+
{% endblock %}
42+
43+
{% block exceptions %}
44+
{% if exceptions %}
45+
.. rubric:: {{ _('Exceptions') }}
46+
47+
.. autoexception::
48+
{% for item in exceptions %}
49+
{{ item }}
50+
{%- endfor %}
51+
{% endif %}
52+
{% endblock %}
53+
54+
{% block modules %}
55+
{% if modules %}
56+
.. rubric:: Modules
57+
58+
.. autosummary::
59+
:toctree:
60+
:recursive:
61+
{% for item in modules %}
62+
{{ item }}
63+
{%- endfor %}
64+
{% endif %}
65+
{% endblock %}

docs/_templates/nucleus-module.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{ objname | escape | underline }}
2+
3+
.. automodule:: {{ fullname }}
4+
:members:
5+
:undoc-members:
6+
:show-inheritance:
7+
:inherited-members:
8+
9+
{% block attributes %}
10+
{% if attributes %}
11+
.. rubric:: Module Attributes
12+
13+
.. autoattribute::
14+
{% for item in attributes %}
15+
{{ item }}
16+
{%- endfor %}
17+
{% endif %}
18+
{% endblock %}
19+
20+
{% block functions %}
21+
{% if functions %}
22+
.. rubric:: {{ _('Functions') }}
23+
24+
.. autofunction::
25+
{% for item in functions %}
26+
{{ item }}
27+
{%- endfor %}
28+
{% endif %}
29+
{% endblock %}
30+
31+
{% block classes %}
32+
{% if classes %}
33+
.. rubric:: {{ _('Classes') }}
34+
35+
.. autoclass::
36+
{% for item in classes %}
37+
{{ item }}
38+
{%- endfor %}
39+
{% endif %}
40+
{% endblock %}
41+
42+
{% block exceptions %}
43+
{% if exceptions %}
44+
.. rubric:: {{ _('Exceptions') }}
45+
46+
.. autoexception::
47+
{% for item in exceptions %}
48+
{{ item }}
49+
{%- endfor %}
50+
{% endif %}
51+
{% endblock %}
52+
53+
{% block modules %}
54+
{% if modules %}
55+
.. rubric:: Modules
56+
57+
.. autosummary::
58+
:toctree:
59+
:recursive:
60+
{% for item in modules %}
61+
{{ item }}
62+
{%- endfor %}
63+
{% endif %}
64+
{% endblock %}

docs/api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
API
2+
===
3+
4+
.. autosummary::
5+
:toctree: _autosummary
6+
:template: nucleus-module.rst
7+
:recursive:
8+
9+
nucleus

docs/conf.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
16+
sys.path.insert(0, os.path.abspath("../.."))
17+
18+
19+
# -- Project information -----------------------------------------------------
20+
21+
project = "Nucleus"
22+
copyright = "2021, Scale"
23+
author = "Scale"
24+
25+
# The full version, including alpha/beta/rc tags
26+
from nucleus import __version__ # noqa: E402
27+
28+
release = "v" + str(__version__)
29+
30+
31+
# -- General configuration ---------------------------------------------------
32+
33+
# Add any Sphinx extension module names here, as strings. They can be
34+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
35+
# ones.
36+
extensions = [
37+
"sphinx.ext.autodoc",
38+
"sphinx.ext.autosummary",
39+
]
40+
41+
# Add any paths that contain templates here, relative to this directory.
42+
templates_path = ["_templates"]
43+
44+
# List of patterns, relative to source directory, that match files and
45+
# directories to ignore when looking for source files.
46+
# This pattern also affects html_static_path and html_extra_path.
47+
exclude_patterns = []
48+
49+
50+
# -- Options for HTML output -------------------------------------------------
51+
52+
# The theme to use for HTML and HTML Help pages. See the documentation for
53+
# a list of builtin themes.
54+
#
55+
html_theme = "furo"
56+
57+
# Add any paths that contain custom static files (such as style sheets) here,
58+
# relative to this directory. They are copied after the builtin static files,
59+
# so a file named "default.css" will overwrite the builtin "default.css".
60+
html_static_path = ["_static"]
61+
62+
autosummary_generate = True
63+
autosummary_imported_members = True

0 commit comments

Comments
 (0)