Skip to content

Commit

Permalink
test documentation docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianp committed Sep 15, 2023
1 parent c488cd9 commit 7737fda
Show file tree
Hide file tree
Showing 7 changed files with 282 additions and 225 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
set -xe
pip install --upgrade pip setuptools wheel
pip install -r docs/requirements.txt
- name: Build documentation
- name: Test examples and docstrings
run: |
set -xe
python -VV
cd docs && make clean && make html
make doctest
11 changes: 8 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
SPHINXOPTS = -d $(BUILDDIR)/doctrees -T

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
.PHONY: help Makefile doctest

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand All @@ -25,6 +25,11 @@ clean:
rm -rf _autosummary/

html-noplot:
$(SPHINXBUILD) -D plot_gallery=0 -D jupyter_execute_notebooks=off -b html $(ALLSPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html
$(SPHINXBUILD) -D plot_gallery=0 -D jupyter_execute_notebooks=off -b html $(SPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

doctest:
$(SPHINXBUILD) -b doctest $(SPHINXOPTS) . $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@
'sphinx.ext.napoleon', # napoleon on top of autodoc: https://stackoverflow.com/a/66930447 might correct some warnings
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'matplotlib.sphinxext.plot_directive',
'sphinx_autodoc_typehints',
'myst_nb',
"sphinx_remove_toctrees",
'sphinx_remove_toctrees',
'sphinx_rtd_theme',
'sphinx_gallery.gen_gallery',
'sphinx_copybutton',
Expand All @@ -70,7 +71,12 @@
"backreferences_dir": os.path.join("modules", "generated"),
}

# Specify how to identify the prompt when copying code snippets
copybutton_prompt_text = r">>> |\.\.\. "
copybutton_prompt_is_regexp = True
copybutton_exclude = "style"

trim_doctests_flags = True
source_suffix = ['.rst', '.ipynb', '.md']

autosummary_generate = True
Expand Down
Loading

0 comments on commit 7737fda

Please sign in to comment.