Commit 063937fb authored by peastman's avatar peastman
Browse files

Fixed some errors in documentation generation

parent 91bf4fcd
......@@ -17,6 +17,7 @@ import sys, os
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath('../sphinx'))
# -- General configuration -----------------------------------------------------
......@@ -25,7 +26,7 @@ sys.path.insert(0, os.path.abspath('.'))
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['../sphinx/autonumber', '../sphinx/numsec']
extensions = ['autonumber', 'numsec']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
......@@ -63,8 +63,8 @@ install both the drivers and toolkit.
4. (Optional) If you plan to use the CPU platform, it is recommended that you
install FFTW, available from http://www.fftw.org. When configuring it, be sure
to specify single precision and multiple threads (the :code:`--enable-float`
and :code:`--enable-threads` options). OpenMM will still work without FFTW,
to specify single precision and multiple threads (the |--|\ :code:`enable-float`
and |--|\ :code:`enable-threads` options). OpenMM will still work without FFTW,
but the performance of particle mesh Ewald (PME) will be much worse.
5. Launch the Terminal application. Change to the OpenMM directory by typing
......@@ -127,7 +127,7 @@ Installing on Linux
2. Make sure you have Python 2.6 or higher (earlier versions will not work) and
a C++ compiler (typically gcc or clang) installed on your computer. You can
check what version of Python is installed by typing :code:`python --version`
check what version of Python is installed by typing :code:`python` |--|\ :code:`version`
into a console window.
3. (Optional) If you want to run OpenMM on a GPU, install CUDA and/or OpenCL.
......@@ -142,8 +142,8 @@ into a console window.
install FFTW. It is probably available through your systems package manager
such as :code:`yum` or :code:`apt-get`\ . Alternatively, you can download
it from http://www.fftw.org. When configuring it, be sure to specify single
precision and multiple threads (the :code:`--enable-float` and :code
:`--enable-threads` options). OpenMM will still work without FFTW, but the
precision and multiple threads (the |--|\ :code:`enable-float` and
|--|\ :code:`enable-threads` options). OpenMM will still work without FFTW, but the
performance of particle mesh Ewald (PME) will be much worse.
5. In a console window, change to the OpenMM directory by typing
......
from docutils.parsers.rst import roles
from docutils.nodes import Text, reference, section
from sphinx.roles import XRefRole
class autonumber(Text):
pass
class autonumber_ref(reference):
pass
def autonumber_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
return ([autonumber(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:
sections = env.toc_secnumbers[doc]
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:
nextNumber = index[category]+1
else:
nextNumber = 1
if app.config.autonumber_by_chapter:
parent = node.parent
chapter = None
while chapter is None:
if isinstance(parent, section):
chapter = parent
parent = parent.parent
chapter = sectionNumbers[chapter.attributes['ids'][0]][0]
if chapter != lastChapter:
index = {}
newNode = Text('%s %d-%d' % (category, chapter, nextNumber))
lastChapter = chapter
else:
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:
raise ValueError('Unknown target for autonumber reference: '+target)
ref_info.replace_self(Text(refTable[target].astext()))
def setup(app):
app.add_config_value('autonumber_by_chapter', True, False)
roles.register_local_role('autonumber', autonumber_role)
app.add_node(autonumber)
app.add_node(autonumber_ref)
app.add_role('numref', XRefRole(nodeclass=autonumber_ref))
app.connect('doctree-resolved', doctree_resolved)
from docutils.parsers.rst import Directive
from docutils.nodes import compound, raw
class CaptionDirective(Directive):
has_content = True
def run(self):
latexPrefix = raw('', '{\\centering', format='latex')
latexSuffix = raw('', '\\par}\\bigskip', format='latex')
text = '\n'.join(self.content)
content_node = compound(rawsource=text)
self.state.nested_parse(self.content, self.content_offset, content_node)
content_node.attributes['classes'].append('caption')
return [latexPrefix, content_node, latexSuffix]
def setup(app):
app.add_directive('caption', CaptionDirective)
......@@ -17,6 +17,7 @@ import sys, os
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath('../sphinx'))
# -- General configuration -----------------------------------------------------
......@@ -25,7 +26,7 @@ sys.path.insert(0, os.path.abspath('.'))
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.pngmath', 'sphinx.ext.mathjax', 'sphinxcontrib.bibtex', '../sphinx/autonumber', '../sphinx/samepage', '../sphinx/caption', '../sphinx/numsec']
extensions = ['sphinx.ext.pngmath', 'sphinx.ext.mathjax', 'sphinxcontrib.bibtex', 'autonumber', 'samepage', 'caption', 'numsec']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
......@@ -3,3 +3,5 @@
<style> .code {font-family:monospace;} </style>
<style> .caption {text-align:center;} </style>
.. |--| replace:: :option:`--`
......@@ -2490,7 +2490,7 @@ Make sure you have Python 2.6 or later installed. For Python installation
packages and instructions, go to http://python.org. If you do not have the
correct Python version, install a valid version using the default options. Most
versions of Linux and Mac OS X have a suitable Python preinstalled. You can
check by typing \ :code:`python --version`\ in a terminal window.
check by typing \ :code:`python` |--|\ :code:`version`\ in a terminal window.
You must have a C++ compiler to install the OpenMM Python API. If you are using
a Mac, install Apple's Xcode development tools
......
from docutils.parsers.rst import Directive
from docutils.nodes import compound, raw
class SamepageDirective(Directive):
has_content = True
def run(self):
prefix = raw('', '\\par\\begin{samepage}', format='latex')
suffix = raw('', '\\end{samepage}\\par', format='latex')
text = '\n'.join(self.content)
content_node = compound(rawsource=text)
self.state.nested_parse(self.content, self.content_offset, content_node)
return [prefix, content_node, suffix]
def setup(app):
app.add_directive('samepage', SamepageDirective)
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