This commit is contained in:
David Turner 2004-01-18 09:49:07 +00:00
parent 4654d76d39
commit fd20da4b75
2 changed files with 667 additions and 619 deletions

View File

@ -56,9 +56,17 @@ class DocCode:
self.lines.append( l )
def dump( self, prefix = "", width=60 ):
for l in self.lines:
lines = self.dump_lines( 0, width )
for l in lines:
print prefix + l
def dump_lines( self, margin=0, width=60 ):
result = []
for l in self.lines:
result.append( " "*margin + l )
return result
#############################################################################
#
@ -76,8 +84,14 @@ class DocPara:
self.words.extend( string.split( l ) )
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 ):
cur = "" # current line
col = 0 # current width
result = []
for word in self.words:
ln = len(word)
@ -85,7 +99,7 @@ class DocPara:
ln = ln+1
if col + ln > width:
print prefix + cur
result.append( " "*margin + cur )
cur = word
col = len(word)
else:
@ -95,7 +109,10 @@ class DocPara:
col = col + ln
if col > 0:
print prefix + cur
result.append( " "*margin + cur )
return result
@ -187,6 +204,17 @@ class DocField:
p.dump( prefix )
first = 0
def dump_lines( self, margin=0, width=60 ):
result = []
nl = None
for p in self.items:
if nl:
result.append( "" )
result.extend( p.dump_lines( margin, width ) )
nl = 1
return result
# this regular expression is used to detect field definitions
#
@ -234,6 +262,16 @@ class DocMarkup:
except:
return None
def get_start( self ):
try:
result = ""
for word in self.fields[0].items[0].words:
result = result + " " + word
return result[1:]
except:
return "ERROR"
def dump( self, margin ):
print " "*margin + "<" + self.tag + ">"
for f in self.fields:

View File

@ -11,21 +11,31 @@
#
from sources import *
from content import *
from utils import *
import utils
import sys, os, time, string, getopt
content_processor = ContentProcessor()
def beautify_block( block ):
if block.content:
# convert all <XXXXX> tags to @XXXXX:
content_processor.reset()
markups = content_processor.process_content( block.content )
text = []
first = 1
for markup in markups:
text.extend( markup.beautify( first ) )
first = 0
# now beautify the documentation "borders" themselves
lines = [ " /*************************************************************************" ]
for l in block.content:
for l in text:
lines.append( " *" + l )
lines.append( " */" )