diff options
Diffstat (limited to 'bin/SConsDoc.py')
-rw-r--r-- | bin/SConsDoc.py | 89 |
1 files changed, 80 insertions, 9 deletions
diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index d3a043b..cd78195 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -5,8 +5,8 @@ __doc__ = """ This module parses home-brew XML files that document various things -in SCons. Right now, it handles Builders, construction variables, -and Tools, but we expect it to get extended in the future. +in SCons. Right now, it handles Builders, functions, construction +variables, and Tools, but we expect it to get extended in the future. In general, you can use any DocBook tag in the input, and this module just adds processing various home-brew tags to try to make life a @@ -14,14 +14,14 @@ little easier. Builder example: - <builder name="VARIABLE"> + <builder name="BUILDER"> <summary> - This is the summary description of an SCons Tool. + This is the summary description of an SCons Builder. It will get placed in the man page, and in the appropriate User's Guide appendix. The name of any builder may be interpolated anywhere in the document by specifying the - &b-VARIABLE; + &b-BUILDER; element. It need not be on a line by itself. Unlike normal XML, blank lines are significant in these @@ -35,6 +35,32 @@ Builder example: </summary> </builder> +Function example: + + <scons_function name="FUNCTION"> + <arguments> + (arg1, arg2, key=value) + </arguments> + <summary> + This is the summary description of an SCons function. + It will get placed in the man page, + and in the appropriate User's Guide appendix. + The name of any builder may be interpolated + anywhere in the document by specifying the + &f-FUNCTION; + element. It need not be on a line by itself. + + Unlike normal XML, blank lines are significant in these + descriptions and serve to separate paragraphs. + They'll get replaced in DocBook output with appropriate tags + to indicate a new paragraph. + + <example> + print "this is example code, it will be offset and indented" + </example> + </summary> + </scons_function> + Construction variable example: <cvar name="VARIABLE"> @@ -60,14 +86,14 @@ Construction variable example: Tool example: - <tool name="VARIABLE"> + <tool name="TOOL"> <summary> This is the summary description of an SCons Tool. It will get placed in the man page, and in the appropriate User's Guide appendix. The name of any tool may be interpolated anywhere in the document by specifying the - &t-VARIABLE; + &t-TOOL; element. It need not be on a line by itself. Unlike normal XML, blank lines are significant in these @@ -82,12 +108,13 @@ Tool example: </tool> """ -import os.path import imp +import os.path +import re import sys import xml.sax.handler -class Item: +class Item(object): def __init__(self, name): self.name = name self.sort_name = name.lower() @@ -106,6 +133,12 @@ class Item: class Builder(Item): pass +class Function(Item): + def __init__(self, name, global_signature, env_signature): + super(Function, self).__init__(name) + self.global_signature = global_signature + self.env_signature = env_signature + class Tool(Item): def __init__(self, name): Item.__init__(self, name) @@ -126,6 +159,22 @@ class Chunk: def append(self, data): self.body.append(data) +class Arguments: + def __init__(self, body=None): + if not body: + body = [] + self.body = body + def __str__(self): + s = ''.join(self.body).strip() + result = [] + for m in re.findall('([a-zA-Z/_]+|[^a-zA-Z/_]+)', s): + if ' ' in m: + m = '"%s"' % m + result.append(m) + return ' '.join(result) + def append(self, data): + self.body.append(data) + class Summary: def __init__(self): self.body = [] @@ -181,6 +230,7 @@ class SConsDocHandler(xml.sax.handler.ContentHandler, self.collect = [] self.current_object = [] self.builders = {} + self.functions = {} self.tools = {} self.cvars = {} @@ -244,6 +294,19 @@ class SConsDocHandler(xml.sax.handler.ContentHandler, def end_builder(self): self.end_xxx() + def start_scons_function(self, attrs): + name = attrs.get('name') + try: + function = self.functions[name] + except KeyError: + function = Function(name, + attrs.get('global', "1"), + attrs.get('env', "1")) + self.functions[name] = function + self.begin_xxx(function) + def end_scons_function(self): + self.end_xxx() + def start_tool(self, attrs): name = attrs.get('name') try: @@ -266,6 +329,14 @@ class SConsDocHandler(xml.sax.handler.ContentHandler, def end_cvar(self): self.end_xxx() + def start_arguments(self, attrs): + arguments = Arguments() + self.current_object.arguments = arguments + self.begin_xxx(arguments) + self.begin_collecting(arguments) + def end_arguments(self): + self.end_xxx() + def start_summary(self, attrs): summary = Summary() self.current_object.summary = summary |