diff --git a/doc/Makefile b/doc/Makefile index 238bd1a44..0c9d94d42 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -117,7 +117,8 @@ $(manual-xmls): %.xml: %.raw.xml $(SCRIPTS_DIR)/fixes.xslt xsltproc --output $@ $(SCRIPTS_DIR)/fixes.xslt $< $(manual-pages-raw-xml): %.raw.xml: %.raw.wiki $(SCRIPTS_DIR)/wikiparser.py - python3 $(SCRIPTS_DIR)/wikiparser.py $< > $@ + python3 $(SCRIPTS_DIR)/wikiparser.py --begin-marker="## BEGIN_INCLUDE" \ + --end-marker='## END_INCLUDE' $< > $@ $(manual-pages-xml): %.xml: %.raw.xml $(SCRIPTS_DIR)/manual-page-fixes.xslt xsltproc --output $@ $(SCRIPTS_DIR)/manual-page-fixes.xslt $< diff --git a/doc/scripts/wikiparser.py b/doc/scripts/wikiparser.py index a6e60ae71..b202ad8f8 100644 --- a/doc/scripts/wikiparser.py +++ b/doc/scripts/wikiparser.py @@ -1201,11 +1201,16 @@ PlainText('dialog.')])])])] # Skip lines before begin_marker, if given. if begin_marker: + removed_lines = [] while lines: line = lines.pop(0).strip() + removed_lines.append(line) if line.startswith(begin_marker): break + if not lines: # No begin marker found + lines = removed_lines + while lines: line = lines.pop(0) # End of included file @@ -1722,6 +1727,10 @@ if __name__ == '__main__': help='Skip module doctests') parser.add_argument('--debug', action='store_true', help='Show parser output') + parser.add_argument('--begin-marker', default=None, + help='Start parsing at this line') + parser.add_argument('--end-marker', default=None, + help='Stop parsing at this line') parser.add_argument('input', type=Path, nargs='*', help='input file path(s)') arguments = parser.parse_args() @@ -1736,7 +1745,9 @@ if __name__ == '__main__': wiki_text = wiki_file.read() context = get_context(in_file) - parsed_wiki = parse_wiki(wiki_text, context) + parsed_wiki = parse_wiki(wiki_text, context, + begin_marker=arguments.begin_marker, + end_marker=arguments.end_marker) if arguments.debug: import pprint pprint.pprint(parsed_wiki, indent=4)