22 import fileinput, re, sys, os, string
40 """create a block pattern, used to recognize special documentation blocks"""
42 self.
start = re.compile( start, re.VERBOSE )
43 self.
column = re.compile( column, re.VERBOSE )
44 self.
end = re.compile( end, re.VERBOSE )
61 \s* # any number of whitespace
62 /\*{2,}/ # followed by '/' and at least two asterisks then '/'
63 \s*$ # probably followed by whitespace
67 \s* # any number of whitespace
68 /\*{1} # followed by '/' and precisely one asterisk
69 ([^*].*) # followed by anything (group 1)
70 \*{1}/ # followed by one asterisk and a '/'
71 \s*$ # probably followed by whitespace
90 \s* # any number of whitespace
91 /\*{2,} # followed by '/' and at least two asterisks
92 \s*$ # probably followed by whitespace
96 \s* # any number of whitespace
97 \*{1}(?!/) # followed by precisely one asterisk not followed by `/'
98 (.*) # then anything (group1)
102 \s* # any number of whitespace
103 \*+/ # followed by at least one asterisk, then '/'
113 re_source_block_formats = [re_source_block_format1, re_source_block_format2]
123 re_markup_tag1 = re.compile(
r'''\s*<(\w*)>''' )
124 re_markup_tag2 = re.compile(
r'''\s*@(\w*):''' )
130 re_markup_tags = [re_markup_tag1, re_markup_tag2]
135 re_crossref = re.compile(
r'@(\w*)(.*)' )
140 re_italic = re.compile(
r"_(\w(\w|')*)_(.*)" )
141 re_bold = re.compile(
r"\*(\w(\w|')*)\*(.*)" )
146 re_source_sep = re.compile(
r'\s*/\*\s*\*/' )
151 re_source_crossref = re.compile(
r'(\W*)(\w*)' )
156 re_source_keywords = re.compile(
'''\\b ( typedef |
175 \#endif ) \\b''', re.VERBOSE )
203 def __init__( self, processor, filename, lineno, lines ):
219 for line0
in self.
lines:
220 m = self.format.column.match( line0 )
222 lines.append( m.group( 1 ) )
226 l = string.strip( l )
228 for tag
in re_markup_tags:
239 print "{{{content start---"
242 print "---content end}}}"
247 fmt = repr( self.format.id ) +
" "
249 for line
in self.
lines:
273 """initialize a source processor"""
280 """reset a block processor, clean all its blocks"""
285 """parse a C source file, and add its blocks to the processor's list"""
295 for line
in fileinput.input( filename ):
297 if line[-1] ==
'\012':
303 if self.format.end.match( line ):
306 self.lines.append( line )
308 elif self.format.column.match( line ):
310 self.lines.append( line )
323 """process a normal line and check whether it is the start of a new block"""
324 for f
in re_source_block_formats:
325 if f.start.match( line ):
328 self.
lineno = fileinput.filelineno()
330 self.lines.append( line )
333 """add the current accumulated lines and create a new block"""
337 self.blocks.append( block )
343 """print all blocks in a processor"""