diff --git a/docs/docmaker.py b/docs/docmaker.py
index 5f35dbdb3..812b5993d 100644
--- a/docs/docmaker.py
+++ b/docs/docmaker.py
@@ -126,140 +126,139 @@ def make_block_list():
# 5 - process source
#
- comment = []
- source = []
- state = 0
+ comment = []
+ source = []
+ state = 0
for line in fileinput.input():
- # remove trailing CR
- l = len(line)
- if l > 0 and line[l-1] == '\012':
- line = line[0:l-1]
+ l = len( line )
+ if l > 0 and line[l - 1] == '\012':
+ line = line[0 : l - 1]
# stripped version of the line
- line2 = string.strip(line)
- l = len(line2)
+ line2 = string.strip( line )
+ l = len( line2 )
- # if this line begins with a comment and we're processing some source, exit
- # to state 0
+ # if this line begins with a comment and we are processing some
+ # source, exit to state 0
#
- if format >= 4 and l > 2 and line2[0:2] == '/*':
- list.append( (block,source) )
+ if format >= 4 and l > 2 and line2[0 : 2] == '/*':
+ list.append( ( block, source ) )
format = 0
-
- if format == 0: ##################### wait beginning of comment ###########
- if l > 3 and line2[0:3] == '/**':
- i = 3
- while (i < l) and (line2[i] == '*'):
- i = i+1
- if i == l:
- # this is '/**' followed by any number of '*', the
- # beginning of a Format 1 block
- #
- block = []
- source = []
- format = 1
+ if format == 0: #### wait for beginning of comment ####
- elif (i == l-1) and (line2[i] == '/'):
- # this is '/**' followed by any number of '*', followed
- # by a '/', i.e. the beginning of a Format 2 or 3 block
- #
- block = []
- source = []
- format = 2
+ if l > 3 and line2[0 : 3] == '/**':
+ i = 3
+ while i < l and line2[i] == '*':
+ i = i + 1
- ##############################################################
- #
- # FORMAT 1
- #
- elif format == 1:
+ if i == l:
+ # this is '/**' followed by any number of '*', the
+ # beginning of a Format 1 block
+ #
+ block = []
+ source = []
+ format = 1
- # if the line doesn't begin with a "*", something went
- # wrong, and we must exit, and forget the current block..
- if (l == 0) or (line2[0] != '*'):
- block = []
- format = 0
-
- # otherwise, we test for an end of block, which is an
- # arbitrary number of '*', followed by '/'
- else:
- i = 1
- while (i < l) and (line2[i] == '*'):
- i = i+1
+ elif i == l - 1 and line2[i] == '/':
+ # this is '/**' followed by any number of '*', followed
+ # by a '/', i.e. the beginning of a Format 2 or 3 block
+ #
+ block = []
+ source = []
+ format = 2
+
+ ##############################################################
+ #
+ # FORMAT 1
+ #
+ elif format == 1:
+
+ # if the line doesn't begin with a "*", something went
+ # wrong, and we must exit, and forget the current block..
+ if l == 0 or line2[0] != '*':
+ block = []
+ format = 0
+
+ # otherwise, we test for an end of block, which is an
+ # arbitrary number of '*', followed by '/'
+ else:
+ i = 1
+ while i < l and line2[i] == '*':
+ i = i + 1
+
+ # test for the end of the block
+ if i < l and line2[i] == '/':
+ if block != []:
+ format = 4
+ else:
+ format = 0
+ else:
+ # otherwise simply append line to current block
+ block.append( line2 )
- # test for the end of the block
- if (i < l) and (line2[i] == '/'):
- if block != []:
- format = 4
- else:
- format = 0
- else:
- # otherwise simply append line to current block
- block.append(line2)
continue
- ##############################################################
- #
- # FORMAT 2
- #
- elif format == 2:
+ ##############################################################
+ #
+ # FORMAT 2
+ #
+ elif format == 2:
- # if the line doesn't begin with '/*' and end with '*/',
- # this is the end of the format 2 format..
- if (l < 4 ) or (line2[:2] != '/*') or (line2[-2:] != '*/'):
- if block != []:
- format = 4
- else:
- format = 0
- else:
- # remove the start and end comment delimiters, then right-strip
- # the line
- line2 = string.rstrip(line2[2:-2])
+ # if the line doesn't begin with '/*' and end with '*/',
+ # this is the end of the format 2 format
+ if l < 4 or line2[: 2] != '/*' or line2[-2 :] != '*/':
+ if block != []:
+ format = 4
+ else:
+ format = 0
+ else:
+ # remove the start and end comment delimiters, then
+ # right-strip the line
+ line2 = string.rstrip( line2[2 : -2] )
- # check for end of a format2 block, i.e. a run of '*'
- if string.count(line2,'*') == l-4:
- if block != []:
- format = 4
- else:
- format = 0
- else:
- # otherwise, add the line to the current block
- block.append(line2)
-
- continue
+ # check for end of a format2 block, i.e. a run of '*'
+ if string.count( line2, '*' ) == l - 4:
+ if block != []:
+ format = 4
+ else:
+ format = 0
+ else:
+ # otherwise, add the line to the current block
+ block.append( line2 )
+
+ continue
- if format >= 4: ########################## source processing ################
+ if format >= 4: #### source processing ####
if l > 0:
format = 5
if format == 5:
- source.append(line)
+ source.append( line )
if format >= 4:
- list.append([block,source])
+ list.append( [block, source] )
return list
-
-
# This function is only used for debugging
#
def dump_block_list( list ):
"""dump a comment block list"""
for block in list:
- print "----------------------------------------"
- for line in block[0]:
- print line
- for line in block[1]:
- print line
+ print "----------------------------------------"
+ for line in block[0]:
+ print line
+ for line in block[1]:
+ print line
print "---------the end-----------------------"
@@ -271,77 +270,86 @@ def dump_block_list( list ):
#
class DocCode:
- def __init__(self,margin=0):
- self.lines = []
- self.margin = margin
-
- def add(self,line):
+ def __init__( self, margin = 0 ):
+ self.lines = []
+ self.margin = margin
+
+ def add( self, line ):
# remove margin whitespace
- if string.strip( line[:self.margin] ) == "": line = line[self.margin:]
- self.lines.append(line)
+ if string.strip( line[: self.margin] ) == "":
+ line = line[self.margin :]
+ self.lines.append( line )
- def dump(self):
+ def dump( self ):
- max_width = 50
+ max_width = 50
for line in self.lines:
print "--" + line
- print ""
+ print ""
- def dump_html(self):
+ def dump_html( self ):
# clean the last empty lines
- l = len(self.lines)-1
- while (len > 0) and string.strip(lines[len-1])=="":
- len = len-1
+ l = len( self.lines ) - 1
+ while len > 0 and string.strip( lines[len - 1] ) == "":
+ len = len - 1
print code_header
- for line in self.lines[0:len]:
+ for line in self.lines[0 : len]:
print lines
print code_footer
##############################################################################
#
-# The DocParagraph is used to store either simple text paragraphs
+# The DocParagraph is used to store text paragraphs
# self.words is simply a list of words for the paragraph
#
class DocParagraph:
- def __init__(self):
- self.words = []
-
- def add(self,line):
+ def __init__( self ):
+ self.words = []
+
+ def add( self, line ):
# get rid of unwanted spaces in the paragraph
- self.words.extend( string.split(line) )
-
+ #
+ # the following line is the same as
+ #
+ # self.words.extend( string.split( line ) )
+ #
+ # but older Python versions don't have the `extend' attribute
+ #
+ self.words[len( self.words ) : len( self.words )] = \
+ string.split( line )
+
- def dump(self):
+ def dump( self ):
- max_width = 50
+ max_width = 50
cursor = 0
line = ""
for word in self.words:
- if cursor+len(word)+1 > max_width:
- print line
- cursor = 0
- line = ""
+ if cursor + len( word ) + 1 > max_width:
+ print line
+ cursor = 0
+ line = ""
- line = line + word + " "
- cursor = cursor + len(word) + 1
-
+ line = line + word + " "
+ cursor = cursor + len( word ) + 1
+
if cursor > 0:
- print line
+ print line
- print ""
+ print ""
- def dump_html(self):
+ def dump_html( self ):
print para_header
self.dump()
@@ -352,33 +360,31 @@ class DocParagraph:
#
# DocContent is used to store the content of a given marker.
#
-#
-#
class DocContent:
- def __init__(self,lines_list):
- self.items = []
- code_mode = 0
- code_margin = 0
- text = []
- paragraph = None
- code = None
- elements = []
- field = None
+ def __init__( self, lines_list ):
+ self.items = []
+ code_mode = 0
+ code_margin = 0
+ text = []
+ paragraph = None
+ code = None
+ elements = []
+ field = None
- for aline in lines_list:
-
- if code_mode == 0:
- line = string.lstrip(aline)
- l = len(line)
- margin = len(aline) - l
+ for aline in lines_list:
+
+ if code_mode == 0:
+ line = string.lstrip( aline )
+ l = len( line )
+ margin = len( aline ) - l
- # if the line is empty, this is the end of the current
- # paragraph
- if l == 0 or line == '{':
+ # if the line is empty, this is the end of the current
+ # paragraph
+ if l == 0 or line == '{':
- if paragraph:
- elements.append(paragraph)
+ if paragraph:
+ elements.append( paragraph )
paragraph = None
if line == "":
@@ -388,87 +394,87 @@ class DocContent:
code_margin = margin
code = None
continue
-
- words = string.split(line)
-
- # test for a field delimiter on the start of the line, i.e.
- # the token `::'
- #
- if len(words) >= 2 and words[1] == "::":
- if paragraph:
- elements.append(paragraph)
+
+ words = string.split( line )
+
+ # test for a field delimiter on the start of the line, i.e.
+ # the token `::'
+ #
+ if len( words ) >= 2 and words[1] == "::":
+ if paragraph:
+ elements.append( paragraph )
paragraph = None
- self.items.append( (field,elements) )
-
- field = words[0]
- elements = []
- words = words[2:]
-
- if len(words) > 0:
- line = string.join(words)
- if not paragraph:
- paragraph = DocParagraph()
- paragraph.add( line )
-
- else:
- line = aline
-
- # the code block ends with a line that has a single '}' on it
- if line == " "*code_margin+'}':
+ self.items.append( ( field, elements ) )
+
+ field = words[0]
+ elements = []
+ words = words[2 :]
+
+ if len( words ) > 0:
+ line = string.join( words )
+ if not paragraph:
+ paragraph = DocParagraph()
+ paragraph.add( line )
+
+ else:
+ line = aline
+
+ # the code block ends with a line that has a single '}' on it
+ if line == " " * code_margin + '}':
if code:
- elements.append(code)
+ elements.append( code )
code = None
- code_mode = 0
- code_margin = 0
-
- # otherwise, add the line to the current paragraph
- else:
+ code_mode = 0
+ code_margin = 0
+
+ # otherwise, add the line to the current paragraph
+ else:
if not code:
code = DocCode()
- code.add(line)
-
- if paragraph:
- elements.append(paragraph)
+ code.add( line )
+
+ if paragraph:
+ elements.append( paragraph )
if code:
- elements.append(code)
-
- self.items.append( (field,elements) )
+ elements.append( code )
+
+ self.items.append( ( field, elements ) )
- def dump(self):
- for item in self.items:
+ def dump( self ):
+ for item in self.items:
field = item[0]
- if field:
- print "
" @@ -476,7 +482,7 @@ class DocContent: else: print " | ||
" - print ""+field+" | " + print "" + field + " | " for element in item[1]: element.dump_html() @@ -484,6 +490,7 @@ class DocContent: if in_table: print " |
" dcontent.dump() print "
" dcontent.dump_html() print "