From 51fb1aa8e0c61787d5ef3100d589c613761679c6 Mon Sep 17 00:00:00 2001 From: jamesb Date: Wed, 24 Mar 2010 21:00:34 +0000 Subject: [PATCH] Make work with latest pyparsing git-svn-id: https://code.ros.org/svn/opencv/trunk@2901 73c94f0f-984f-4a5f-82bc-2d8db8d8ee08 --- opencv/doc/latex2sphinx/go | 1 + opencv/doc/latex2sphinx/latex.py | 7 ++++++- opencv/doc/latex2sphinx/latexparser.py | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/opencv/doc/latex2sphinx/go b/opencv/doc/latex2sphinx/go index 905500d7..57a7863c 100644 --- a/opencv/doc/latex2sphinx/go +++ b/opencv/doc/latex2sphinx/go @@ -1,5 +1,6 @@ #!/bin/bash +mkdir -p c cpp py tput clear python latex.py ../online-opencv.tex || exit diff --git a/opencv/doc/latex2sphinx/latex.py b/opencv/doc/latex2sphinx/latex.py index 948ccb93..1c16cad3 100644 --- a/opencv/doc/latex2sphinx/latex.py +++ b/opencv/doc/latex2sphinx/latex.py @@ -46,6 +46,8 @@ class SphinxWriter: 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: @@ -192,9 +194,12 @@ class SphinxWriter: 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 = "" diff --git a/opencv/doc/latex2sphinx/latexparser.py b/opencv/doc/latex2sphinx/latexparser.py index 17f014f2..c3423400 100644 --- a/opencv/doc/latex2sphinx/latexparser.py +++ b/opencv/doc/latex2sphinx/latexparser.py @@ -44,8 +44,8 @@ ParserElement.setDefaultWhitespaceChars("\n\t") backslash = chr(92) texcmd = Forward() -filler = CharsNotIn(backslash + '\n' + '$') -filler2 = CharsNotIn(backslash + '\n' + '$' + '{}') +filler = CharsNotIn(backslash + '$') +filler2 = CharsNotIn(backslash + '$' + '{}') arg = '[' + CharsNotIn("]") + ']' arg.setParseAction(argfun) @@ -68,8 +68,12 @@ texcmd.setParseAction(texcmdfun) 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 -- 2.39.2