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
04f68ba4
Commit
04f68ba4
authored
Jul 07, 2015
by
Robert McGibbon
Browse files
Prettify some of the docstrings
parent
532f2bd6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
9 deletions
+48
-9
wrappers/python/src/swig_doxygen/OpenMM.i
wrappers/python/src/swig_doxygen/OpenMM.i
+2
-0
wrappers/python/src/swig_doxygen/swigInputBuilder.py
wrappers/python/src/swig_doxygen/swigInputBuilder.py
+46
-9
No files found.
wrappers/python/src/swig_doxygen/OpenMM.i
View file @
04f68ba4
%
module
openmm
%
include
"factory.i"
%
include
"factory.i"
%
include
"std_string.i"
%
include
"std_string.i"
%
include
"std_iostream.i"
%
include
"std_iostream.i"
...
...
wrappers/python/src/swig_doxygen/swigInputBuilder.py
View file @
04f68ba4
...
@@ -13,7 +13,43 @@ import getopt
...
@@ -13,7 +13,43 @@ import getopt
import
re
import
re
import
xml.etree.ElementTree
as
etree
import
xml.etree.ElementTree
as
etree
#
try
:
from
html.parser
import
HTMLParser
except
ImportError
:
# python 2
from
HTMLParser
import
HTMLParser
def
striphtmltags
(
s
):
"""Strip a couple html tags used inside docstrings in the C++ source
to produce something more easily read as plain text.
"""
class
ConvertLists
(
HTMLParser
):
def
reset
(
self
):
super
(
ConvertLists
,
self
).
reset
()
self
.
out
=
[]
def
handle_starttag
(
self
,
tag
,
attrs
):
if
tag
==
'li'
:
self
.
out
.
append
(
'
\n
- '
)
def
handle_data
(
self
,
data
):
self
.
out
.
append
(
data
.
strip
())
convertlists
=
ConvertLists
()
def
replace_ul_tags
(
m
):
a
,
b
=
m
.
span
()
sub
=
s
[
a
:
b
]
convertlists
.
reset
()
convertlists
.
feed
(
sub
)
return
'
\n
%s
\n\n
'
%
''
.
join
(
convertlists
.
out
)
s
=
re
.
sub
(
'\s*(<ul>.*</ul>\s*)'
,
replace_ul_tags
,
s
,
flags
=
re
.
MULTILINE
|
re
.
DOTALL
)
s
=
s
.
replace
(
'<i>'
,
'_'
)
s
=
s
.
replace
(
'</i>'
,
'_'
)
return
s
INDENT
=
" "
;
INDENT
=
" "
;
...
@@ -266,6 +302,7 @@ class SwigInputBuilder:
...
@@ -266,6 +302,7 @@ class SwigInputBuilder:
dNode
=
classNode
.
find
(
'detaileddescription'
)
dNode
=
classNode
.
find
(
'detaileddescription'
)
if
dNode
is
not
None
:
if
dNode
is
not
None
:
docstring
=
getNodeText
(
dNode
).
strip
().
replace
(
'"'
,
'
\\
"'
)
docstring
=
getNodeText
(
dNode
).
strip
().
replace
(
'"'
,
'
\\
"'
)
docstring
=
striphtmltags
(
docstring
)
self
.
fOutDocstring
.
write
(
'%%feature("docstring") %s "%s";
\n
'
%
(
className
,
docstring
))
self
.
fOutDocstring
.
write
(
'%%feature("docstring") %s "%s";
\n
'
%
(
className
,
docstring
))
self
.
fOut
.
write
(
"class %s"
%
className
)
self
.
fOut
.
write
(
"class %s"
%
className
)
if
className
in
self
.
configModule
.
MISSING_BASE_CLASSES
:
if
className
in
self
.
configModule
.
MISSING_BASE_CLASSES
:
...
...
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