Commit d37af32e authored by Stefan Sauer's avatar Stefan Sauer
Browse files 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.
parent 21ba2e57
......@@ -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; \
@gtkdoc-mktmpl --module=$(DOC_MODULE)
@echo ' DOC Building template files'
@$(PYTHON) \
$(top_srcdir)/common/ $(srcdir)/$(INSPECT_DIR) tmpl
@touch tmpl-build.stamp
......@@ -2,23 +2,14 @@
# vi:si:et:sw=4:sts=4:ts=4
use the output from 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
# 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 =
if match:
id = match.expand("\\1")
self._sections[id] = []
if not id:
"WARNING: line before a SECTION header: %s" % 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._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")
......@@ -136,30 +98,28 @@ def main():
inspectdir = sys.argv[1]
tmpldir = sys.argv[2]
if not os.path.exists (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):
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)
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="" href="' + \
'element-' + element + '-details.xml">' + \
'<fallback xmlns="" />' + \
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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment