Commit c65757f6 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Document

parent 82e6bcd0
"""
The function of this script is to render the Jinja2 templates in the current
directory into input files for sphinx. It introspects the OpenMM Python module
to find all of the classes and formats them for inclusion into the templates.
"""
from os.path import dirname, join, splitext from os.path import dirname, join, splitext
from glob import glob from glob import glob
import inspect import inspect
import jinja2 import jinja2
import simtk.openmm as mm import simtk.openmm.openmm
from simtk.openmm import app import simtk.openmm.app
def fullname(klass): def fullname(klass):
return klass.__module__ + '.' + klass.__name__ return klass.__module__ + '.' + klass.__name__
# 'integrators': [],
# 'library_extras': [],
# 'forces': [],
def library_template_variables(): def library_template_variables():
"""Create the data structure available to the Jinja2 renderer when
filling in the templates.
This function extracts all of classes in ``simtk.openmm.openmm`` and returns
a dictionary with them grouped into three lists, the integrators, the forces,
and the remainder (library_extras).
A couple core classes are skipped, because they're included manually in the
template.
"""
data = { data = {
'integrators': [], 'integrators': [],
'library_extras': [],
'forces': [], 'forces': [],
'library_extras': [],
} }
mm_klasses = inspect.getmembers(mm, predicate=inspect.isclass) mm_klasses = inspect.getmembers(simtk.openmm.openmm, predicate=inspect.isclass)
# gather all Force subclasses # gather all Force subclasses
for name, klass in mm_klasses: for name, klass in mm_klasses:
...@@ -34,10 +45,14 @@ def library_template_variables(): ...@@ -34,10 +45,14 @@ def library_template_variables():
data['integrators'].append(fullname(klass)) data['integrators'].append(fullname(klass))
# gather all extra subclasses in simtk.openmm.openmm # gather all extra subclasses in simtk.openmm.openmm
# core classes that are already included in library.rst.jinja2
exclude = ['simtk.openmm.openmm.Platform', 'simtk.openmm.openmm.Context', exclude = ['simtk.openmm.openmm.Platform', 'simtk.openmm.openmm.Context',
'simtk.openmm.openmm.System', 'simtk.openmm.openmm.State'] 'simtk.openmm.openmm.System', 'simtk.openmm.openmm.State']
exclude.extend(data['forces']) exclude.extend(data['forces'])
exclude.extend(data['integrators']) exclude.extend(data['integrators'])
# these classes are useless and not worth documenting.
exclude.extend([ exclude.extend([
'simtk.openmm.openmm.SwigPyIterator', 'simtk.openmm.openmm.SwigPyIterator',
'simtk.openmm.openmm.OpenMMException']) 'simtk.openmm.openmm.OpenMMException'])
...@@ -51,13 +66,23 @@ def library_template_variables(): ...@@ -51,13 +66,23 @@ def library_template_variables():
def app_template_variables(): def app_template_variables():
"""Create the data structure available to the Jinja2 renderer when
filling in the templates.
This function extracts all of classes in ``simtk.openmm.app`` and returns
a dictionary with them grouped into three lists, the reporters, the
classes with the word "File" in the name, and the remainder.
Four classes are skipped (see exclude), because they're included manually
in the template.
"""
data = { data = {
'reporters': [], 'reporters': [],
'fileclasses': [], 'fileclasses': [],
'app_extras': [], 'app_extras': [],
} }
app_klasses = inspect.getmembers(app, predicate=inspect.isclass) app_klasses = inspect.getmembers(simtk.openmm.app, predicate=inspect.isclass)
# gather all Reporters # gather all Reporters
for name, klass in app_klasses: for name, klass in app_klasses:
......
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