diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2015-06-07 20:12:05 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2015-06-07 22:54:19 +0200 |
commit | d37af32e2d6d1b546af72978f8441a84996ab3ea (patch) | |
tree | 2c4accbe59e2de4a38e728eb48afa3e17788b3e7 | |
parent | 21ba2e575a0ecb8c51b46fa31d4b9cfd699da8b2 (diff) |
mangle-tmpl.py: generate tmpl files instead of merging
We don't have any hand-written docs in tmpl files. Stop generating them with
gtkdoc and just write the minimal files ourself.
-rw-r--r-- | gtk-doc-plugins.mak | 15 | ||||
-rw-r--r-- | mangle-tmpl.py | 72 |
2 files changed, 19 insertions, 68 deletions
diff --git a/gtk-doc-plugins.mak b/gtk-doc-plugins.mak index 5d9b2f9..767e55a 100644 --- a/gtk-doc-plugins.mak +++ b/gtk-doc-plugins.mak @@ -171,19 +171,10 @@ scan-build.stamp: $(HFILE_GLOB) $(EXTRA_HFILES) $(basefiles) scanobj-build.stamp --ignore-headers="$(IGNORE_HFILES)"; \ touch scan-build.stamp -#### update templates; done on every build #### +#### generate templates; done on every build #### -# in a non-srcdir build, we need to copy files from the previous step -# and the files from previous runs of this step -tmpl-build.stamp: $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_OVERRIDES) - @echo ' DOC Rebuilding template files' - @if test x"$(srcdir)" != x. ; then \ - for f in $(SCANOBJ_FILES) $(SCAN_FILES); \ - do \ - if test -e $(srcdir)/$$f; then cp -u $(srcdir)/$$f . ; fi; \ - done; \ - fi - @gtkdoc-mktmpl --module=$(DOC_MODULE) +tmpl-build.stamp: + @echo ' DOC Building template files' @$(PYTHON) \ $(top_srcdir)/common/mangle-tmpl.py $(srcdir)/$(INSPECT_DIR) tmpl @touch tmpl-build.stamp diff --git a/mangle-tmpl.py b/mangle-tmpl.py index 51ea8c2..7a92d04 100644 --- a/mangle-tmpl.py +++ b/mangle-tmpl.py @@ -2,23 +2,14 @@ # vi:si:et:sw=4:sts=4:ts=4 """ -use the output from gst-xmlinspect.py to mangle tmpl/*.sgml and -insert/overwrite Short Description and Long Description +use the files from inspect/*.xml to create mininal tmpl/*.sgml files containing +'Short Description' and 'Long Description' to inject element details into the +docbook files produced by gtkdoc-mkdb """ -# FIXME: right now it uses pygst and scans on its own; -# we really should use inspect/*.xml instead since the result of -# gst-xmlinspect.py is committed by the docs maintainer, who can be -# expected to have pygst, but this step should be done for every docs build, -# so no pygst allowed - -# read in inspect/*.xml -# for every tmpl/element-(name).xml: mangle with details from element - from __future__ import print_function, unicode_literals import glob -import re import sys import os @@ -28,37 +19,12 @@ class Tmpl: self._sectionids = [] self._sections = {} - def read(self): - """ - Read and parse the sections from the given file. - """ - lines = open(self.filename).readlines() - matcher = re.compile("<!-- ##### SECTION (\S+) ##### -->\n") - id = None - - for line in lines: - match = matcher.search(line) - if match: - id = match.expand("\\1") - self._sectionids.append(id) - self._sections[id] = [] - else: - if not id: - sys.stderr.write( - "WARNING: line before a SECTION header: %s" % line) - else: - self._sections[id].append(line) - - def get_section(self, id): - """ - Get the content from the given section. - """ - return self._sections[id] - def set_section(self, id, content): """ Replace the given section id with the given content. """ + if not id in self._sectionids: + self._sectionids.append(id) self._sections[id] = content def output(self): @@ -73,14 +39,10 @@ class Tmpl: return "".join(lines) - def write(self, backup=False): + def write(self): """ Write out the template file again, backing up the previous one. """ - if backup: - target = self.filename + ".mangle.bak" - os.rename(self.filename, target) - handle = open(self.filename, "w") handle.write(self.output()) handle.close() @@ -136,30 +98,28 @@ def main(): inspectdir = sys.argv[1] tmpldir = sys.argv[2] + if not os.path.exists (tmpldir): + os.mkdir(tmpldir) + # parse all .xml files; build map of element name -> short desc #for file in glob.glob("inspect/plugin-*.xml"): elements = {} for file in glob.glob("%s/plugin-*.xml" % inspectdir): elements.update(get_elements(file)) - for file in glob.glob("%s/element-*.sgml" % tmpldir): - base = os.path.basename(file) - element = base[len("element-"):-len(".sgml")] + for element in elements.keys(): + file = "%s/element-%s.sgml" % (tmpldir, element) tmpl = Tmpl(file) - tmpl.read() - if element in elements.keys(): - description = elements[element]['description'] - tmpl.set_section("Short_Description", "%s\n\n" % description) - # put in an include if not yet there + description = elements[element]['description'] + tmpl.set_section("Short_Description", "%s\n" % description) + + # add include for details line = '<include xmlns="http://www.w3.org/2003/XInclude" href="' + \ 'element-' + element + '-details.xml">' + \ '<fallback xmlns="http://www.w3.org/2003/XInclude" />' + \ '</include>\n' - section = tmpl.get_section("Long_Description") - if not section[0] == line: - section.insert(0, line) - tmpl.set_section("Long_Description", section) + tmpl.set_section("Long_Description", line) tmpl.write() main() |