Skip to content

Commit

Permalink
docs: automate API docs
Browse files Browse the repository at this point in the history
Automatically create pages in the API docs section using sphinx-autodoc. This is added as an event handler in conf.py.
  • Loading branch information
danth committed Apr 8, 2020
1 parent af24bc2 commit 7d4fea2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 107 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -59,6 +59,7 @@ coverage.xml

# Sphinx documentation
docs/_build/
docs/api/

# PyBuilder
target/
Expand Down
7 changes: 0 additions & 7 deletions docs/api/modules.rst

This file was deleted.

30 changes: 0 additions & 30 deletions docs/api/semantic_release.history.rst

This file was deleted.

69 changes: 0 additions & 69 deletions docs/api/semantic_release.rst

This file was deleted.

23 changes: 23 additions & 0 deletions docs/conf.py
Expand Up @@ -35,6 +35,29 @@
htmlhelp_basename = 'python-semantic-releasedoc'


# -- Automatically run sphinx-apidoc --------------------------------------

def run_apidoc(_):
from sphinx import apidoc

docs_path = os.path.dirname(__file__)
apidoc_path = os.path.join(docs_path, 'api')
module_path = os.path.join(docs_path, '..', 'semantic_release')

apidoc.main([
'--force',
'--module-first',
'--separate',
'-d', '3',
'-o', apidoc_path,
module_path
])


def setup(app):
app.connect('builder-inited', run_apidoc)


# -- Options for LaTeX output ---------------------------------------------
latex_documents = [
('index', 'python-semantic-release.tex', u'python-semantic-release Documentation',
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Expand Up @@ -55,6 +55,6 @@ Documentation Contents
Automatic releases <automatic-releases/index>
Configuration <configuration>
Environment Variables <envvars>
API docs <api/semantic_release>
API docs <api/modules>
Troubleshooting <troubleshooting>
Contributors <contributors>

0 comments on commit 7d4fea2

Please sign in to comment.