Unverified Commit a885a6ae authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2080 from peastman/sphinx

Changes to work correctly with latest version of Sphinx
parents 65a1f936 428fb836
......@@ -182,7 +182,7 @@ script:
- python devtools/run-ctest.py --start-time $START_TIME
- if [[ ! -z "${DOCS_DEPLOY}" && "${DOCS_DEPLOY}" = "true" ]]; then
pip install sphinx==1.5.6 sphinxcontrib-bibtex sphinxcontrib-lunrsearch sphinxcontrib-autodoc_doxygen;
pip install sphinx sphinxcontrib-bibtex sphinxcontrib-lunrsearch sphinxcontrib-autodoc_doxygen;
make sphinxhtml;
make sphinxpdf;
make C++ApiDocs PythonApiDocs;
......
from docutils.parsers.rst import roles
from docutils.nodes import Text, reference, section
from docutils.nodes import Text, reference, section, label
from sphinx.roles import XRefRole
class autonumber(Text):
class autonumber(label):
pass
class autonumber_ref(reference):
pass
def autonumber_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return ([autonumber(text)], [])
return ([autonumber(text=text)], [])
def doctree_resolved(app, doctree, docname):
index = {};
refTable = {}
if app.config.autonumber_by_chapter:
# Record the number of each chapter
env = app.builder.env
sectionNumbers = {}
for doc in env.toc_secnumbers:
......@@ -24,9 +24,9 @@ def doctree_resolved(app, doctree, docname):
for sectionId in sections:
sectionNumbers[sectionId[1:]] = sections[sectionId]
lastChapter = -1
# Assign numbers to all the autonumbered objects.
for node in doctree.traverse(autonumber):
category = node.astext().split(',')[0]
if category in index:
......@@ -47,13 +47,13 @@ def doctree_resolved(app, doctree, docname):
newNode = Text('%s %d-%d' % (category, chapter, nextNumber))
lastChapter = chapter
else:
newNode = Text('%s %d' % (category, nextNumber))
newNode = Text('%s %d' % (category, nextNumber))
index[category] = nextNumber
refTable[node.astext()] = newNode
node.parent.replace(node, newNode)
# Replace references with the name of the referenced object
for ref_info in doctree.traverse(autonumber_ref):
target = ref_info['reftarget']
if target not in refTable:
......@@ -68,4 +68,3 @@ def setup(app):
app.add_role('autonumref', XRefRole(nodeclass=autonumber_ref))
app.connect('doctree-resolved', doctree_resolved)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment