--- a/docs/reference/reference.yml Wed Jun 28 11:12:40 2000 +0000
+++ b/docs/reference/reference.yml Wed Jun 28 14:52:43 2000 +0000
@@ -92,6 +92,17 @@
particular programming interface. The __init__ module
imports the key classes into the top level of the package.
+.h2 Overall Structure
+
+Abstractly Platypus currently can be thought of has having four
+levels: documents, pages, frames and flowables (things which can fit into frames in some way).
+In practice there is a fifth level, the canvas, so that if you want
+you can do anything that pdfgen's canvas allows.
+
+.h2 BaseDocTemplate
+.getClassDoc reportlab.platypus.doctemplate BaseDocTemplate
+
+.h2 Flowables
.getClassDoc reportlab.platypus.paragraph Paragraph
.pageBreak
@@ -126,6 +137,9 @@
.h1 Appendix A - CVS Revision History
.beginPre Code
$Log: reference.yml,v $
+Revision 1.9 2000/06/28 14:52:43 rgbecker
+Documentation changes
+
Revision 1.8 2000/06/19 23:52:31 andy_robinson
rltemplate now simple, based on UserDocTemplate
--- a/docs/tools/codegrab.py Wed Jun 28 11:12:40 2000 +0000
+++ b/docs/tools/codegrab.py Wed Jun 28 14:52:43 2000 +0000
@@ -11,208 +11,215 @@
import sys
class Struct:
- pass
+ pass
def getObjectsDefinedIn(modulename, directory=None):
- """Returns two tuple of (functions, classes) defined
- in the given module. 'directory' must be the directory
- containing the script; modulename should not include
- the .py suffix"""
+ """Returns two tuple of (functions, classes) defined
+ in the given module. 'directory' must be the directory
+ containing the script; modulename should not include
+ the .py suffix"""
- if directory:
- searchpath = [directory]
- else:
- searchpath = sys.path # searches usual Python path
+ if directory:
+ searchpath = [directory]
+ else:
+ searchpath = sys.path # searches usual Python path
- #might be a package. If so, check the top level
- #package is there, then recalculate the path needed
- words = string.split(modulename, '.')
- if len(words) > 1:
- packagename = words[0]
- packagefound = imp.find_module(packagename, searchpath)
- assert packagefound, "Package %s not found" % packagename
- (file, packagepath, description) = packagefound
- #now the full path should be known, if it is in the
- #package
-
- directory = apply(os.path.join, tuple([packagepath] + words[1:-1]))
- modulename = words[-1]
- searchpath = [directory]
+ #might be a package. If so, check the top level
+ #package is there, then recalculate the path needed
+ words = string.split(modulename, '.')
+ if len(words) > 1:
+ packagename = words[0]
+ packagefound = imp.find_module(packagename, searchpath)
+ assert packagefound, "Package %s not found" % packagename
+ (file, packagepath, description) = packagefound
+ #now the full path should be known, if it is in the
+ #package
+
+ directory = apply(os.path.join, tuple([packagepath] + words[1:-1]))
+ modulename = words[-1]
+ searchpath = [directory]
- #find and import the module.
- found = imp.find_module(modulename, searchpath)
- assert found, "Module %s not found" % modulename
- (file, pathname, description) = found
- mod = imp.load_module(modulename, file, pathname, description)
+ #find and import the module.
+ found = imp.find_module(modulename, searchpath)
+ assert found, "Module %s not found" % modulename
+ (file, pathname, description) = found
+ mod = imp.load_module(modulename, file, pathname, description)
- #grab the code too, minus trailing newlines
- lines = open(pathname, 'r').readlines()
- lines = map(string.rstrip, lines)
-
- result = Struct()
- result.functions = []
- result.classes = []
- result.doc = mod.__doc__
- for name in dir(mod):
- value = getattr(mod, name)
- if type(value) is types.FunctionType:
- path, file = os.path.split(value.func_code.co_filename)
- root, ext = os.path.splitext(file)
- #we're possibly interested in it
- if root == modulename:
- #it was defined here
- funcObj = value
- fn = Struct()
- fn.name = name
- fn.proto = getFunctionPrototype(funcObj, lines)
- if funcObj.__doc__:
- fn.doc = dedent(funcObj.__doc__)
- else:
- fn.doc = '(no documentation string)'
- #is it official?
- if name[0:1] == '_':
- fn.status = 'private'
- elif name[-1] in '0123456789':
- fn.status = 'experimental'
- else:
- fn.status = 'official'
-
- result.functions.append(fn)
- elif type(value) == types.ClassType:
- if value.__module__ == modulename:
- cl = Struct()
- cl.name = name
- if value.__doc__:
- cl.doc = dedent(value.__doc__)
- else:
- cl.doc = "(no documentation string)"
-
- cl.bases = []
- for base in value.__bases__:
- cl.bases.append(base.__name__)
- if name[0:1] == '_':
- cl.status = 'private'
- elif name[-1] in '0123456789':
- cl.status = 'experimental'
- else:
- cl.status = 'official'
-
- cl.methods = []
- #loop over dict finding methods defined here
- # Q - should we show all methods?
- # loop over dict finding methods defined here
- items = value.__dict__.items()
- items.sort()
- for (key2, value2) in items:
- if type(value2) <> types.FunctionType:
- continue # not a method
- elif os.path.splitext(value2.func_code.co_filename)[0] == modulename:
- continue # defined in base class
- else:
- #we want it
- meth = Struct()
- meth.name = key2
- meth.proto = getFunctionPrototype(value2, lines)
- if value2.__doc__:
- meth.doc = dedent(value2.__doc__)
- else:
- meth.doc = "(no documentation string)"
- #is it official?
- if key2[0:1] == '_':
- meth.status = 'private'
- elif key2[-1] in '0123456789':
- meth.status = 'experimental'
- else:
- meth.status = 'official'
- cl.methods.append(meth)
- result.classes.append(cl)
- return result
-
+ #grab the code too, minus trailing newlines
+ lines = open(pathname, 'r').readlines()
+ lines = map(string.rstrip, lines)
+
+ result = Struct()
+ result.functions = []
+ result.classes = []
+ result.doc = mod.__doc__
+ for name in dir(mod):
+ value = getattr(mod, name)
+ if type(value) is types.FunctionType:
+ path, file = os.path.split(value.func_code.co_filename)
+ root, ext = os.path.splitext(file)
+ #we're possibly interested in it
+ if root == modulename:
+ #it was defined here
+ funcObj = value
+ fn = Struct()
+ fn.name = name
+ fn.proto = getFunctionPrototype(funcObj, lines)
+ if funcObj.__doc__:
+ fn.doc = dedent(funcObj.__doc__)
+ else:
+ fn.doc = '(no documentation string)'
+ #is it official?
+ if name[0:1] == '_':
+ fn.status = 'private'
+ elif name[-1] in '0123456789':
+ fn.status = 'experimental'
+ else:
+ fn.status = 'official'
+
+ result.functions.append(fn)
+ elif type(value) == types.ClassType:
+ if value.__module__ == modulename:
+ cl = Struct()
+ cl.name = name
+ if value.__doc__:
+ cl.doc = dedent(value.__doc__)
+ else:
+ cl.doc = "(no documentation string)"
+
+ cl.bases = []
+ for base in value.__bases__:
+ cl.bases.append(base.__name__)
+ if name[0:1] == '_':
+ cl.status = 'private'
+ elif name[-1] in '0123456789':
+ cl.status = 'experimental'
+ else:
+ cl.status = 'official'
+
+ cl.methods = []
+ #loop over dict finding methods defined here
+ # Q - should we show all methods?
+ # loop over dict finding methods defined here
+ items = value.__dict__.items()
+ items.sort()
+ for (key2, value2) in items:
+ if type(value2) <> types.FunctionType:
+ continue # not a method
+ elif os.path.splitext(value2.func_code.co_filename)[0] == modulename:
+ continue # defined in base class
+ else:
+ #we want it
+ meth = Struct()
+ meth.name = key2
+ name2 = value2.func_code.co_name
+ meth.proto = getFunctionPrototype(value2, lines)
+ if name2!=key2:
+ meth.doc = 'pointer to '+name2
+ meth.proto = string.replace(meth.proto,name2,key2)
+ else:
+ if value2.__doc__:
+ meth.doc = dedent(value2.__doc__)
+ else:
+ meth.doc = "(no documentation string)"
+ #is it official?
+ if key2[0:1] == '_':
+ meth.status = 'private'
+ elif key2[-1] in '0123456789':
+ meth.status = 'experimental'
+ else:
+ meth.status = 'official'
+ cl.methods.append(meth)
+ result.classes.append(cl)
+ return result
def getFunctionPrototype(f, lines):
- """Pass in the function object and list of lines;
- it extracts the header as a multiline text block."""
- firstLineNo = f.func_code.co_firstlineno - 1
- lineNo = firstLineNo
- brackets = 0
- while 1:
- line = lines[lineNo]
- for char in line:
- if char == '(':
- brackets = brackets + 1
- elif char == ')':
- brackets = brackets - 1
- if brackets == 0:
- break
- else:
- lineNo = lineNo + 1
+ """Pass in the function object and list of lines;
+ it extracts the header as a multiline text block."""
+ firstLineNo = f.func_code.co_firstlineno - 1
+ lineNo = firstLineNo
+ brackets = 0
+ while 1:
+ line = lines[lineNo]
+ for char in line:
+ if char == '(':
+ brackets = brackets + 1
+ elif char == ')':
+ brackets = brackets - 1
+ if brackets == 0:
+ break
+ else:
+ lineNo = lineNo + 1
- usefulLines = lines[firstLineNo:lineNo+1]
- return string.join(usefulLines, '\n')
+ usefulLines = lines[firstLineNo:lineNo+1]
+ return string.join(usefulLines, '\n')
def dedent(comment):
- """Attempts to dedent the lines to the edge. Looks at no.
- of leading spaces in line 2, and removes up to that number
- of blanks from other lines."""
- commentLines = string.split(comment, '\n')
- if len(commentLines) < 2:
- cleaned = map(string.lstrip, commentLines)
- else:
- spc = 0
- for char in commentLines[1]:
- if char in string.whitespace:
- spc = spc + 1
- else:
- break
- #now check other lines
- cleaned = []
- for line in commentLines:
- for i in range(min(len(line),spc)):
- if line[0] in string.whitespace:
- line = line[1:]
- cleaned.append(line)
- return string.join(cleaned, '\n')
-
-
+ """Attempts to dedent the lines to the edge. Looks at no.
+ of leading spaces in line 2, and removes up to that number
+ of blanks from other lines."""
+ commentLines = string.split(comment, '\n')
+ if len(commentLines) < 2:
+ cleaned = map(string.lstrip, commentLines)
+ else:
+ spc = 0
+ for char in commentLines[1]:
+ if char in string.whitespace:
+ spc = spc + 1
+ else:
+ break
+ #now check other lines
+ cleaned = []
+ for line in commentLines:
+ for i in range(min(len(line),spc)):
+ if line[0] in string.whitespace:
+ line = line[1:]
+ cleaned.append(line)
+ return string.join(cleaned, '\n')
+
+
def dumpDoc(modulename, directory=None):
- """Test support. Just prints docco on the module
- to standard output."""
- docco = getObjectsDefinedIn(modulename, directory)
- print 'codegrab.py - ReportLab Documentation Utility'
- print 'documenting', modulename + '.py'
- print '-------------------------------------------------------'
- print
- if docco.functions == []:
- print 'No functions found'
- else:
- print 'Functions:'
- for f in docco.functions:
- print f.proto
- print ' ' + f.doc
+ """Test support. Just prints docco on the module
+ to standard output."""
+ docco = getObjectsDefinedIn(modulename, directory)
+ print 'codegrab.py - ReportLab Documentation Utility'
+ print 'documenting', modulename + '.py'
+ print '-------------------------------------------------------'
+ print
+ if docco.functions == []:
+ print 'No functions found'
+ else:
+ print 'Functions:'
+ for f in docco.functions:
+ print f.proto
+ print ' ' + f.doc
- if docco.classes == []:
- print 'No classes found'
- else:
- print 'Classes:'
- for c in docco.classes:
- print c.name
- print ' ' + c.doc
- for m in c.methods:
- print m.proto # it is already indented in the file!
- print ' ' + m.doc
- print
+ if docco.classes == []:
+ print 'No classes found'
+ else:
+ print 'Classes:'
+ for c in docco.classes:
+ print c.name
+ print ' ' + c.doc
+ for m in c.methods:
+ print m.proto # it is already indented in the file!
+ print ' ' + m.doc
+ print
-def test():
- dumpDoc('reportlab.platypus.paragraph')
+def test(m='reportlab.platypus.paragraph'):
+ dumpDoc(m)
if __name__=='__main__':
- import sys
- print 'Path to search:'
- for line in sys.path:
- print ' ',line
- test()
-
+ import sys
+ print 'Path to search:'
+ for line in sys.path:
+ print ' ',line
+ M = sys.argv[1:]
+ if M==[]:
+ M.append('reportlab.platypus.paragraph')
+ for m in M:
+ test(m)
--- a/docs/userguide/genuserguide.py Wed Jun 28 11:12:40 2000 +0000
+++ b/docs/userguide/genuserguide.py Wed Jun 28 14:52:43 2000 +0000
@@ -32,9 +32,12 @@
#
###############################################################################
# $Log: genuserguide.py,v $
+# Revision 1.11 2000/06/28 14:52:43 rgbecker
+# Documentation changes
+#
# Revision 1.10 2000/06/27 10:09:48 rgbecker
# Minor cosmetic changes
-#
+#
# Revision 1.9 2000/06/23 21:09:03 aaron_watters
# text text and more text
#
@@ -62,31 +65,46 @@
# Revision 1.1 2000/06/17 02:57:56 aaron_watters
# initial checkin. user guide generation framework.
#
-__version__=''' $Id: genuserguide.py,v 1.10 2000/06/27 10:09:48 rgbecker Exp $ '''
+__version__=''' $Id: genuserguide.py,v 1.11 2000/06/28 14:52:43 rgbecker Exp $ '''
__doc__ = """
This module contains the script for building the user guide.
"""
+_oldStyle=0 #change to 1 to get Aaron's original
+if _oldStyle:
+ from reportlab.lib.styles import getSampleStyleSheet
+ styleSheet = getSampleStyleSheet()
+else:
+ import os, sys
+ sys.path.insert(0,os.path.abspath(os.path.join('..','tools')))
+ from rltemplate import RLDocTemplate
+ from stylesheet import getStyleSheet
+ styleSheet = getStyleSheet()
+
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus.flowables import Flowable
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import letter
from reportlab.platypus import Paragraph, Spacer, Preformatted, PageBreak, CondPageBreak
-from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
+from reportlab.lib.styles import ParagraphStyle
from reportlab.lib import colors
import examples
-styleSheet = getSampleStyleSheet()
from reportlab.lib.corp import ReportLabLogo
LOGO = ReportLabLogo(0.25*inch, 0.25*inch, inch, 0.75*inch)
from t_parse import Template
QFcodetemplate = Template("X$X$", "X")
-codesubst = "%s<font name=courier color=green>%s</font>"
QFreptemplate = Template("X^X^", "X")
-QFsubst = "%s<font name=Helvetica color=blue><i>%s</i></font>"
+if _oldStyle:
+ codesubst = "%s<font name=courier color=green>%s</font>"
+ QFsubst = "%s<font name=Helvetica color=blue><i>%s</i></font>"
+else:
+ codesubst = "%s<b><font name=courier>i</b>%s</font>"
+ QFsubst = "%s<font name=Helvetica><i>%s</i></font>"
+
def quickfix(text):
"""inside text find any subsequence of form $subsequence$.
@@ -117,44 +135,53 @@
return text
#print quickfix("$testing$ testing $one$ ^two^ $three(^four^)$")
-class PageAnnotations:
- """ "closure" containing onfirstpage, onnextpage actions
- and any data they might want to use.
- """
- pagesize = letter
- pagenumber = 1
- def onFirstPage(self, canvas, doc):
- (xsize, ysize) = self.pagesize
- LOGO.draw(canvas)
- # width=6.25*inch,height=0.62*inch)
- canvas.setFont("Helvetica", 12)
- canvas.drawRightString(xsize-inch, ysize-0.8*inch, "ReportLab User Guide")
- self.pagenumber = self.pagenumber+1
- def onNextPage(self, canvas, doc):
- canvas.saveState()
- (xsize, ysize) = self.pagesize
- canvas.setFont("Helvetica", 12)
- canvas.drawString(inch, ysize-0.8*inch, "Page %s" % self.pagenumber)
- self.onFirstPage(canvas, doc)
- canvas.restoreState()
+if _oldStyle:
+ class PageAnnotations:
+ """ "closure" containing onfirstpage, onnextpage actions
+ and any data they might want to use.
+ """
+ pagesize = letter
+ pagenumber = 1
+ def onFirstPage(self, canvas, doc):
+ (xsize, ysize) = self.pagesize
+ LOGO.draw(canvas)
+ # width=6.25*inch,height=0.62*inch)
+ canvas.setFont("Helvetica", 12)
+ canvas.drawRightString(xsize-inch, ysize-0.8*inch, "ReportLab User Guide")
+ self.pagenumber = self.pagenumber+1
+ def onNextPage(self, canvas, doc):
+ canvas.saveState()
+ (xsize, ysize) = self.pagesize
+ canvas.setFont("Helvetica", 12)
+ canvas.drawString(inch, ysize-0.8*inch, "Page %s" % self.pagenumber)
+ self.onFirstPage(canvas, doc)
+ canvas.restoreState()
class Guide:
def __init__(self):
- self.myannotations = PageAnnotations()
+ if _oldStyle:
+ self.myannotations = PageAnnotations()
self.story = story()
def go(self, filename="userguide.pdf"):
# generate the doc...
- doc = SimpleDocTemplate(filename,pagesize = letter ,showBoundary=0,
- leftMargin=inch, rightMargin=inch, topMargin=1*inch, bottomMargin=inch)
- story = self.story
- doc.build(story, self.myannotations.onFirstPage, self.myannotations.onNextPage)
+ doc = RLDocTemplate(filename,pagesize = letter)
+ story = self.story
+ if _oldStyle:
+ doc.build(story, self.myannotations.onFirstPage, self.myannotations.onNextPage)
+ else:
+ doc.build(story)
-H = styleSheet['Heading2']
-lessonnamestyle = ParagraphStyle("lessonname", parent=H)
-lessonnamestyle.fontName = 'Helvetica-Bold'
+H1 = styleSheet['Heading1']
+H2 = styleSheet['Heading2']
B = styleSheet['BodyText']
-discussiontextstyle = ParagraphStyle("discussiontext", parent=B)
-discussiontextstyle.fontName= 'Helvetica'
+if _oldStyle:
+ lessonnamestyle = ParagraphStyle("lessonname", parent=H2)
+ lessonnamestyle.fontName = 'Helvetica-Bold'
+ discussiontextstyle = ParagraphStyle("discussiontext", parent=B)
+ discussiontextstyle.fontName= 'Helvetica'
+else:
+ lessonnamestyle = H2
+ discussiontextstyle = B
exampletextstyle = styleSheet['Code']
# size for every example
examplefunctionxinches = 5.5
@@ -184,15 +211,18 @@
# an
# example""")
-def head(text):
+def head(text,style=lessonnamestyle):
BODY.append(CondPageBreak(inch))
- disc(text, style=lessonnamestyle)
+ disc(text, style=style)
+
+def title(text):
+ disc(text,style=styleSheet['Title'])
#head("this is a header")
def lesson(text):
BODY.append(PageBreak())
- head(text)
+ head(text,style=H1)
def canvasdemo(function):
BODY.append(Spacer(0.1*inch, 0.1*inch))
@@ -242,7 +272,8 @@
#pencilnote()
-head("ReportLab User Guide")
+title("ReportLab User Guide")
+head("Introduction",style=H1)
disc("""
This document is intended to be a conversational introduction
--- a/reportlab/platypus/doctemplate.py Wed Jun 28 11:12:40 2000 +0000
+++ b/reportlab/platypus/doctemplate.py Wed Jun 28 14:52:43 2000 +0000
@@ -31,9 +31,12 @@
#
###############################################################################
# $Log: doctemplate.py,v $
+# Revision 1.22 2000/06/28 14:52:43 rgbecker
+# Documentation changes
+#
# Revision 1.21 2000/06/26 15:58:22 rgbecker
# Simple fix to widths problem
-#
+#
# Revision 1.20 2000/06/21 12:27:42 rgbecker
# remove UserDocTemplate, but add Andy's hook methods
#
@@ -96,7 +99,7 @@
# Revision 1.1 2000/05/12 12:53:33 rgbecker
# Initial try at a document template class
#
-__version__=''' $Id: doctemplate.py,v 1.21 2000/06/26 15:58:22 rgbecker Exp $ '''
+__version__=''' $Id: doctemplate.py,v 1.22 2000/06/28 14:52:43 rgbecker Exp $ '''
__doc__="""
This module contains the core structure of platypus.
@@ -226,9 +229,9 @@
EXCEPTION: doctemplate.build(...) must be called for most reasonable uses
since it builds a document using the page template.
- Each document template builds exactly one document into a file specified
- by the filename argument on initialization.
-
+ Each document template builds exactly one document into a file specified
+ by the filename argument on initialization.
+
Possible keyword arguments for the initialization:
pageTemplates: A list of templates. Must be nonempty. Names
@@ -238,7 +241,7 @@
a chapter and two more for the interior of a chapter on odd and even pages.
If this argument is omitted then at least one pageTemplate should be provided
using the addPageTemplates method before the document is built.
- showBoundary: (for debugging) if set draw a box around the frame boundaries.
+ showBoundary: if set draw a box around the frame boundaries.
leftMargin:
rightMargin:
topMargin: