Skip to content

Commit

Permalink
Add "autodocs", code documentation generated from docstrings
Browse files Browse the repository at this point in the history
Adding a new section into "Contribute" page, "Code documentation", and
besides the actual code documenation, I propose moving "Classes" page
there as well.
  • Loading branch information
happz committed May 26, 2023
1 parent 5e70c85 commit 4285f35
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# tmt-specific

/tmp/
docs/autodocs/*.rst
docs/_build
docs/spec
docs/stories
Expand Down
7 changes: 6 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext autodocs

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " autodocs to refresh autodocs generated files"

clean:
rm -rf $(BUILDDIR)/*

autodocs:
rm -f autodocs/*.rst
pushd ../ && sphinx-apidoc --force --implicit-namespaces --no-toc -o docs/autodocs tmt && popd

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
Expand Down
Empty file added docs/autodocs/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,6 @@ Essential Classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. automodule:: tmt
:noindex:
:members:
:undoc-members:
9 changes: 9 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autodoc.typehints',
'sphinx_rtd_theme',
]

Expand Down Expand Up @@ -126,6 +127,14 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# Autodocs & type hints
autodoc_default_flags = ['members', 'undoc-members', 'show-inheritance', 'private-members']
autoclass_content = "both"

autodoc_typehints_format = 'short'
autodoc_typehints_description_target = 'all'
# This one works, but it's a bit uglier than the default value (`signature`).
# autodoc_typehints = 'description'

# -- Options for HTML output ----------------------------------------------

Expand Down
10 changes: 10 additions & 0 deletions docs/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,13 @@ __ https://bodhi.fedoraproject.org/releases/
__ https://github.com/teemtee/tmt/releases/
__ https://pypi.org/project/tmt/
__ https://copr.fedorainfracloud.org/coprs/psss/tmt/builds/


Code documentation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. toctree::
:maxdepth: 1

Overview of important and interesting classes <classes>
Documentation generated from sources <autodocs/tmt.rst>
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ Table of Contents
Stories <stories>
Questions <questions>
Contribute <contribute>
Classes <classes>
Plugins <plugins>

0 comments on commit 4285f35

Please sign in to comment.