Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
428fb836
Commit
428fb836
authored
May 22, 2018
by
peastman
Browse files
Changes to work correctly with latest version of Sphinx
parent
65a1f936
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
.travis.yml
.travis.yml
+1
-1
docs-source/sphinx/autonumber.py
docs-source/sphinx/autonumber.py
+11
-12
No files found.
.travis.yml
View file @
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;
...
...
docs-source/sphinx/autonumber.py
View file @
428fb836
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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment