Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
marble committed Dec 9, 2019
2 parents 492f28c + 91f82aa commit 14a9ec9
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
0.3.0

Update files:

- VERSION.txt
- setup.py
- CHANGES.rst

End.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
from setuptools import setup, find_packages
from codecs import open
from os import path
Expand All @@ -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,
Expand Down
26 changes: 16 additions & 10 deletions sphinxcontrib/t3targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 14a9ec9

Please sign in to comment.