From: Jaroslav Kysela Date: Mon, 15 Jan 2018 17:46:42 +0000 (+0100) Subject: docs: increase rebuild time (add --batch mode to md_to_c.py X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7c303510b2e88500778568a6f24c911158d9114;p=thirdparty%2Ftvheadend.git docs: increase rebuild time (add --batch mode to md_to_c.py --- diff --git a/Makefile b/Makefile index 963c8ac0e..f4b7debbe 100644 --- a/Makefile +++ b/Makefile @@ -772,28 +772,25 @@ $(BUILDDIR)/build.o: $(BUILDDIR)/build.c # Documentation $(BUILDDIR)/docs-timestamp: $(I18N-DOCS) support/doc/md_to_c.py - @-rm -f src/docs_inc.c - @for i in $(MD-ROOT); do \ - echo "Markdown: docs/markdown/$${i}.md"; \ - $(MD-TO-C) --in="docs/markdown/$${i}.md" \ - --name="tvh_doc_root_$${i}" >> src/docs_inc.c || exit 1; \ - done - @for i in $(MD-CLASS); do \ - echo "Markdown: docs/class/$${i}.md"; \ - $(MD-TO-C) --in="docs/class/$${i}.md" \ - --name="tvh_doc_$${i}_class" >> src/docs_inc.c || exit 1; \ - done - @for i in $(MD-PROP); do \ - echo "Markdown: docs/property/$${i}.md"; \ - $(MD-TO-C) --in="docs/property/$${i}.md" \ - --name="tvh_doc_$${i}_property" >> src/docs_inc.c || exit 1; \ - done - @for i in $(MD-WIZARD); do \ - echo "Markdown: docs/wizard/$${i}.md"; \ - $(MD-TO-C) --in="docs/wizard/$${i}.md" \ - --name="tvh_doc_wizard_$${i}" >> src/docs_inc.c || exit 1; \ - done - @$(MD-TO-C) --pages="$(MD-ROOT)" >> src/docs_inc.c + @-rm -f src/docs_inc.c src/docs_inc.c.new + @$(MD-TO-C) --batch --list="$(MD-ROOT)" \ + --inpath="docs/markdown/%s.md" \ + --name="tvh_doc_root_%s" \ + --out="src/docs_inc.c.new" + @$(MD-TO-C) --batch --list="$(MD-CLASS)" \ + --inpath="docs/class/%s.md" \ + --name="tvh_doc_%s_class" \ + --out="src/docs_inc.c.new" + @$(MD-TO-C) --batch --list="$(MD-PROP)" \ + --inpath="docs/property/%s.md" \ + --name="tvh_doc_%s_property" \ + --out="src/docs_inc.c.new" + @$(MD-TO-C) --batch --list="$(MD-WIZARD)" \ + --inpath="docs/wizard/%s.md" \ + --name="tvh_doc_wizard_%s" \ + --out="src/docs_inc.c.new" + @$(MD-TO-C) --pages="$(MD-ROOT)" >> src/docs_inc.c.new + @mv src/docs_inc.c.new src/docs_inc.c @touch $@ src/docs_inc.c: $(BUILDDIR)/docs-timestamp diff --git a/support/doc/md_to_c.py b/support/doc/md_to_c.py index cbdcc5175..6feb8100b 100755 --- a/support/doc/md_to_c.py +++ b/support/doc/md_to_c.py @@ -430,7 +430,7 @@ def argv_get(what): for a in sys.argv: if a.startswith(what): a = a[len(what):] - if a[0] == '=': + if a and a[0] == '=': return a[1:] else: return True @@ -440,30 +440,46 @@ def argv_get(what): # # +def run(input, name, human): + fp = utf8open(input, 'r') + text = fp.read(1024*1024*2) + fp.close() + + renderer = TVH_C_Renderer(parse_html=1) + md = Markdown(renderer) + text = md(text) + text = optimize(text) + if human: + return text + return 'const char *' + name + '[] = {\n' + text + '\nNULL\n};\n' + HUMAN=argv_get('human') DEBUG=argv_get('debug') pages = argv_get('pages') if pages: dopages(pages) sys.exit(0) -input = argv_get('in') -if not input: - fatal('Specify input file.') -name = argv_get('name') -if not name: - fatal('Specify class name.') -name = name.replace('/', '_') - -fp = utf8open(input, 'r') -text = fp.read(1024*1024*2) -fp.close() - -renderer = TVH_C_Renderer(parse_html=1) -md = Markdown(renderer) -text = md(text) -text = optimize(text) - -if not HUMAN: - print('const char *' + name + '[] = {\n' + text + '\nNULL\n};\n'); +BATCH=argv_get('batch') +if BATCH: + inpath = argv_get('inpath') + out = argv_get('out') + name = argv_get('name') + list = argv_get('list') + fp = open(out, "a+") + for l in list.split(' '): + input = inpath % l + print("Markdown: %s" % input) + n = (name % l).replace('/', '_') + text = run(input, n, HUMAN) + fp.write(text) + fp.close() else: + input = argv_get('in') + if not input: + fatal('Specify input file.') + name = argv_get('name') + if not name: + fatal('Specify class name.') + name = name.replace('/', '_') + text = run(input, name, HUMAN) print(text)