diff options
author | Dirk Baechle <dl9obn@darc.de> | 2013-05-03 22:12:43 (GMT) |
---|---|---|
committer | Dirk Baechle <dl9obn@darc.de> | 2013-05-03 22:12:43 (GMT) |
commit | e70f1133e2725460290ec719351a33dd28c1df3e (patch) | |
tree | b37d71196a6afd7eeb3271c651e86bf3d810dbcd /bin | |
parent | 9e7cf970a730549348fd22a0921ea0ed2e894a69 (diff) | |
download | SCons-e70f1133e2725460290ec719351a33dd28c1df3e.zip SCons-e70f1133e2725460290ec719351a33dd28c1df3e.tar.gz SCons-e70f1133e2725460290ec719351a33dd28c1df3e.tar.bz2 |
- added first version of the SCons XSD
- rewrote User Guide XML files, such that they are valid against it
Diffstat (limited to 'bin')
-rw-r--r-- | bin/SConsDoc.py | 35 | ||||
-rw-r--r-- | bin/scons-proc.py | 15 |
2 files changed, 48 insertions, 2 deletions
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 8889923..e5d28cd 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -213,6 +213,39 @@ def validate_xml(fpath, xmlschema_context): return True +def prettyprint_xml(fpath): + if not has_libxml2: + # At the moment we prefer libxml2 over lxml, the latter can lead + # to conflicts when installed together with libxml2. + if has_lxml: + # Use lxml + from lxml import etree + fin = open(fpath,'r') + tree = etree.parse(fin) + pretty_content = etree.tostring(tree, pretty_print=True) + fin.close() + + fout = open(fpath,'w') + fout.write(pretty_content) + fout.close() + else: + # Use xmllint as a last fallback + try: + import subprocess + p = subprocess.Popen(['xmllint', '-o', fpath, '--format', fpath], + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + sout, serr = p.communicate() + except: + print "Can't prettyprint %s! Neither lxml/libxml2, nor xmllint found." % fpath + return False + + # Read file and resolve entities + doc = libxml2.readFile(fpath, None, libxml2.XML_PARSE_NOENT) + err = xmlschema_context.schemaValidateDoc(doc) + # Cleanup + doc.freeDoc() + + perc="%" def validate_all_xml(dpath='src', xsdfile=default_xsd): @@ -302,7 +335,7 @@ class Builder(Item): class Function(Item): def __init__(self, name): super(Function, self).__init__(name) - self.arguments = [] + self.arguments = ['()'] class Tool(Item): def __init__(self, name): diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 7a56a79..3d460ab 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -126,6 +126,16 @@ class SCons_XML(object): fl = filename.split(',') filename = fl[0] f = self.fopen(filename) + + # Write XML header + f.write("""<?xml version='1.0'?> +<variablelist xmlns="%s" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="%s scons.xsd"> + +""" % (SConsDoc.dbxsd, SConsDoc.dbxsd)) + f.write(Warning) + for v in self.values: f.write('\n<varlistentry id="%s%s">\n' % (v.prefix, v.idfunc())) @@ -149,6 +159,9 @@ class SCons_XML(object): f.write('</listitem>\n') f.write('</varlistentry>\n') + # Write end tag + f.write('\n</variablelist>\n') + def write_mod(self, filename): try: description = self.values[0].description @@ -262,7 +275,7 @@ class Function(SConsThing): signature = arg.signature except AttributeError: signature = "both" - s = self.args_to_xml(arg) + s = arg # TODO: self.args_to_xml(arg) if signature in ('both', 'global'): result.append('<synopsis>%s%s</synopsis>\n' % (self.name, s)) #<br> if signature in ('both', 'env'): |