Skip to content

Commit

Permalink
docs: fix missing changelog files
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 28, 2019
1 parent b1c69fd commit 2c1e08a
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.7.1
- docs: fix missing changelog files
0.7.0
- feat: added command-line entry point "qpinfo"
- feat: support subjoined QPSeries file format
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ qpformat
|PyPI Version| |Tests Status| |Coverage Status| |Docs Status|


**qpformat** is a Python3 library for opening quantitative phase imaging data file formats.
**qpformat** is a Python library for opening quantitative phase imaging
data file formats.


Documentation
-------------

The documentation, including the reference and examples, is available at `qpformat.readthedocs.io <https://qpformat.readthedocs.io/en/stable/>`__.
The documentation, including the reference and examples, is available at
`qpformat.readthedocs.io <https://qpformat.readthedocs.io/en/stable/>`__.


Installation
Expand Down
75 changes: 75 additions & 0 deletions docs/extensions/github_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Display changelog with links to GitHub issues
Usage
-----
The directive
.. include_changelog:: ../CHANGELOG
adds the content of the changelog file into the current document.
References to GitHub issues are identified as "(#XY)" (with parentheses
and hash) and a link is inserted
https://github.com/RI-imaging/{PROJECT}/issues/{XY}
where PROJECT ist the `project` variable defined in conf.py.
"""
import io
import re

from docutils.statemachine import ViewList
from docutils.parsers.rst import Directive
from sphinx.util.nodes import nested_parse_with_titles
from docutils import nodes


class IncludeDirective(Directive):
required_arguments = 1
optional_arguments = 0

def run(self):
full_path = self.arguments[0]
project = self.state.document.settings.env.config.github_project

def insert_github_link(reobj):
line = reobj.string
instr = line[reobj.start():reobj.end()]
issue = instr.strip("#()")
link = "https://github.com/{}/issues/".format(project)
rstlink = "(`#{issue} <{link}{issue}>`_)".format(issue=issue,
link=link)
return rstlink

with io.open(full_path, "r") as myfile:
text = myfile.readlines()

rst = []
for line in text:
line = line.strip("\n")
if line.startswith(" ") and line.strip().startswith("-"):
# list in list:
rst.append("")
if not line.startswith(" "):
rst.append("")
line = "version " + line
rst.append(line)
rst.append("-"*len(line))
elif not line.strip():
rst.append(line)
else:
line = re.sub(r"\(#[0-9]*\)", insert_github_link, line)
rst.append(line)

vl = ViewList(rst, "fakefile.rst")
# Create a node.
node = nodes.section()
node.document = self.state.document
# Parse the rst.
nested_parse_with_titles(self.state, vl, node)
return node.children


def setup(app):
app.add_config_value('github_project', "user/project", 'html')
app.add_directive('include_changelog', IncludeDirective)
return {'version': '0.1'} # identifies the version of our extension
6 changes: 6 additions & 0 deletions docs/sec_changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=========
Changelog
=========
List of changes in-between qpformat releases.

.. include_changelog:: ../CHANGELOG

0 comments on commit 2c1e08a

Please sign in to comment.