Gary Oberbrunner avatar Gary Oberbrunner committed 0c9c8af

New doc toolchain changes:
bin/SConsDoc.py: catch parse exceptions and improve error msgs
bin/docs-validate.py: allow testing individual files from cmd line
src/engine/SCons/Tool/zip.xml: fix text to validate against DTD

Comments (0)

Files changed (3)

         def validateXml(self, fpath, xmlschema_context):
             # Use lxml
             xmlschema = etree.XMLSchema(xmlschema_context)
-            doc = etree.parse(fpath)
+            try:
+	        doc = etree.parse(fpath)
+            except Exception, e:
+                print "ERROR: %s fails to parse:"%fpath
+                print e
+                return False
             doc.xinclude()
             try:
                 xmlschema.assertValid(doc)
             except Exception, e:
+                print "ERROR: %s fails to validate:" % fpath
                 print e
-                print "%s fails to validate" % fpath
                 return False
             return True
 
     
     fpaths = []
     for dp in dpaths:
-        for path, dirs, files in os.walk(dp):
-            for f in files:
-                if f.endswith('.xml'):
-                    fp = os.path.join(path, f)
-                    if isSConsXml(fp):
-                        fpaths.append(fp)
+        if dp.endswith('.xml') and isSConsXml(dp):
+            path='.'
+            fpaths.append(dp)
+        else:
+            for path, dirs, files in os.walk(dp):
+                for f in files:
+                    if f.endswith('.xml'):
+                        fp = os.path.join(path, f)
+                        if isSConsXml(fp):
+                            fpaths.append(fp)
                 
     fails = []
     for idx, fp in enumerate(fpaths):
-        fpath = os.path.join(path, f)
+        fpath = os.path.join(path, fp)
         print "%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)),
                                      perc, idx+1, len(fpaths),fp)
                                               

bin/docs-validate.py

 # documentation files against our own XSD in docs/xsd.
 #
 
-import os
+import sys,os
 import SConsDoc
 
 if __name__ == "__main__":
-    if SConsDoc.validate_all_xml(['src',
-                                  os.path.join('doc','design'),
-                                  os.path.join('doc','developer'),
-                                  os.path.join('doc','man'),
-                                  os.path.join('doc','python10'),
-                                  os.path.join('doc','reference'),
-                                  os.path.join('doc','user')
-                                  ]):
-        print "OK"
+    if len(sys.argv)>1:
+        if SConsDoc.validate_all_xml((sys.argv[1],)):
+            print "OK"
+        else:
+            print "Validation failed! Please correct the errors above and try again."
     else:
-        print "Validation failed! Please correct the errors above and try again."
+        if SConsDoc.validate_all_xml(['src',
+                                      os.path.join('doc','design'),
+                                      os.path.join('doc','developer'),
+                                      os.path.join('doc','man'),
+                                      os.path.join('doc','python10'),
+                                      os.path.join('doc','reference'),
+                                      os.path.join('doc','user')
+                                      ]):
+            print "OK"
+        else:
+            print "Validation failed! Please correct the errors above and try again."

src/engine/SCons/Tool/zip.xml

 </summary>
 </cvar>
 
-</sconsdoc>
 <cvar name="ZIPROOT">
 <summary>
 An optional zip root directory (default empty).  The filenames stored
 Otherwise the filenames are relative to the current directory of the
 command.
 For instance:
-<example>
+<example_commands>
 env = Environment()
 env.Zip('foo.zip', 'subdir1/subdir2/file1', ZIPROOT='subdir1')
-</example>
+</example_commands>
+<para>
 will produce a zip file <literal>foo.zip</literal>
 containing a file with the name
 <literal>subdir2/file1</literal> rather than
 <literal>subdir1/subdir2/file1</literal>.
+</para>
 </summary>
 </cvar>
+</sconsdoc>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.