diff --git a/CHANGES.rst b/CHANGES.rst index da26b9c..2b5c45c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,4 +1,19 @@ +Release 0.3.0 (Dec 9, 2019) +=========================== + +* link line numbers to *.rst.txt + + + +Release 0.2.1 (May 28, 2019) +============================ + +* ... + + + Version 0.1 (2014-12-10) ======================== * Initial upload to PyPi + diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..993b933 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1,9 @@ +0.3.0 + +Update files: + +- VERSION.txt +- setup.py +- CHANGES.rst + +End. \ No newline at end of file diff --git a/setup.py b/setup.py index d1f0d8b..2b4fca8 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from setuptools import setup, find_packages from codecs import open from os import path @@ -14,7 +15,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/development.html#single-sourcing-the-version - version='0.1.0', + version='0.3.0', description='Implement Sphinx directive "ref-targets-list"', long_description=long_description, diff --git a/sphinxcontrib/t3targets.py b/sphinxcontrib/t3targets.py index a31c8a0..d51885e 100644 --- a/sphinxcontrib/t3targets.py +++ b/sphinxcontrib/t3targets.py @@ -12,6 +12,8 @@ """ +from __future__ import absolute_import +from six.moves import range __license__ = """ If not otherwise noted, the extensions in this package are licensed @@ -51,7 +53,11 @@ # http://nullege.com/codes/search/docutils.nodes.reference from docutils import nodes -from sphinx.util.compat import Directive +try: + from sphinx.util.compat import Directive +except ImportError: + from docutils.parsers.rst import Directive + from operator import itemgetter import os @@ -65,7 +71,7 @@ def getRelPath(srcdir, destpath): # Starting from the filepath root, work out how much of the filepath is # shared by base and target. for i in range(min(len(srclist), len(destlist))): - if srclist[i] <> destlist[i]: + if srclist[i] != destlist[i]: break else: # If we broke out of the loop, i is pointing to the first differing @@ -143,18 +149,18 @@ def process_reftargetslist_nodes(app, doctree, fromdocname): classes=['ref-targets-list']) labels = env.domains['std'].data['labels'] anonlabels = env.domains['std'].data['anonlabels'] - for doc in sorted(etc.keys(), key=keyfunc): - relpath = getRelPath(srcdir, doc).replace('\\','/') + for doc in sorted(list(etc.keys()), key=keyfunc): + relpath = getRelPath(srcdir, doc).replace('\\', '/') relpath = os.path.splitext(relpath)[0] + '.html' rstrelpath = os.path.join('_sources', doc) - rstrelpath = getRelPath(srcdir, rstrelpath).replace('\\','/') - rstrelpath = os.path.splitext(rstrelpath)[0] + '.txt' + rstrelpath = getRelPath(srcdir, rstrelpath).replace('\\', '/') + rstrelpath = os.path.splitext(rstrelpath)[0] + '.rst.txt' bullet_list = nodes.bullet_list(rawsource='', bullet='-') for lineno, refid in sorted(etc[doc], key=itemgetter(0)): - if labels.has_key(refid): + if refid in labels: flag = 'label' cntLabels += 1 - elif anonlabels.has_key(refid): + elif refid in anonlabels: flag = 'anonlabel' cntAnonLabels += 1 else: @@ -244,10 +250,10 @@ def doctreeRead(app, doctree): if not hasattr(env, 'ext_targets_cache'): env.ext_targets_cache = {} etc = env.ext_targets_cache - if not etc.has_key(docname): + if docname not in etc: etc[docname] = [] for node in doctree.traverse(nodes.target): - if node.attributes.has_key('refid'): + if 'refid' in node.attributes: etc[docname].append((node.line, node.attributes['refid'])) def setup(app):