Skip to content

Commit 2ed6419

Browse files
[DOCUMENTATION] debugged sphinx build feature
1 parent 381efc7 commit 2ed6419

File tree

8 files changed

+130
-52
lines changed

8 files changed

+130
-52
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
License - MIT
1+
# License - MIT
22

33
Copyright (c) 2017-2024 Mr. Walls
44

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ cleanup:
136136

137137
clean: cleanup
138138
$(QUIET)rm -f test-results/junit.xml 2>/dev/null || true
139-
$(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>/dev/null || true
139+
$(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean || true
140140
$(QUIET)$(ECHO) "$@: Done."
141141

142142
must_be_root:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ make test-tox ; # runs the tox tests
7070
make clean ; # cleans up for next test
7171
```
7272

73+
# Documentation
74+
75+
For more details read the project [documentation](./docs/index).
76+
7377
# Next steps:
7478

7579
Like automation? Then integrate away, this template can take it!

docs/Makefile

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
5+
SPHINXOPTS = -c ../docs/ -v
66
SPHINXBUILD = sphinx-build
77
PAPER =
88
BUILDDIR = _build
9+
SRCDIR = .
10+
# change this to the directory you store python code in
11+
PROJECT_DOC_SRC_DIR = "pythonrepo"
912

1013
# Internal variables.
1114
PAPEROPT_a4 = -D latex_paper_size=a4
1215
PAPEROPT_letter = -D latex_paper_size=letter
13-
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
16+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
1417
# the i18n builder cannot share the environment and doctrees with the others
15-
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
18+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
1619

17-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
20+
.PHONY: help init clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
1821

1922
help:
2023
@echo "Please use \`make <target>' where <target> is one of"
@@ -38,41 +41,52 @@ help:
3841
@echo " linkcheck to check all external links for integrity"
3942
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
4043

44+
init:
45+
@ln -sf ../"$(PROJECT_DOC_SRC_DIR)" $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)"
46+
@ln -sf ../tests $(SRCDIR)/tests 2>/dev/null || true
47+
@ln -sf ../README.md $(SRCDIR)/README.md
48+
@ln -sf ../LICENSE.md $(SRCDIR)/LICENSE.md
49+
4150
clean:
4251
@-rm -rf $(BUILDDIR)/* 2>/dev/null || true
52+
@-rm -rfRd $(SRCDIR)/apidocs/* 2>/dev/null || true
53+
@-unlink $(SRCDIR)/README.md 2>/dev/null || true
54+
@-unlink $(SRCDIR)/tests 2>/dev/null || true
55+
@-unlink $(SRCDIR)/LICENSE.md 2>/dev/null || true
56+
@-unlink $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)" 2>/dev/null || true
4357

44-
html:
58+
html: init
4559
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
4660
@echo
4761
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
4862

49-
dirhtml:
63+
dirhtml: init
5064
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
5165
@echo
5266
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
5367

54-
singlehtml:
68+
singlehtml: init
5569
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
5670
@echo
5771
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
5872

59-
pickle:
73+
pickle: init
6074
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
6175
@echo
6276
@echo "Build finished; now you can process the pickle files."
6377

64-
json:
78+
json: init
6579
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
6680
@echo
6781
@echo "Build finished; now you can process the JSON files."
6882

69-
htmlhelp:
83+
htmlhelp: init
7084
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
7185
@echo
7286
@echo "Build finished; now you can run HTML Help Workshop with the" \
7387
".hhp project file in $(BUILDDIR)/htmlhelp."
7488

75-
qthelp:
89+
qthelp: init
7690
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
7791
@echo
7892
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
@@ -81,7 +95,7 @@ qthelp:
8195
@echo "To view the help file:"
8296
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc"
8397

84-
devhelp:
98+
devhelp: init
8599
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
86100
@echo
87101
@echo "Build finished."
@@ -90,12 +104,12 @@ devhelp:
90104
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample"
91105
@echo "# devhelp"
92106

93-
epub:
107+
epub: init
94108
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
95109
@echo
96110
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
97111

98-
latex:
112+
latex: init
99113
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
100114
@echo
101115
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@@ -108,35 +122,35 @@ latexpdf:
108122
$(MAKE) -C $(BUILDDIR)/latex all-pdf
109123
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
110124

111-
text:
125+
text: init
112126
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
113127
@echo
114128
@echo "Build finished. The text files are in $(BUILDDIR)/text."
115129

116-
man:
130+
man: init
117131
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
118132
@echo
119133
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
120134

121-
texinfo:
135+
texinfo: init
122136
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
123137
@echo
124138
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
125139
@echo "Run \`make' in that directory to run these through makeinfo" \
126140
"(use \`make info' here to do that automatically)."
127141

128-
info:
142+
info: init
129143
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
130144
@echo "Running Texinfo files through makeinfo..."
131145
make -C $(BUILDDIR)/texinfo info
132146
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
133147

134-
gettext:
148+
gettext: init
135149
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
136150
@echo
137151
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
138152

139-
changes:
153+
changes: init
140154
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
141155
@echo
142156
@echo "The overview file is in $(BUILDDIR)/changes."
@@ -147,7 +161,7 @@ linkcheck:
147161
@echo "Link check complete; look for any errors in the above output " \
148162
"or in $(BUILDDIR)/linkcheck/output.txt."
149163

150-
doctest:
164+
doctest: init
151165
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152166
@echo "Testing of doctests in the sources finished, look at the " \
153167
"results in $(BUILDDIR)/doctest/output.txt."

docs/conf.py

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,48 @@
1818
# If extensions (or modules to document with autodoc) are in another directory,
1919
# add these directories to sys.path here. If the directory is relative to the
2020
# documentation root, use os.path.abspath to make it absolute, like shown here.
21-
sys.path.insert(0, os.path.abspath('../pythonrepo'))
21+
sys.path.insert(0, os.path.abspath('../'))
22+
sys.path.insert(1, os.path.abspath('./pythonrepo'))
2223

2324
# -- General configuration -----------------------------------------------------
2425

2526
# If your documentation needs a minimal Sphinx version, state it here.
26-
needs_sphinx = '4.0'
27+
needs_sphinx = '5.3'
2728

2829
# Add any Sphinx extension module names here, as strings. They can be extensions
2930
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
31+
# for md us 'autodoc2' (pip install sphinx-autodoc2)
32+
# for rst use 'sphinx.ext.autodoc'
3033
extensions = [
31-
'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.githubpages',
34+
'sphinx.ext.napoleon', 'autodoc2', 'sphinx.ext.autosummary',
35+
'sphinx.ext.githubpages',
3236
'sphinx.ext.autosummary', 'sphinx.ext.doctest', 'sphinx.ext.todo',
33-
'sphinx.ext.linkcode', 'sphinx.ext.viewcode'
37+
'sphinx.ext.linkcode', 'sphinx.ext.viewcode', 'myst_parser'
3438
]
3539

40+
# for md auto-docs
41+
autodoc2_packages = [
42+
"pythonrepo",
43+
"tests",
44+
]
45+
46+
autodoc2_render_plugin = "myst"
47+
3648
# Add any paths that contain templates here, relative to this directory.
3749
templates_path = ['_templates']
3850

3951
# The suffix of source filenames.
4052
source_suffix = {
41-
'.rst': 'restructuredtext',
4253
'.md': 'markdown',
54+
'.txt': 'markdown',
55+
'.rst': 'restructuredtext',
4356
}
4457

4558
# The encoding of source files. Official sphinx docs reccomend utf-8-sig.
4659
source_encoding = 'utf-8-sig'
4760

4861
# The master toctree document.
49-
master_doc = 'index'
62+
master_doc = 'toc'
5063

5164
# General information about the project.
5265
project = u'python_template'
@@ -74,7 +87,7 @@
7487

7588
# List of patterns, relative to source directory, that match files and
7689
# directories to ignore when looking for source files.
77-
exclude_patterns = ['_build', '.github/', '.circleci/', 'dist', 'tests']
90+
exclude_patterns = ['_build', '.github', '.circleci', '.DS_Store', '**/.git', 'dist', 'tests']
7891

7992
# The reST default role (used for this markup: `text`) to use for all documents.
8093
# default_role = None
@@ -86,22 +99,28 @@
8699
# unit titles (such as .. function::).
87100
add_module_names = True
88101

102+
# sigs should not have backslashes
103+
strip_signature_backslash = True
104+
89105
# If true, sectionauthor and moduleauthor directives will be shown in the
90106
# output. They are ignored by default.
91-
show_authors = False
107+
show_authors = True
92108

93109
# The name of the Pygments (syntax highlighting) style to use.
110+
# pygments_style = 'py'
94111
pygments_style = 'default'
95112

96113
# A list of ignored prefixes for module index sorting.
97114
# modindex_common_prefix = []
98115

116+
# Create table of contents entries for domain objects (e.g. functions, classes, attributes, etc.).
117+
toc_object_entries = True
99118

100119
# -- Options for HTML output ---------------------------------------------------
101120

102121
# The theme to use for HTML and HTML Help pages. See the documentation for
103122
# a list of builtin themes.
104-
html_theme = 'default'
123+
html_theme = 'sphinxawesome_theme'
105124

106125
# Theme options are theme-specific and customize the look and feel of a theme
107126
# further. For a list of options available for each theme, see the
@@ -116,7 +135,7 @@
116135
# html_title = None
117136

118137
# A shorter title for the navigation bar. Default is the same as html_title.
119-
# html_short_title = None
138+
html_short_title = 'Project Docs'
120139

121140
# The name of an image file (relative to this directory) to place at the top
122141
# of the sidebar.
@@ -127,6 +146,8 @@
127146
# pixels large.
128147
# html_favicon = None
129148

149+
html_permalinks_icon = '<span>#</span>'
150+
130151
# Add any paths that contain custom static files (such as style sheets) here,
131152
# relative to this directory. They are copied after the builtin static files,
132153
# so a file named "default.css" will overwrite the builtin "default.css".
@@ -177,6 +198,29 @@
177198
htmlhelp_basename = 'python_repo_doc'
178199

179200

201+
# -- Options for MyST markdown parser -------------------------------------------
202+
# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#syntax-directives
203+
204+
# be more like GFM with style
205+
myst_enable_extensions = set(['tasklist', 'strikethrough', 'fieldlist'])
206+
207+
# for GFM diagrams and interoperability with other Markdown renderers
208+
myst_fence_as_directive = set(('mermaid', 'suggestion', 'note'))
209+
210+
# Focus only on github markdown
211+
myst_gfm_only = False
212+
213+
214+
#heading_anchors = 1
215+
216+
# -- Options for napoleon ext --------------------------------------------------
217+
218+
# include __init__ when it has docstrings
219+
napoleon_include_init_with_doc = True
220+
221+
# try to be smarter
222+
napoleon_preprocess_types = True
223+
180224
# -- Options for LaTeX output --------------------------------------------------
181225

182226
latex_elements = {}
@@ -266,3 +310,12 @@
266310

267311
# How to display URL addresses: 'footnote', 'no', or 'inline'.
268312
# texinfo_show_urls = 'footnote'
313+
314+
# -- Link resolver -------------------------------------------------------------
315+
def linkcode_resolve(domain, info):
316+
if domain != 'py':
317+
return None
318+
if not info['module']:
319+
return None
320+
filename = info['module'].replace('.', '/')
321+
return "https://github.com/reactive-firewall/python-repo/blob/stable/%s.py" % filename

docs/index.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/toc.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Welcome to Python Repo' documentation!
2+
3+
## Contents:
4+
5+
```{toctree}
6+
:maxdepth: 3
7+
apidocs/index
8+
/README.md
9+
/setup.py
10+
/LICENSE.md
11+
:Name: Documentation
12+
/
13+
```
14+
15+
## Overview
16+
17+
```{autosummary}
18+
```
19+
20+
21+
## Quickstart:
22+
23+
more filler text

0 commit comments

Comments
 (0)