Commit b65ecbc8 authored by Michel Pelletier's avatar Michel Pelletier

details and flag not to munge docstrings

parent eefef3ed
......@@ -166,6 +166,7 @@ class Class(Named):
# Note that we don't use a function definition here, because
# we don't want to specify a signature!
__call__=Method("Instantiate instances of the class")
__bases__=Attribute("A sequence of base classes")
......
......@@ -2,24 +2,34 @@ import string
""" Pretty-Print an Interface object as structured text (Yum) """
def justify_and_indent(text, level, width=72):
def justify_and_indent(text, level, munge=0, width=72):
""" strip newlines, indent and justify text """
lines = []
line = " " * level
text = string.split(string.strip(string.translate(text, string.maketrans("\r\n", " "))))
if munge:
line = " " * level
for word in text:
line = string.join([line, word])
if len(line) > width:
text = string.split(string.strip(string.translate(text, string.maketrans("\r\n", " "))))
for word in text:
line = string.join([line, word])
if len(line) > width:
lines.append(line)
line = " " * level
else:
lines.append(line)
line = " " * level
return string.join(lines, "\n")
else:
lines.append(line)
text = string.split(string.replace(text,"\r\n", "\n"), "\n")
return string.join(lines, "\n")
for line in text:
lines.append( (" " * level) + line)
return string.join(lines, "\n")
def build_signature(meth):
""" this is a lot of work just to build a signature... """
......@@ -41,7 +51,9 @@ def build_signature(meth):
sig = sig + ")"
return sig
def interface_as_stx(I):
def interface_as_stx(I, munge=0):
""" Output structured text format. Note, this will wack any existing
'structured' format of the text. """
outp = "%s\n\n" % I.__name__
level = 1
......@@ -54,15 +66,19 @@ def interface_as_stx(I):
level = level + 1
for b in I.__bases__:
item = "o %s" % b.__name__
outp = outp + justify_and_indent(item, level) + "\n\n"
outp = outp + justify_and_indent(item, level, munge) + "\n\n"
level = level - 1
level = level + 1
for name, desc in I.namesAndDescriptions():
item = "%s%s -- %s" % (name, build_signature(desc), desc.__doc__)
outp = outp + justify_and_indent(item, level) + "\n\n"
outp = outp + justify_and_indent(item, level, munge) + "\n\n"
return outp
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment