Skip to content

Commit 864cdca

Browse files
committed
docs: update and add changelog
1 parent 1562a34 commit 864cdca

File tree

6 files changed

+104
-6
lines changed

6 files changed

+104
-6
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- setup: migrate to GitHub Actions
44
- setup: migrate to pyproject.toml
55
- docs: remove dependency on old mock standalone library (#19)
6+
- docs: overhaul and add changelog
67
0.3.3
78
- fix: add constant `ZERO_CUTOFF` that defines when a trace average is
89
treated as zero

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
'sphinx.ext.viewcode',
7575
'sphinx.ext.napoleon',
7676
'fancy_include',
77+
'github_changelog',
7778
]
7879

7980

@@ -143,7 +144,7 @@
143144

144145
# The theme to use for HTML and HTML Help pages. See the documentation for
145146
# a list of builtin themes.
146-
html_theme = 'default'
147+
html_theme = 'sphinx_rtd_theme'
147148

148149
# Add any paths that contain custom themes here, relative to this directory.
149150
# html_theme_path = []

docs/extensions/github_changelog.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
"""Display changelog with links to GitHub issues
2+
3+
Usage
4+
-----
5+
The directive
6+
7+
.. include_changelog:: ../CHANGELOG
8+
9+
adds the content of the changelog file into the current document.
10+
References to GitHub issues are identified as "(#XY)" (with parentheses
11+
and hash) and a link is inserted
12+
13+
https://github.com/RI-imaging/{PROJECT}/issues/{XY}
14+
15+
where PROJECT ist the `project` variable defined in conf.py.
16+
"""
17+
import io
18+
import re
19+
20+
from docutils.statemachine import ViewList
21+
from docutils.parsers.rst import Directive
22+
from sphinx.util.nodes import nested_parse_with_titles
23+
from docutils import nodes
24+
25+
26+
class IncludeDirective(Directive):
27+
required_arguments = 1
28+
optional_arguments = 0
29+
30+
def run(self):
31+
full_path = self.arguments[0]
32+
project = self.state.document.settings.env.config.github_project
33+
34+
def insert_github_link(reobj):
35+
line = reobj.string
36+
instr = line[reobj.start():reobj.end()]
37+
issue = instr.strip("#()")
38+
link = "https://github.com/{}/issues/".format(project)
39+
rstlink = "(`#{issue} <{link}{issue}>`_)".format(issue=issue,
40+
link=link)
41+
return rstlink
42+
43+
with io.open(full_path, "r") as myfile:
44+
text = myfile.readlines()
45+
46+
rst = []
47+
for line in text:
48+
line = line.strip("\n")
49+
if line.startswith(" ") and line.strip().startswith("-"):
50+
# list in list:
51+
rst.append("")
52+
if not line.startswith(" "):
53+
rst.append("")
54+
line = "version " + line
55+
rst.append(line)
56+
rst.append("-"*len(line))
57+
elif not line.strip():
58+
rst.append(line)
59+
else:
60+
line = re.sub(r"\(#[0-9]*\)", insert_github_link, line)
61+
rst.append(line)
62+
63+
vl = ViewList(rst, "fakefile.rst")
64+
# Create a node.
65+
node = nodes.section()
66+
node.document = self.state.document
67+
# Parse the rst.
68+
nested_parse_with_titles(self.state, vl, node)
69+
return node.children
70+
71+
72+
def setup(app):
73+
app.add_config_value('github_project', "user/project", 'html')
74+
app.add_directive('include_changelog', IncludeDirective)
75+
return {'version': '0.1'} # identifies the version of our extension

docs/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,46 @@ Summary:
1717
correlate_numpy
1818

1919

20+
.. _sec_ac:
21+
2022
Autocorrelation
2123
---------------
2224
.. autofunction:: autocorrelate
2325

26+
27+
.. _sec_cc:
28+
2429
Cross-correlation
2530
-----------------
2631
.. autofunction:: correlate
2732

33+
34+
.. _sec_cc_numpy:
35+
2836
Cross-correlation (NumPy)
2937
-------------------------
3038
.. autofunction:: correlate_numpy
3139

40+
41+
.. _sec_constants:
42+
3243
Constants
3344
---------
3445
.. autodata:: multipletau.core.ZERO_CUTOFF
3546

47+
48+
.. _sec_examples:
49+
3650
Examples
3751
========
3852
.. fancy_include:: compare_correlation_methods.py
3953

4054

55+
56+
.. _sec_changelog:
57+
58+
Changelog
59+
=========
60+
List of changes in-between nanite releases.
61+
62+
.. include_changelog:: ../CHANGELOG

docs/requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
mock
2-
sphinx==4.3.0
3-
sphinxcontrib.bibtex>=2.0
4-
sphinx_rtd_theme==1.0
1+
sphinx
2+
sphinxcontrib.bibtex
3+
sphinx_rtd_theme
54

multipletau/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
Obtaining multipletau
2525
---------------------
26-
If you have Python and :py:mod:`numpy` installed, simply run
26+
If you have Python and :py:mod:`numpy` installed, simply run::
2727
2828
pip install multipletau
2929

0 commit comments

Comments
 (0)