"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "3bbd3bb9906b725da6a2b4910e258e0cc5c7d767"
Commit 8eedf2be authored by peastman's avatar peastman
Browse files

Fixed deprecation warnings in Python API docs

parent 67450563
...@@ -2,7 +2,7 @@ import re ...@@ -2,7 +2,7 @@ import re
def process_docstring(app, what, name, obj, options, lines): def process_docstring(app, what, name, obj, options, lines):
"""This hook edits the docstrings to replace "<tt><pre>" html tags """This hook edits the docstrings to replace "<tt><pre>" html tags
with sphinx directives. and deprecated markers with sphinx directives.
""" """
def repl(m): def repl(m):
s = m.group(1) s = m.group(1)
...@@ -10,15 +10,19 @@ def process_docstring(app, what, name, obj, options, lines): ...@@ -10,15 +10,19 @@ def process_docstring(app, what, name, obj, options, lines):
s = linesep + s s = linesep + s
newline = '.. code-block:: c++' + linesep newline = '.. code-block:: c++' + linesep
return newline + ' ' + s.replace(linesep, linesep + ' ') return newline + ' ' + s.replace(linesep, linesep + ' ')
def repl2(m):
if name == 'simtk.openmm.openmm.CustomTorsionForce': s = m.group(1)
print(lines) if not s.startswith(linesep):
s = linesep + s
newline = '|LINEBREAK|.. admonition:: Deprecated' + linesep
return newline + ' ' + s.replace(linesep, linesep + ' ')
linesep = '|LINEBREAK|' linesep = '|LINEBREAK|'
joined = linesep.join(lines) joined = linesep.join(lines)
joined = re.sub(r'<tt><pre>((|LINEBREAK|)?.*?)</pre></tt>', repl, joined) joined = re.sub(r'<tt><pre>((|LINEBREAK|)?.*?)</pre></tt>', repl, joined)
joined = re.sub(r'<tt>(.*?)</tt>', repl, joined) joined = re.sub(r'<tt>(.*?)</tt>', repl, joined)
joined = re.sub(r'@deprecated(.*?\|LINEBREAK\|)', repl2, joined, flags=re.IGNORECASE)
lines[:] = [(l if not l.isspace() else '') for l in joined.split(linesep)] lines[:] = [(l if not l.isspace() else '') for l in joined.split(linesep)]
......
...@@ -186,8 +186,7 @@ class Modeller(object): ...@@ -186,8 +186,7 @@ class Modeller(object):
def convertWater(self, model='tip3p'): def convertWater(self, model='tip3p'):
"""Convert all water molecules to a different water model. """Convert all water molecules to a different water model.
@deprecated Use addExtraParticles() instead. It performs the same @deprecated Use addExtraParticles() instead. It performs the same function but in a more general way.
function but in a more general way.
Parameters Parameters
---------- ----------
......
...@@ -74,6 +74,11 @@ def getNodeText(node): ...@@ -74,6 +74,11 @@ def getNodeText(node):
s = "%s%s\n\n" % (s, getNodeText(n)) s = "%s%s\n\n" % (s, getNodeText(n))
elif n.tag == "ref": elif n.tag == "ref":
s = "%s%s" % (s, getNodeText(n)) s = "%s%s" % (s, getNodeText(n))
elif n.tag == "xrefsect":
title = n.find("xreftitle")
description = n.find("xrefdescription")
if title is not None and description is not None and getNodeText(title).lower() == "deprecated":
s = "%s\n@deprecated %s\n\n" % (s, getNodeText(description))
else: else:
if n.tag in docTags: if n.tag in docTags:
tag = docTags[n.tag] tag = docTags[n.tag]
......
...@@ -322,14 +322,14 @@ Parameters: ...@@ -322,14 +322,14 @@ Parameters:
} }
%extend OpenMM::XmlSerializer { %extend OpenMM::XmlSerializer {
%feature(docstring, "This method exists only for backward compatibility. @deprecated Use serialize() instead.") serializeSystem; %feature(docstring, "This method exists only for backward compatibility.\n@deprecated Use serialize() instead.") serializeSystem;
static std::string serializeSystem(const OpenMM::System* object) { static std::string serializeSystem(const OpenMM::System* object) {
std::stringstream ss; std::stringstream ss;
OpenMM::XmlSerializer::serialize<OpenMM::System>(object, "System", ss); OpenMM::XmlSerializer::serialize<OpenMM::System>(object, "System", ss);
return ss.str(); return ss.str();
} }
%feature(docstring, "This method exists only for backward compatibility. @deprecated Use deserialize() instead.") deserializeSystem; %feature(docstring, "This method exists only for backward compatibility.\n@deprecated Use deserialize() instead.") deserializeSystem;
%newobject deserializeSystem; %newobject deserializeSystem;
static OpenMM::System* deserializeSystem(const char* inputString) { static OpenMM::System* deserializeSystem(const char* inputString) {
std::stringstream ss; std::stringstream ss;
......
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