Commit 292f9ab5 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Fix install

parent 22784f48
...@@ -5,6 +5,7 @@ file(GLOB STAGING_INPUT_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" ...@@ -5,6 +5,7 @@ file(GLOB STAGING_INPUT_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"index.rst" "index.rst"
"render.py" "render.py"
"conf.py" "conf.py"
"process-docstring.py"
"_static/logo.png" "_static/logo.png"
"_templates/class.rst" "_templates/class.rst"
) )
...@@ -35,6 +36,7 @@ add_custom_command( ...@@ -35,6 +36,7 @@ add_custom_command(
COMMAND "${PYTHON_EXECUTABLE}" -m sphinx . "${CMAKE_BINARY_DIR}/api-python" COMMAND "${PYTHON_EXECUTABLE}" -m sphinx . "${CMAKE_BINARY_DIR}/api-python"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/conf.py" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/conf.py"
"${CMAKE_CURRENT_BINARY_DIR}/process-docstring.py"
"${CMAKE_CURRENT_BINARY_DIR}/app.rst" "${CMAKE_CURRENT_BINARY_DIR}/app.rst"
"${CMAKE_CURRENT_BINARY_DIR}/library.rst" "${CMAKE_CURRENT_BINARY_DIR}/library.rst"
"${CMAKE_CURRENT_BINARY_DIR}/index.rst" "${CMAKE_CURRENT_BINARY_DIR}/index.rst"
...@@ -44,7 +46,7 @@ add_custom_command( ...@@ -44,7 +46,7 @@ add_custom_command(
) )
add_custom_target(PythonApiDocs DEPENDS ${CMAKE_BINARY_DIR}/api-python/index.html) add_custom_target(PythonApiDocs DEPENDS ${CMAKE_BINARY_DIR}/api-python/index.html)
INSTALL(DIRECTORY "${PROJECT_BINARY_DIR}/api-python/" INSTALL(DIRECTORY "${CMAKE_BINARY_DIR}/api-python/"
DESTINATION "docs/api-python/") DESTINATION "docs/api-python/")
INSTALL(FILES "Python API Reference.html" INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../Python API Reference.html"
DESTINATION "docs/") DESTINATION "docs/")
...@@ -5,7 +5,7 @@ import os ...@@ -5,7 +5,7 @@ import os
import simtk.openmm.version import simtk.openmm.version
extensions = ['sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinx.ext.autosummary', extensions = ['sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinx.ext.autosummary',
'sphinx.ext.autodoc', 'numpydoc',] 'sphinx.ext.autodoc', 'numpydoc', 'process-docstring']
autosummary_generate = True autosummary_generate = True
autodoc_default_flags = ['members', 'inherited-members'] autodoc_default_flags = ['members', 'inherited-members']
......
import re
def process_docstring(app, what, name, obj, options, lines):
"""This hook edits the docstrings to replace "<tt><pre>" html tags
with sphinx directives.
"""
def repl(m):
s = m.group(1)
if not s.startswith(linesep):
s = linesep + s
newline = '.. code-block:: c++' + linesep
return newline + ' ' + s.replace(linesep, linesep + ' ')
if name == 'simtk.openmm.openmm.CustomTorsionForce':
print(lines)
linesep = '|LINEBREAK|'
joined = linesep.join(lines)
joined = re.sub(r'<tt><pre>((|LINEBREAK|)?.*?)</pre></tt>', repl, joined)
joined = re.sub(r'<tt>(.*?)</tt>', repl, joined)
lines[:] = [(l if not l.isspace() else '') for l in joined.split(linesep)]
def setup(app):
app.connect('autodoc-process-docstring', process_docstring)
def test():
lines = ['Hello World', '<tt><pre>', 'contents', '</pre></tt>', '', '<tt>contents2</tt>']
linesRef = ['Hello World', '.. code-block:: c++', '', ' contents', '', '', '.. code-block:: c++', '', ' contents2']
process_docstring(None, None, None, None, None, lines)
assert lines == linesRef
if __name__ == '__main__':
test()
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