Commit 4af139d2e4d61b2771717ec712c787f1a5b0b87e

Werner Lemberg 2008-01-18T04:53:28

formatting, whitespace

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
diff --git a/src/tools/docmaker/content.py b/src/tools/docmaker/content.py
index b14c52e..3f2b4de 100644
--- a/src/tools/docmaker/content.py
+++ b/src/tools/docmaker/content.py
@@ -1,4 +1,4 @@
-#  Content (c) 2002, 2004, 2006, 2007 David Turner <david@freetype.org>
+#  Content (c) 2002, 2004, 2006, 2007, 2008 David Turner <david@freetype.org>
 #
 #  This file contains routines used to parse the content of documentation
 #  comment blocks and build more structured objects out of them.
@@ -34,6 +34,7 @@ re_code_end   = re.compile( r"(\s*)}\s*$" )
 re_identifier = re.compile( r'(\w*)' )
 
 
+
 #############################################################################
 #
 # The DocCode class is used to store source code lines.
@@ -46,7 +47,7 @@ re_identifier = re.compile( r'(\w*)' )
 #
 class DocCode:
 
-    def __init__( self, margin, lines ):
+    def  __init__( self, margin, lines ):
         self.lines  = []
         self.words  = None
 
@@ -56,12 +57,12 @@ class DocCode:
                 l = l[margin:]
             self.lines.append( l )
 
-    def dump( self, prefix = "", width=60 ):
+    def  dump( self, prefix = "", width=60 ):
         lines = self.dump_lines( 0, width )
         for l in lines:
             print prefix + l
 
-    def dump_lines( self, margin=0, width=60 ):
+    def  dump_lines( self, margin=0, width=60 ):
         result = []
         for l in self.lines:
             result.append( " "*margin + l )
@@ -77,32 +78,32 @@ class DocCode:
 #
 class DocPara:
 
-    def __init__( self, lines ):
+    def  __init__( self, lines ):
         self.lines = None
         self.words = []
         for l in lines:
-            l = string.strip(l)
+            l = string.strip( l )
             self.words.extend( string.split( l ) )
 
-    def dump( self, prefix = "", width = 60 ):
+    def  dump( self, prefix = "", width = 60 ):
         lines = self.dump_lines( 0, width )
         for l in lines:
             print prefix + l
 
-    def dump_lines( self, margin=0, width = 60 ):
+    def  dump_lines( self, margin=0, width = 60 ):
         cur    = ""  # current line
         col    = 0   # current width
         result = []
 
         for word in self.words:
-            ln = len(word)
+            ln = len( word )
             if col > 0:
                 ln = ln+1
 
             if col + ln > width:
                 result.append( " "*margin + cur )
                 cur = word
-                col = len(word)
+                col = len( word )
             else:
                 if col > 0:
                     cur = cur + " "
@@ -116,7 +117,6 @@ class DocPara:
 
 
 
-
 #############################################################################
 #
 #  The DocField class is used to store a list containing either DocPara or
@@ -125,8 +125,7 @@ class DocPara:
 #
 class DocField:
 
-    def __init__( self, name, lines ):
-
+    def  __init__( self, name, lines ):
         self.name  = name  # can be None for normal paragraphs/sources
         self.items = []     # list of items
 
@@ -148,7 +147,7 @@ class DocField:
             if mode == mode_code:
 
                 m = re_code_end.match( l )
-                if m and len(m.group(1)) <= margin:
+                if m and len( m.group( 1 ) ) <= margin:
                     # that's it, we finised the code sequence
                     code = DocCode( 0, cur_lines )
                     self.items.append( code )
@@ -169,7 +168,7 @@ class DocField:
                         cur_lines = []
 
                     # switch to code extraction mode
-                    margin = len(m.group(1))
+                    margin = len( m.group( 1 ) )
                     mode   = mode_code
 
                 else:
@@ -193,7 +192,7 @@ class DocField:
             para = DocPara( cur_lines )
             self.items.append( para )
 
-    def dump( self, prefix = "" ):
+    def  dump( self, prefix = "" ):
         if self.field:
             print prefix + self.field + " ::"
             prefix = prefix + "----"
@@ -205,7 +204,7 @@ class DocField:
             p.dump( prefix )
             first = 0
 
-    def dump_lines( self, margin=0, width=60 ):
+    def  dump_lines( self, margin=0, width=60 ):
         result = []
         nl     = None
         for p in self.items:
@@ -217,6 +216,8 @@ class DocField:
 
         return result
 
+
+
 # this regular expression is used to detect field definitions
 #
 re_field  = re.compile( r"\s*(\w*|\w(\w|\.)*\w)\s*::" )
@@ -225,9 +226,9 @@ re_field  = re.compile( r"\s*(\w*|\w(\w|\.)*\w)\s*::" )
 
 class DocMarkup:
 
-    def __init__( self, tag, lines ):
-        self.tag       = string.lower(tag)
-        self.fields    = []
+    def  __init__( self, tag, lines ):
+        self.tag    = string.lower( tag )
+        self.fields = []
 
         cur_lines = []
         field     = None
@@ -245,10 +246,10 @@ class DocMarkup:
                     cur_lines = []
                     field     = None
 
-                field     = m.group(1)   # record field name
-                ln        = len(m.group(0))
+                field     = m.group( 1 )   # record field name
+                ln        = len( m.group( 0 ) )
                 l         = " "*ln + l[ln:]
-                cur_lines = [ l ]
+                cur_lines = [l]
             else:
                 cur_lines.append( l )
 
@@ -256,14 +257,14 @@ class DocMarkup:
             f = DocField( field, cur_lines )
             self.fields.append( f )
 
-    def get_name( self ):
+    def  get_name( self ):
         try:
             return self.fields[0].items[0].words[0]
 
         except:
             return None
 
-    def get_start( self ):
+    def  get_start( self ):
         try:
             result = ""
             for word in self.fields[0].items[0].words:
@@ -273,7 +274,7 @@ class DocMarkup:
         except:
             return "ERROR"
 
-    def dump( self, margin ):
+    def  dump( self, margin ):
         print " "*margin + "<" + self.tag + ">"
         for f in self.fields:
             f.dump( "  " )
@@ -281,26 +282,25 @@ class DocMarkup:
 
 
 
-
 class DocChapter:
 
-    def __init__( self, block ):
+    def  __init__( self, block ):
         self.block    = block
         self.sections = []
         if block:
-            self.name     = block.name
-            self.title    = block.get_markup_words( "title" )
-            self.order    = block.get_markup_words( "sections" )
+            self.name  = block.name
+            self.title = block.get_markup_words( "title" )
+            self.order = block.get_markup_words( "sections" )
         else:
-            self.name     = "Other"
-            self.title    = string.split( "Miscellaneous" )
-            self.order    = []
+            self.name  = "Other"
+            self.title = string.split( "Miscellaneous" )
+            self.order = []
 
 
 
 class DocSection:
 
-    def __init__( self, name = "Other" ):
+    def  __init__( self, name = "Other" ):
         self.name        = name
         self.blocks      = {}
         self.block_names = []  # ordered block names in section
@@ -311,14 +311,14 @@ class DocSection:
         self.title       = "ERROR"
         self.chapter     = None
 
-    def add_def( self, block ):
+    def  add_def( self, block ):
         self.defs.append( block )
 
-    def add_block( self, block ):
+    def  add_block( self, block ):
         self.block_names.append( block.name )
-        self.blocks[ block.name ] = block
+        self.blocks[block.name] = block
 
-    def process( self ):
+    def  process( self ):
         # lookup one block that contains a valid section description
         for block in self.defs:
             title = block.get_markup_text( "title" )
@@ -329,14 +329,14 @@ class DocSection:
                 self.order       = block.get_markup_words( "order" )
                 return
 
-    def reorder( self ):
-
+    def  reorder( self ):
         self.block_names = sort_order_list( self.block_names, self.order )
 
 
+
 class ContentProcessor:
 
-    def __init__( self ):
+    def  __init__( self ):
         """initialize a block content processor"""
         self.reset()
 
@@ -345,33 +345,33 @@ class ContentProcessor:
 
         self.chapters = []        # list of chapters
 
-    def set_section( self, section_name ):
+    def  set_section( self, section_name ):
         """set current section during parsing"""
         if not self.sections.has_key( section_name ):
             section = DocSection( section_name )
-            self.sections[ section_name ] = section
-            self.section                  = section
+            self.sections[section_name] = section
+            self.section                = section
         else:
-            self.section = self.sections[ section_name ]
+            self.section = self.sections[section_name]
 
-    def add_chapter( self, block ):
+    def  add_chapter( self, block ):
         chapter = DocChapter( block )
         self.chapters.append( chapter )
 
 
-    def reset( self ):
+    def  reset( self ):
         """reset the content processor for a new block"""
         self.markups      = []
         self.markup       = None
         self.markup_lines = []
 
-    def add_markup( self ):
+    def  add_markup( self ):
         """add a new markup section"""
         if self.markup and self.markup_lines:
 
             # get rid of last line of markup if it's empty
             marks = self.markup_lines
-            if len(marks) > 0 and not string.strip(marks[-1]):
+            if len( marks ) > 0 and not string.strip( marks[-1] ):
                 self.markup_lines = marks[:-1]
 
             m = DocMarkup( self.markup, self.markup_lines )
@@ -381,8 +381,7 @@ class ContentProcessor:
             self.markup       = None
             self.markup_lines = []
 
-
-    def process_content( self, content ):
+    def  process_content( self, content ):
         """process a block content and return a list of DocMarkup objects
            corresponding to it"""
         markup       = None
@@ -394,8 +393,8 @@ class ContentProcessor:
             for t in re_markup_tags:
                 m = t.match( line )
                 if m:
-                    found  = string.lower(m.group(1))
-                    prefix = len(m.group(0))
+                    found  = string.lower( m.group( 1 ) )
+                    prefix = len( m.group( 0 ) )
                     line   = " "*prefix + line[prefix:]   # remove markup from line
                     break
 
@@ -404,7 +403,7 @@ class ContentProcessor:
                 first = 0
                 self.add_markup()  # add current markup content
                 self.markup = found
-                if len(string.strip( line )) > 0:
+                if len( string.strip( line ) ) > 0:
                     self.markup_lines.append( line )
             elif first == 0:
                 self.markup_lines.append( line )
@@ -413,11 +412,10 @@ class ContentProcessor:
 
         return self.markups
 
-
     def  parse_sources( self, source_processor ):
         blocks = source_processor.blocks
-        count  = len(blocks)
-        for n in range(count):
+        count  = len( blocks )
+        for n in range( count ):
 
             source = blocks[n]
             if source.content:
@@ -432,9 +430,7 @@ class ContentProcessor:
 
                 doc_block = DocBlock( source, follow, self )
 
-
     def  finish( self ):
-
         # process all sections to extract their abstract, description
         # and ordered list of items
         #
@@ -445,8 +441,8 @@ class ContentProcessor:
         # listed there
         for chap in self.chapters:
             for sec in chap.order:
-                if self.sections.has_key(sec):
-                    section = self.sections[ sec ]
+                if self.sections.has_key( sec ):
+                    section = self.sections[sec]
                     section.chapter = chap
                     section.reorder()
                     chap.sections.append( section )
@@ -460,7 +456,7 @@ class ContentProcessor:
         others = []
         for sec in self.sections.values():
             if not sec.chapter:
-                others.append(sec)
+                others.append( sec )
 
         # create a new special chapter for all remaining sections
         # when necessary
@@ -474,8 +470,7 @@ class ContentProcessor:
 
 class DocBlock:
 
-    def __init__( self, source, follow, processor ):
-
+    def  __init__( self, source, follow, processor ):
         processor.reset()
 
         self.source    = source
@@ -491,7 +486,6 @@ class DocBlock:
         except:
             pass
 
-
         # compute block name from first markup paragraph
         try:
             markup = self.markups[0]
@@ -499,7 +493,7 @@ class DocBlock:
             name   = para.words[0]
             m = re_identifier.match( name )
             if m:
-                name = m.group(1)
+                name = m.group( 1 )
             self.name = name
         except:
             pass
@@ -542,21 +536,17 @@ class DocBlock:
 
         self.code = source
 
-
-    def location( self ):
+    def  location( self ):
         return self.source.location()
 
-
-
-    def get_markup( self, tag_name ):
+    def  get_markup( self, tag_name ):
         """return the DocMarkup corresponding to a given tag in a block"""
         for m in self.markups:
-            if m.tag == string.lower(tag_name):
+            if m.tag == string.lower( tag_name ):
                 return m
         return None
 
-
-    def get_markup_name( self, tag_name ):
+    def  get_markup_name( self, tag_name ):
         """return the name of a given primary markup in a block"""
         try:
             m = self.get_markup( tag_name )
@@ -564,21 +554,18 @@ class DocBlock:
         except:
             return None
 
-
-    def get_markup_words( self, tag_name ):
+    def  get_markup_words( self, tag_name ):
         try:
             m = self.get_markup( tag_name )
             return m.fields[0].items[0].words
         except:
             return []
 
-
-    def get_markup_text( self, tag_name ):
+    def  get_markup_text( self, tag_name ):
         result = self.get_markup_words( tag_name )
         return string.join( result )
 
-
-    def get_markup_items( self, tag_name ):
+    def  get_markup_items( self, tag_name ):
         try:
             m = self.get_markup( tag_name )
             return m.fields[0].items