Rename bin/linecount to bin/linecount.py and provide finer-grained
[scons.git] / bin / scons-proc.py
index d55016fe6bf271ab1fe7005e68e76715f97113d0..cc3b085685cc8c79137bae1658e9b4161b07bc88 100644 (file)
@@ -6,7 +6,7 @@
 # construction variables documented in the specified XML files.
 #
 # Dependening on the options, the lists are output in either
-# DocBook-formatted generated SGML files containing the summary text
+# DocBook-formatted generated XML files containing the summary text
 # and/or .mod files contining the ENTITY definitions for each item,
 # or in man-page-formatted output.
 #
@@ -23,31 +23,35 @@ import SConsDoc
 base_sys_path = [os.getcwd() + '/build/test-tar-gz/lib/scons'] + sys.path
 
 helpstr = """\
-Usage: scons-proc.py [--man|--sgml] \
-                        [-b file(s)] [-t file(s)] [-v file(s)] [infile ...]
+Usage: scons-proc.py [--man|--xml]
+                     [-b file(s)] [-t file(s)] [-v file(s)] [infile ...]
 Options:
   -b file(s)        dump builder information to the specified file(s)
   -t file(s)        dump tool information to the specified file(s)
   -v file(s)        dump variable information to the specified file(s)
   --man             print info in man page format, each -[btv] argument
                     is a single file name
-  --sgml            (default) print info in SGML format, each -[btv] argument
+  --xml             (default) print info in SML format, each -[btv] argument
                     is a pair of comma-separated .gen,.mod file names
 """
 
 opts, args = getopt.getopt(sys.argv[1:],
-                           "b:t:v:",
-                           ['builders=', 'man', 'sgml', 'tools=', 'variables='])
+                           "b:ht:v:",
+                           ['builders=', 'help',
+                            'man', 'xml', 'tools=', 'variables='])
 
 buildersfiles = None
-output_type = '--sgml'
+output_type = '--xml'
 toolsfiles = None
 variablesfiles = None
 
 for o, a in opts:
     if o in ['-b', '--builders']:
         buildersfiles = a
-    elif o in ['--man', '--sgml']:
+    elif o in ['-h', '--help']:
+        sys.stdout.write(helpstr)
+        sys.exit(0)
+    elif o in ['--man', '--xml']:
         output_type = o
     elif o in ['-t', '--tools']:
         toolsfiles = a
@@ -128,7 +132,7 @@ class SCons_XML:
             return sys.stdout
         return open(name, 'w')
 
-class SCons_XML_to_SGML(SCons_XML):
+class SCons_XML_to_XML(SCons_XML):
     def write(self, files):
         gen, mod = string.split(files, ',')
         g.write_gen(gen)
@@ -146,11 +150,16 @@ class SCons_XML_to_SGML(SCons_XML):
             f.write('<listitem>\n')
             for chunk in v.summary.body:
                 f.write(str(chunk))
-            #if v.uses:
-            #    u = map(lambda x, s: '&%slink-%s;' % (s.prefix, x), v.uses)
-            #    f.write('<para>\n')
-            #    f.write('Uses:  ' + ', '.join(u) + '.\n')
-            #    f.write('</para>\n')
+            if v.sets:
+                s = map(lambda x: '&cv-link-%s;' % x, v.sets)
+                f.write('<para>\n')
+                f.write('Sets:  ' + ', '.join(s) + '.\n')
+                f.write('</para>\n')
+            if v.uses:
+                u = map(lambda x: '&cv-link-%s;' % x, v.uses)
+                f.write('<para>\n')
+                f.write('Uses:  ' + ', '.join(u) + '.\n')
+                f.write('</para>\n')
             f.write('</listitem>\n')
             f.write('</varlistentry>\n')
     def write_mod(self, filename):
@@ -204,6 +213,8 @@ class SCons_XML_to_man(SCons_XML):
         body = re.sub('\.EE\n\n+(?!\.IP)', '.EE\n.IP\n', body)
         body = re.sub('&(scons|SConstruct|SConscript|jar);', r'\\fB\1\\fP', body)
         body = string.replace(body, '&Dir;', r'\fBDir\fP')
+        body = string.replace(body, '&target;', r'\fItarget\fP')
+        body = string.replace(body, '&source;', r'\fIsource\fP')
         body = re.sub('&b(-link)?-([^;]*);', r'\\fB\2\\fP()', body)
         body = re.sub('&cv(-link)?-([^;]*);', r'$\2', body)
         body = re.sub(r'<(command|envar|filename|literal|option)>([^<]*)</\1>',
@@ -223,8 +234,8 @@ class SCons_XML_to_man(SCons_XML):
 
 if output_type == '--man':
     processor_class = SCons_XML_to_man
-elif output_type == '--sgml':
-    processor_class = SCons_XML_to_SGML
+elif output_type == '--xml':
+    processor_class = SCons_XML_to_XML
 else:
     sys.stderr.write("Unknown output type '%s'\n" % output_type)
     sys.exit(1)
@@ -264,3 +275,9 @@ if variablesfiles:
             entityfunc = lambda x: '$'+x)
 
     g.write(variablesfiles)
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: