diff --git a/modules/java/generator/rst_parser.py b/modules/java/generator/rst_parser.py index a8d3fbf354..dc8e978e75 100644 --- a/modules/java/generator/rst_parser.py +++ b/modules/java/generator/rst_parser.py @@ -172,6 +172,7 @@ class RstParser(object): capturing_seealso = False skip_code_lines = False expected_brief = True + was_code_line = False fdecl = DeclarationParser() pdecl = ParamParser() @@ -201,17 +202,21 @@ class RstParser(object): # skip lines if line-skipping mode is activated if skip_code_lines: - if not l or l.startswith(" "): - continue + if not l: + continue + if l.startswith(" "): + None else: skip_code_lines = False if ll.startswith(".. code-block::") or ll.startswith(".. image::"): skip_code_lines = True + continue # todo: parse structure members; skip them for now if ll.startswith(".. ocv:member::"): + #print ll skip_code_lines = True continue @@ -223,6 +228,7 @@ class RstParser(object): expected_brief = False elif ll.endswith("::"): # turn on line-skipping mode for code fragments + #print ll skip_code_lines = True ll = ll[:len(ll)-2] @@ -286,9 +292,20 @@ class RstParser(object): continue # record other lines as long description - func["long"] = func.get("long", "") + "\n" + ll - if skip_code_lines: - func["long"] = func.get("long", "") + "\n" + if (skip_code_lines): + ll = ll.replace("/*", "/ *") + ll = ll.replace("*/", "* /") + if (was_code_line): + func["long"] = func.get("long", "") + "\n" + ll + "\n" + else: + was_code_line = True; + func["long"] = func.get("long", "") + ll +"\n\n\n // C++ code:\n\n" + else: + if (was_code_line): + func["long"] = func.get("long", "") + "\n" + ll + "\n\n"; + was_code_line = False; + else: + func["long"] = func.get("long", "") + "\n" + ll # endfor l in lines if fdecl.balance != 0: