6 from formatter
import *
13 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
14 "http://www.w3.org/TR/html4/loose.dtd">
17 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23 <style type="text/css">
24 body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
26 background: #FFFFFF; }
28 p { text-align: justify; }
29 h1 { text-align: center; }
30 li { text-align: justify; }
31 td { padding: 0 0.5em 0 0.5em; }
32 td.left { padding: 0 0.5em 0 0.5em;
35 a:link { color: #0000EF; }
36 a:visited { color: #51188E; }
37 a:hover { color: #FF0000; }
39 span.keyword { font-family: monospace;
44 pre.colored { color: blue; }
46 ul.empty { list-style-type: none; }
53 <table align=center><tr><td><font size=-1>[<a href="\
57 <table align=center><tr><td width="100%"></td>
58 <td><font size=-1>[<a href="\
62 ">Index</a>]</font></td>
63 <td width="100%"></td>
64 <td><font size=-1>[<a href="\
68 ">TOC</a>]</font></td></tr></table>
73 ">Index</a>]</font></td>
74 <td width="100%"></td></tr></table>
79 API Reference</h1></center>
90 section_title_header =
"<center><h1>"
91 section_title_footer =
"</h1></center>"
94 code_header =
'<pre class="colored">'
95 code_footer =
'</pre>'
102 block_header =
'<table align=center width="75%"><tr><td>'
103 block_footer_start =
"""\
106 <table align=center width="75%"><tr><td><font size=-2>[<a href="\
108 block_footer_middle =
"""\
109 ">Index</a>]</font></td>
110 <td width="100%"></td>
111 <td><font size=-2>[<a href="\
113 block_footer_end =
"""\
114 ">TOC</a>]</font></td></tr></table>
118 description_header =
'<table align=center width="87%"><tr><td>'
119 description_footer =
"</td></tr></table><br>"
122 marker_header =
'<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>'
123 marker_inter =
"</b></em></td></tr><tr><td>"
124 marker_footer =
"</td></tr></table>"
127 header_location_header =
'<table align=center width="87%"><tr><td>'
128 header_location_footer =
"</td></tr></table><br>"
131 source_header =
'<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n'
132 source_footer =
"\n</pre></table><br>"
135 chapter_header =
'<br><table align=center width="75%"><tr><td><h2>'
136 chapter_inter =
'</h2><ul class="empty"><li>'
137 chapter_footer =
'</li></ul></td></tr></table>'
140 index_footer_start =
"""\
142 <table><tr><td width="100%"></td>
143 <td><font size=-2>[<a href="\
145 index_footer_end =
"""\
146 ">TOC</a>]</font></td></tr></table>
150 toc_footer_start =
"""\
152 <table><tr><td><font size=-2>[<a href="\
154 toc_footer_end =
"""\
155 ">Index</a>]</font></td>
156 <td width="100%"></td>
162 keyword_prefix =
'<span class="keyword">'
163 keyword_suffix =
'</span>'
165 section_synopsis_header =
'<h2>Synopsis</h2>'
166 section_synopsis_footer =
''
172 result = string.replace( line,
"&",
"&" )
173 result = string.replace( result,
"<",
"<" )
174 result = string.replace( result,
">",
">" )
180 return string.replace( line,
"&",
"&" )
185 l = len( self.lines )
186 while l > 0
and string.strip( self.lines[l - 1] ) ==
"":
191 print prefix + code_header,
192 for line
in self.lines[0 : l + 1]:
194 print prefix + code_footer,
200 def __init__( self, processor, project_title, file_prefix ):
201 Formatter.__init__( self, processor )
203 global html_header_1, html_header_2, html_header_3
204 global html_header_4, html_header_5, html_footer
207 file_prefix = file_prefix +
"-"
216 html_header_3 + file_prefix +
"index.html" + \
217 html_header_4 + file_prefix +
"toc.html" + \
218 html_header_5 + project_title + \
223 html_header_3i + file_prefix +
"toc.html" + \
224 html_header_5 + project_title + \
229 html_header_3 + file_prefix +
"index.html" + \
230 html_header_5t + project_title + \
234 time.asctime( time.localtime( time.time() ) ) + \
235 "</font></center>" + html_footer
246 """ convert a series of simple words into some HTML text """
256 """analyze a simple word to detect cross-references and styling"""
258 m = re_crossref.match( word )
265 return '<a href="' + url +
'">' + name +
'</a>' + rest
269 "WARNING: undefined cross reference '" + name +
"'.\n" )
270 return '?' + name +
'?' + rest
273 m = re_italic.match( word )
277 return '<i>' + name +
'</i>' + rest
279 m = re_bold.match( word )
283 return '<b>' + name +
'</b>' + rest
288 """ convert words of a paragraph into tagged HTML text, handle xrefs """
292 for word
in words[1:]:
295 line = re.sub(
r"(^|\W)`(.*?)'(\W|$)", \
296 r'\1‘\2’\3', \
299 line = string.replace( line,
"~",
" " )
301 return para_header + line + para_footer
304 """ convert a code sequence to HTML """
305 line = code_header +
'\n'
309 return line + code_footer
312 """ convert a field's content into some valid HTML """
320 return string.join( lines,
'\n' )
327 print "<table><tr valign=top><td><b>" + field.name +
"</b></td><td>"
332 print "</td></tr></table>"
337 m = re_source_crossref.match( line )
341 length = len( m.group( 0 ) )
343 if name == block_name:
345 result = result + prefix +
'<b>' + name +
'</b>'
346 elif re_source_keywords.match( name ):
348 result = result + prefix + keyword_prefix + name + keyword_suffix
349 elif self.identifiers.has_key( name ):
352 result = result + prefix +
'<a href="' + \
366 print "<table cellpadding=3 border=0>"
368 if len( field.name ) > 22:
369 print "<tr valign=top><td colspan=0><b>" + field.name +
"</b></td></tr>"
370 print "<tr valign=top><td></td><td>"
372 print "<tr valign=top><td><b>" + field.name +
"</b></td><td>"
380 for field
in markup.fields:
386 table_fields.append( field )
414 print "<table align=center border=0 cellpadding=0 cellspacing=0>"
415 for r
in range( rows ):
417 for c
in range( self.
columns ):
422 line = line +
'<td><a href="' + url +
'">' + bname +
'</a></td>'
424 line = line +
'<td></td>'
425 line = line +
"</tr>"
430 print index_footer_start + \
439 if index_filename ==
None:
442 Formatter.index_dump( self, index_filename )
449 print "<center><h1>Table of Contents</h1></center>"
452 print chapter_header + string.join( chapter.title ) + chapter_inter
453 print "<table cellpadding=5>"
456 print '<tr valign=top><td class="left">'
458 section.title +
'</a></td><td>'
470 print chapter_header + \
471 '<a href="' + index_filename +
'">Global Index</a>' + \
472 chapter_inter + chapter_footer
475 print toc_footer_start + \
481 def toc_dump( self, toc_filename = None, index_filename = None ):
482 if toc_filename ==
None:
485 if index_filename ==
None:
488 Formatter.toc_dump( self, toc_filename, index_filename )
496 print section_title_header
498 print section_title_footer
501 for b
in section.blocks.values():
502 if len( b.name ) > maxwidth:
503 maxwidth = len( b.name )
508 print section_synopsis_header
509 print "<table align=center cellspacing=5 cellpadding=0 border=0>"
511 columns = width / maxwidth
515 count = len( section.block_names )
516 rows = ( count + columns - 1 ) / columns
518 for r
in range( rows ):
520 for c
in range( columns ):
522 line = line +
'<td></td><td>'
524 name = section.block_names[i]
525 line = line +
'<a href="#' + name +
'">' + name +
'</a>'
527 line = line +
'</td>'
528 line = line +
"</tr>"
531 print "</table><br><br>"
532 print section_synopsis_footer
534 print description_header
536 print description_footer
543 print '<h4><a name="' + block.name +
'">' + block.name +
'</a></h4>'
548 for f
in self.headers.keys():
549 if block.source.filename.find( f ) >= 0:
550 header = self.
headers[f] +
' (' + f +
')'
558 print header_location_header
559 print 'Defined in ' + header +
'.'
560 print header_location_footer
568 if markup.tag ==
"description":
569 print description_header
571 print marker_header + markup.tag + marker_inter
576 if markup.tag ==
"description":
577 print description_footer
582 print block_footer_start + self.
file_prefix +
"index.html" + \
583 block_footer_middle + self.
file_prefix +
"toc.html" + \