s = ":math:`%s`" % s[1:-1].strip()
elif self.state != 'math':
s.replace('\\_', '_')
+ if len(s) > 0 and s[-1] == '\n':
+ s = s[:-1]
if self.state == 'fpreamble':
self.description += s
else:
return
s = str(c.params[0]).replace('\\_', '_')
s = s.replace('\\par', '')
+ s = s.replace('\n', ' ')
s = s.replace(';', '')
self.indent = 0
- print >>self, ".. cfunction:: " + s + "\n"
+ for proto in s.split('\\newline'):
+ if proto.strip() != "":
+ print >>self, "\n\n.. cfunction:: " + proto.strip() + "\n"
# print >>self, "=", repr(c.params[0].str)
print >>self, ' ' + self.description
self.description = ""
backslash = chr(92)
texcmd = Forward()
-filler = CharsNotIn(backslash + '\n' + '$')
-filler2 = CharsNotIn(backslash + '\n' + '$' + '{}')
+filler = CharsNotIn(backslash + '$')
+filler2 = CharsNotIn(backslash + '$' + '{}')
arg = '[' + CharsNotIn("]") + ']'
arg.setParseAction(argfun)
document = ZeroOrMore(dollarmath | texcmd | filler) + StringEnd().suppress()
if 0:
- s = "\\frac{\\sum_{I, \\, \\texttt{mask}(I) \\ne 0} \\texttt{arr}(I)_c}{N}"
+ s = """Starting from OpenCV 2.0 the new modern C++ interface has been introduced.
+It is crisp (less typing is needed to code the same thing), type-safe
+and, in general, more convenient to use. Here is a short example of what it looks like:"""
print s
+ print filler.parseString(s)
+ sys.exit(-1)
for t in document.parseString(s):
if isinstance(t, TexCmd):
print '====> cmd=[%s]' % t.cmd, t