summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDirk Baechle <dl9obn@darc.de>2013-05-04 00:12:43 +0200
committerDirk Baechle <dl9obn@darc.de>2013-05-04 00:12:43 +0200
commit834fbd437ab038737b5853e2e45763d2ff2317d8 (patch)
tree4b70034aed93544cd27f4ca39b1b3816d9f4554e /bin
parent804fe7d2dbf24ddf65c1d9dac087d88edc281019 (diff)
downloadscons-834fbd437ab038737b5853e2e45763d2ff2317d8.tar.gz
- 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.py35
-rw-r--r--bin/scons-proc.py15
2 files changed, 48 insertions, 2 deletions
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py
index 8889923f..e5d28cd4 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 7a56a798..3d460ab2 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'):