1,6 → 1,6 |
#!/usr/bin/env python |
# -*- coding: Utf8 -*- |
"""Generate Python documentation in HTML for Scribus. |
"""Generate Python documentation in clean and nice HTML for Scribus. |
Based on the PyDoc package. |
""" |
__author__ = "Petr Vanek <petr@yarpen.cz>" |
325,23 → 325,18 |
''' % (title, extras or ' ') |
|
def section(self, title, fgcol, bgcol, contents, width=6, |
prelude='', marginalia=None, gap=' '): |
prelude='', marginalia=None, gap=' '): |
"""Format a section with a heading.""" |
if marginalia is None: |
marginalia = '<tt>' + ' ' * width + '</tt>' |
result = '''<p> |
#marginalia = '<tt>' + ' ' * width + '</tt>' |
pass |
result = ''' |
<h4>debug_Section: "%s"</h4> |
''' % (title) |
if prelude: |
result = result + ''' |
<p>debug_Marginalia1: %s</p> |
<p>debug_Prelude: %s</p> |
''' % (marginalia, prelude) |
else: |
result = result + ''' |
<p>debug_Marginalia2: %s |
''' % (marginalia) |
|
''' % (prelude) |
return result + ''' |
<p>debug_Contents: %s</p> |
''' % contents |
354,20 → 349,21 |
def preformat(self, text): |
"""Format literal preformatted text.""" |
text = self.escape(expandtabs(text)) |
return replace(text, '\n\n', '\n \n', '\n\n', '\n \n', |
' ', ' ', '\n', '<br>\n') |
return replace(text, '\n\n', '\n \n', '\n\n', '\n \n') |
#'\n', '<br>\n') |
|
def multicolumn(self, list, format, cols=4): |
"""Format a list of items into a multi-column list.""" |
result = '' |
"""result = '' |
rows = (len(list)+cols-1)/cols |
for col in range(cols): |
result = result + '<td width="%d%%" valign=top>' % (100/cols) |
#result = result + '<td width="%d%%" valign=top>' % (100/cols) |
for i in range(rows*col, rows*col+rows): |
if i < len(list): |
result = result + format(list[i]) + '<br>\n' |
result = result + format(list[i]) + ' ' |
result = result + '</td>' |
return '<table width="100%%" summary="list"><tr>%s</tr></table>' % result |
return '<p>%s</p>' % result""" |
pass |
|
def grey(self, text): return '<p>debug_Grey: %s</p>' % text |
|
468,10 → 464,10 |
links = [] |
for i in range(len(parts)-1): |
links.append( |
'<a href="%s.html"><font color="#ffffff">%s</font></a>' % |
'<a href="%s.html">%s</a>' % |
(join(parts[:i+1], '.'), parts[i])) |
linkedname = join(links + parts[-1:], '.') |
head = '<big><big><strong>%s</strong></big></big>' % linkedname |
head = '<h5>debug_Linkedname:%s</h5>' % linkedname |
try: |
path = inspect.getabsfile(object) |
url = path |
591,12 → 587,13 |
|
# Cute little class to pump out a horizontal rule between sections. |
class HorizontalRule: |
def __init__(self): |
pass |
"""def __init__(self): |
self.needone = 0 |
def maybe(self): |
if self.needone: |
push('<hr>\n') |
self.needone = 1 |
self.needone = 1""" |
hr = HorizontalRule() |
|
# List the mro, if non-trivial. |
603,11 → 600,10 |
mro = list(inspect.getmro(object)) |
if len(mro) > 2: |
hr.maybe() |
push('<dl><dt>Method resolution order:</dt>\n') |
push('<p>Method resolution order:</p>\n') |
for base in mro: |
push('<dd>%s</dd>\n' % self.classlink(base, |
object.__module__)) |
push('</dl>\n') |
push('%s<br>\n' % self.classlink(base, object.__module__)) |
push('\n') |
|
def spill(msg, attrs, predicate): |
ok, attrs = _split_list(attrs, predicate) |
713,10 → 709,10 |
contents = ''.join(contents) |
|
if name == realname: |
title = '<a name="%s">class <strong>%s</strong></a>' % ( |
title = '<a name="%s">class <code>%s</code></a>' % ( |
name, realname) |
else: |
title = '<strong>%s</strong> = <a name="%s">class %s</a>' % ( |
title = '<code>%s</code> = <a name="%s">class %s</a>' % ( |
name, name, realname) |
if bases: |
parents = [] |
754,7 → 750,7 |
object = object.im_func |
|
if name == realname: |
title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname) |
title = '<a name="%s">%s</a>' % (anchor, realname) |
else: |
if (cl and realname in cl.__dict__ and |
cl.__dict__[realname] is object): |
763,7 → 759,7 |
skipdocs = 1 |
else: |
reallink = realname |
title = '<a name="%s"><strong>%s</strong></a> = %s' % ( |
title = '<a name="%s">%s</a> = %s' % ( |
anchor, name, reallink) |
if inspect.isfunction(object): |
args, varargs, varkw, defaults = inspect.getargspec(object) |
770,13 → 766,13 |
argspec = inspect.formatargspec( |
args, varargs, varkw, defaults, formatvalue=self.formatvalue) |
if realname == '<lambda>': |
title = '<strong>%s</strong> <em>lambda</em> ' % name |
title = '%s <i>lambda</i> ' % name |
argspec = argspec[1:-1] # remove parentheses |
else: |
argspec = '(...)' |
|
decl = title + argspec + (note and self.grey( |
'<font face="helvetica, arial">%s</font>' % note)) |
'%s' % note)) |
|
if skipdocs: |
return '<dl><dt>%s</dt></dl>\n' % decl |
788,8 → 784,8 |
|
def docother(self, object, name=None, mod=None, *ignored): |
"""Produce HTML documentation for a data object.""" |
lhs = name and '<strong>%s</strong> = ' % name or '' |
return lhs + self.repr(object) |
lhs = name and 'debug_Docother: %s = ' % name or '' |
return lhs + self.repr(object) + '<br>' |
|
def index(self, dir, shadowed=None): |
"""Generate an HTML index for a directory of modules.""" |