docs/userguide/genuserguide.py
author rgbecker
Fri, 14 Jul 2000 10:49:22 +0000
changeset 384 286a631ebdbc
parent 381 2ca856765ed1
child 400 2c967654b495
permissions -rw-r--r--
Added space, optional bullet and eg after spacing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     1
#!/bin/env python
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     2
###############################################################################
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     3
#
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
     4
#   ReportLab Public License Version 1.0
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     5
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     6
#   Except for the change of names the spirit and intention of this
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     7
#   license is the same as that of Python
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
     8
#
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
     9
#   (C) Copyright ReportLab Inc. 1998-2000.
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    10
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    11
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    12
# All Rights Reserved
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    13
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    14
# Permission to use, copy, modify, and distribute this software and its
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    15
# documentation for any purpose and without fee is hereby granted, provided
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    16
# that the above copyright notice appear in all copies and that both that
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    17
# copyright notice and this permission notice appear in supporting
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    18
# documentation, and that the name of ReportLab not be used
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    19
# in advertising or publicity pertaining to distribution of the software
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    20
# without specific, written prior permission. 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    21
# 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    22
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    23
# Disclaimer
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    24
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    25
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    26
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    27
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    28
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    29
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    30
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    31
# PERFORMANCE OF THIS SOFTWARE. 
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    32
#
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
    33
###############################################################################
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    34
#   $Log: genuserguide.py,v $
384
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
    35
#   Revision 1.31  2000/07/14 10:49:22  rgbecker
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
    36
#   Added space, optional bullet and eg after spacing
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
    37
#
381
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
    38
#   Revision 1.30  2000/07/13 20:36:02  aaron_watters
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
    39
#   various mods
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
    40
#
371
4b5524993d85 More demos in appendix
rgbecker
parents: 370
diff changeset
    41
#   Revision 1.29  2000/07/13 12:38:56  rgbecker
4b5524993d85 More demos in appendix
rgbecker
parents: 370
diff changeset
    42
#   More demos in appendix
4b5524993d85 More demos in appendix
rgbecker
parents: 370
diff changeset
    43
#
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
    44
#   Revision 1.28  2000/07/13 12:18:32  rgbecker
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
    45
#   begin app_demos.py
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
    46
#
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
    47
#   Revision 1.27  2000/07/13 11:59:45  rgbecker
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
    48
#   Added some more
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
    49
#
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
    50
#   Revision 1.26  2000/07/10 23:56:09  andy_robinson
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
    51
#   Paragraphs chapter pretty much complete.  Fancy cover.
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
    52
#
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
    53
#   Revision 1.25  2000/07/10 14:20:15  andy_robinson
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
    54
#   Broke up the user guide into chapters.
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
    55
#
340
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
    56
#   Revision 1.24  2000/07/10 12:00:17  andy_robinson
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
    57
#   More work on chapter 1
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
    58
#
337
76141601ec1f Broke out chapter 1
andy_robinson
parents: 336
diff changeset
    59
#   Revision 1.23  2000/07/08 13:24:27  andy_robinson
76141601ec1f Broke out chapter 1
andy_robinson
parents: 336
diff changeset
    60
#   Broke out chapter 1
76141601ec1f Broke out chapter 1
andy_robinson
parents: 336
diff changeset
    61
#
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
    62
#   Revision 1.22  2000/07/08 12:52:25  andy_robinson
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
    63
#   Separated out actual text from genuserguide, so it can be broken into
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
    64
#   chapters.
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
    65
#
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
    66
#   Revision 1.21  2000/07/07 22:55:31  andy_robinson
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
    67
#   Added paragraph examples and widget to User Guide
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
    68
#
331
df7a5344d9e3 More on paragraphs
rgbecker
parents: 330
diff changeset
    69
#   Revision 1.20  2000/07/07 16:18:37  rgbecker
df7a5344d9e3 More on paragraphs
rgbecker
parents: 330
diff changeset
    70
#   More on paragraphs
df7a5344d9e3 More on paragraphs
rgbecker
parents: 330
diff changeset
    71
#
330
e392b1be9211 Start on Paragraph
rgbecker
parents: 328
diff changeset
    72
#   Revision 1.19  2000/07/07 15:09:21  rgbecker
e392b1be9211 Start on Paragraph
rgbecker
parents: 328
diff changeset
    73
#   Start on Paragraph
e392b1be9211 Start on Paragraph
rgbecker
parents: 328
diff changeset
    74
#
328
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
    75
#   Revision 1.18  2000/07/06 15:38:15  rgbecker
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
    76
#   Started on Tables added EmbeddedCode utility
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
    77
#
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
    78
#   Revision 1.17  2000/07/05 16:06:01  rgbecker
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
    79
#   Platypus Start
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
    80
#
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
    81
#   Revision 1.16  2000/07/04 22:22:40  andy_robinson
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
    82
#   Tidied up genuserguide.py, especially figure handling; began
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
    83
#   adding PDF special features docco
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
    84
#
318
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
    85
#   Revision 1.15  2000/07/03 16:03:31  andy_robinson
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
    86
#   Changes to heading structure
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
    87
#
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    88
#   Revision 1.14  2000/07/03 15:50:31  andy_robinson
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    89
#   Pushed down most existing lessons one level; added
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    90
#   functions heading1..heading3 for building story
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    91
#   unambiguously; spelled Hugh Hefner right!
314
72c75740504b abspath is 1.5.2 only
rgbecker
parents: 311
diff changeset
    92
#
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    93
#   Revision 1.13  2000/07/03 09:51:38  rgbecker
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    94
#   abspath is 1.5.2 only
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    95
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    96
#   Revision 1.12  2000/06/28 16:10:00  rgbecker
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    97
#   Fix unwanted 'i'
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    98
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
    99
#   Revision 1.11  2000/06/28 14:52:43  rgbecker
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   100
#   Documentation changes
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   101
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   102
#   Revision 1.10  2000/06/27 10:09:48  rgbecker
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   103
#   Minor cosmetic changes
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   104
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   105
#   Revision 1.9  2000/06/23 21:09:03  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   106
#   text text and more text
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   107
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   108
#   Revision 1.8  2000/06/22 19:05:24  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   109
#   added quickhack for font changes in paragraphs and lots of new text
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   110
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   111
#   Revision 1.7  2000/06/22 13:55:59  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   112
#   showPage resets all state parameters warning.
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   113
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   114
#   Revision 1.6  2000/06/22 13:35:28  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   115
#   textobject and pathobject methods, among other things
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   116
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   117
#   Revision 1.5  2000/06/21 21:19:29  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   118
#   colors, line styles, more examples
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   119
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   120
#   Revision 1.4  2000/06/21 15:16:05  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   121
#   Lots of graphical examples added
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   122
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   123
#   Revision 1.3  2000/06/20 20:31:42  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   124
#   typos and more examples
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   125
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   126
#   Revision 1.2  2000/06/19 21:13:02  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   127
#   2nd try. more text
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   128
#   
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   129
#   Revision 1.1  2000/06/17 02:57:56  aaron_watters
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   130
#   initial checkin. user guide generation framework.
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   131
#   
384
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   132
__version__=''' $Id: genuserguide.py,v 1.31 2000/07/14 10:49:22 rgbecker Exp $ '''
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   133
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   134
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   135
__doc__ = """
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   136
This module contains the script for building the user guide.
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   137
"""
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   138
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   139
import os, sys
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   140
import string
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   141
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   142
sys.path.insert(0,os.path.join(os.path.dirname(sys.argv[0]),'..','tools'))
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   143
from rltemplate import RLDocTemplate
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   144
from stylesheet import getStyleSheet
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   145
styleSheet = getStyleSheet()
310
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   146
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   147
#from reportlab.platypus.doctemplate import SimpleDocTemplate
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   148
from reportlab.lib.units import inch
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   149
from reportlab.lib.pagesizes import letter
328
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   150
from reportlab.platypus import Paragraph, Spacer, Preformatted,\
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   151
            PageBreak, CondPageBreak, Flowable, Table, TableStyle, \
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   152
            NextPageTemplate, KeepTogether
310
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   153
from reportlab.lib.styles import ParagraphStyle
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   154
from reportlab.lib import colors
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   155
from reportlab.lib.sequencer import getSequencer
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   156
import examples
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   157
import platdemos
328
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   158
import StringIO
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
   159
appmode=0
318
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   160
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   161
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   162
from reportlab.lib.corp import ReportLabLogo
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   163
LOGO = ReportLabLogo(0.25*inch, 0.25*inch, inch, 0.75*inch)
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   164
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   165
from t_parse import Template
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   166
QFcodetemplate = Template("X$X$", "X")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   167
QFreptemplate = Template("X^X^", "X")
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   168
codesubst = "%s<font name=Courier>%s</font>"
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   169
QFsubst = "%s<font name=Courier><i>%s</i></font>"
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   170
    
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   171
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   172
def quickfix(text):
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   173
    """inside text find any subsequence of form $subsequence$.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   174
       Format the subsequence as code.  If similarly if text contains ^arg^
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   175
       format the arg as replaceable.  The escape sequence for literal
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   176
       $ is $\\$ (^ is ^\\^.
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   177
    """
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   178
    from string import join
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   179
    for (template,subst) in [(QFcodetemplate, codesubst), (QFreptemplate, QFsubst)]:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   180
        fragment = text
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   181
        parts = []
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   182
        try:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   183
            while fragment:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   184
                try:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   185
                    (matches, index) = template.PARSE(fragment)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   186
                except: raise ValueError
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   187
                else:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   188
                    [prefix, code] = matches
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   189
                    if code == "\\":
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   190
                        part = fragment[:index]
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   191
                    else:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   192
                        part = subst % (prefix, code)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   193
                    parts.append(part)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   194
                    fragment = fragment[index:]
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   195
        except ValueError:
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   196
            parts.append(fragment)
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   197
        text = join(parts, "")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   198
    return text
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   199
#print quickfix("$testing$ testing $one$ ^two^ $three(^four^)$")
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   200
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   201
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   202
310
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   203
H1 = styleSheet['Heading1']
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   204
H2 = styleSheet['Heading2']
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   205
H3 = styleSheet['Heading3']
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   206
H4 = styleSheet['Heading4']
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   207
B = styleSheet['BodyText']
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   208
BU = styleSheet['Bullet']
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   209
Comment = styleSheet['Comment']
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   210
Centred = styleSheet['Centred']
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   211
Caption = styleSheet['Caption']
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   212
318
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   213
#set up numbering
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   214
seq = getSequencer()
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   215
seq.setFormat('Chapter','1')
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   216
seq.setFormat('Section','1')
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   217
seq.setFormat('Appendix','A')
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   218
seq.setFormat('Figure', '1')
318
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   219
seq.chain('Chapter','Section')
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   220
seq.chain('Chapter','Figure')
318
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   221
03c9f114c621 Changes to heading structure
andy_robinson
parents: 317
diff changeset
   222
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   223
lessonnamestyle = H2
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   224
discussiontextstyle = B
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   225
exampletextstyle = styleSheet['Code']
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   226
# size for every example
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   227
examplefunctionxinches = 5.5
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   228
examplefunctionyinches = 3
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   229
examplefunctiondisplaysizes = (examplefunctionxinches*inch, examplefunctionyinches*inch)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   230
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   231
# for testing
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   232
def NOP(*x,**y):
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   233
    return None
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   234
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   235
def CPage(inches):
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   236
    getStory().append(CondPageBreak(inches*inch))
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   237
    
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   238
def newPage():
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   239
    getStory().append(PageBreak())
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   240
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   241
def nextTemplate(templName):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   242
    f = NextPageTemplate(templName)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   243
    getStory().append(f)
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   244
    
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   245
def disc(text, klass=Paragraph, style=discussiontextstyle):
301
5ad57f31ae75 added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents: 300
diff changeset
   246
    text = quickfix(text)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   247
    P = klass(text, style)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   248
    getStory().append(P)
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   249
340
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   250
def restartList():
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   251
    getSequencer().reset('list1')
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   252
384
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   253
def list(text, doBullet=1):
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   254
    text=quickfix(text)
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   255
    if doBullet:
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   256
        text='<bullet><seq id="list1"/>.</bullet>'+text
340
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   257
    P = Paragraph(text, BU)
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   258
    getStory().append(P)
f3f2af39e7d7 More work on chapter 1
andy_robinson
parents: 337
diff changeset
   259
    
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   260
def bullet(text):
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   261
    text='<bullet><font name="Symbol">'+chr(183)+'</font></bullet>' + quickfix(text)
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   262
    P = Paragraph(text, BU)
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   263
    getStory().append(P)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   264
    
384
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   265
def eg(text,before=0.1,after=0):
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   266
    space(before)
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   267
    disc(text, klass=Preformatted, style=exampletextstyle)
384
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   268
    space(after)
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   269
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   270
def space(inches=1./6):
286a631ebdbc Added space, optional bullet and eg after spacing
rgbecker
parents: 381
diff changeset
   271
	if inches: getStory().append(Spacer(0,inches*inch))
328
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   272
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   273
def EmbeddedCode(code,name='t', fn='embedded.tmp'):
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   274
    eg(code)
e0122856a912 Started on Tables added EmbeddedCode utility
rgbecker
parents: 323
diff changeset
   275
    disc("produces")
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   276
    exec code+("\ngetStory().append(%s)\n"%name)
310
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   277
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   278
def startKeep():
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   279
    return len(getStory())
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   280
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   281
def endKeep(s):
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   282
    S = getStory()
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   283
    k = KeepTogether(S[s:])
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   284
    S[s:] = [k]
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   285
 
310
cbec783cfb81 Documentation changes
rgbecker
parents: 308
diff changeset
   286
def title(text):
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   287
    """Use this for the document title only"""
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   288
    disc(text,style=styleSheet['Title'])
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   289
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   290
#AR 3/7/2000 - defining three new levels of headings; code
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   291
#should be swapped over to using them.
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   292
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   293
def heading1(text):
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   294
    """Use this for chapters.  Lessons within a big chapter
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   295
    should now use heading2 instead.  Chapters get numbered."""
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   296
    getStory().append(PageBreak())
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   297
    p = Paragraph('Chapter <seq id="Chapter"/> - ' + quickfix(text), H1)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   298
    getStory().append(p)
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   299
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
   300
def Appendix1(text,):
371
4b5524993d85 More demos in appendix
rgbecker
parents: 370
diff changeset
   301
    global appmode
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   302
    getStory().append(PageBreak())
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
   303
    if not appmode:
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   304
        seq.setFormat('Chapter','A')
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   305
        seq.reset('Chapter')
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
   306
        appmode = 1
369
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   307
    p = Paragraph('Appendix <seq id="Chapter"/> - ' + quickfix(text), H1)
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   308
    getStory().append(p)
53a1b7bd93ff Added some more
rgbecker
parents: 344
diff changeset
   309
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   310
def heading2(text):
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   311
    """Used to be 'lesson'"""
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   312
    getStory().append(CondPageBreak(inch))
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   313
    p = Paragraph('<seq template="%(Chapter)s.%(Section+)s - "/>' + quickfix(text), H2)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   314
    getStory().append(p)
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   315
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   316
def heading3(text):
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   317
    """Used to be most of the plain old 'head' sections"""
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   318
    getStory().append(CondPageBreak(inch))
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   319
    p = Paragraph(quickfix(text), H3)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   320
    getStory().append(p)
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   321
 
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   322
def heading4(text):
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   323
    """Used to be most of the plain old 'head' sections"""
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   324
    getStory().append(CondPageBreak(inch))
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   325
    p = Paragraph(quickfix(text), H4)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   326
    getStory().append(p)
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   327
    
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   328
def todo(text):
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   329
    """Used for notes to ourselves"""
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   330
    getStory().append(Paragraph(quickfix(text), Comment))
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   331
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   332
def centred(text):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   333
    getStory().append(Paragraph(quickfix(text), Centred))
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   334
                      
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   335
def caption(text):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   336
    getStory().append(Paragraph(quickfix(text), Caption))
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   337
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   338
class Illustration(platdemos.Figure):
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   339
    """The examples are all presented as functions which do
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   340
    something to a canvas, with a constant height and width
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   341
    used.  This puts them inside a figure box with a caption."""
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   342
    
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   343
    def __init__(self, operation, caption):
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   344
        stdwidth, stdheight = examplefunctiondisplaysizes
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   345
        #platdemos.Figure.__init__(self, stdwidth * 0.75, stdheight * 0.75)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   346
        platdemos.Figure.__init__(self, stdwidth, stdheight,
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   347
                    'Figure <seq template="%(Chapter)s-%(Figure+)s"/>: ' + quickfix(caption))
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   348
        self.operation = operation
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   349
        
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   350
    def drawFigure(self):
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   351
        #shrink it a little...
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   352
        #self.canv.scale(0.75, 0.75)
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   353
        self.operation(self.canv)
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   354
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   355
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   356
def illust(operation, caption):
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   357
    i = Illustration(operation, caption)
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   358
    getStory().append(i)
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   359
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   360
class ParaBox(platdemos.Figure):
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   361
    """Illustrates paragraph examples, with style attributes on the left"""
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   362
    descrStyle = ParagraphStyle('description',
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   363
                                fontName='Courier',
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   364
                                fontSize=8,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   365
                                leading=9.6)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   366
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   367
    def __init__(self, text, style, caption):
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   368
        platdemos.Figure.__init__(self, 0, 0, caption)
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   369
        self.text = text
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   370
        self.style = style
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   371
        self.para = Paragraph(text, style)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   372
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   373
        styleText = self.getStyleText(style)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   374
        self.pre = Preformatted(styleText, self.descrStyle)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   375
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   376
    def wrap(self, availWidth, availHeight):
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   377
        """Left 30% is for attributes, right 50% for sample,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   378
        10% gutter each side."""
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   379
        self.x0 = availWidth * 0.05  #left of box
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   380
        self.x1 = availWidth * 0.1   #left of descriptive text
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   381
        self.x2 = availWidth * 0.5   #left of para itself
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   382
        self.x3 = availWidth * 0.9   #right of para itself
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   383
        self.x4 = availWidth * 0.95  #right of box
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   384
        self.width = self.x4 - self.x0
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   385
        self.dx = 0.5 * (availWidth - self.width)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   386
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   387
        paw, self.pah = self.para.wrap(self.x3 - self.x2, availHeight)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   388
        self.pah = self.pah + self.style.spaceBefore + self.style.spaceAfter
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   389
        prw, self.prh = self.pre.wrap(self.x2 - self.x1, availHeight)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   390
        self.figureHeight = max(self.prh, self.pah) * 10.0/9.0
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   391
        return platdemos.Figure.wrap(self, availWidth, availHeight)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   392
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   393
    def getStyleText(self, style):
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   394
        """Converts style to preformatted block of text"""
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   395
        lines = []
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   396
        for (key, value) in style.__dict__.items():
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   397
            lines.append('%s = %s' % (key, value))
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   398
        lines.sort()
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   399
        return string.join(lines, '\n')        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   400
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   401
    def drawFigure(self):
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   402
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   403
        #now we fill in the bounding box and before/after boxes       
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   404
        self.canv.saveState()
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   405
        self.canv.setFillGray(0.95)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   406
        self.canv.setDash(1,3)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   407
        self.canv.rect(self.x2 - self.x0,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   408
                       self.figureHeight * 0.95 - self.pah,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   409
                       self.x3-self.x2, self.para.height,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   410
                       fill=1,stroke=1)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   411
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   412
        self.canv.setFillGray(0.90)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   413
        self.canv.rect(self.x2 - self.x0, #spaceBefore
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   414
                       self.figureHeight * 0.95 - self.pah + self.para.height,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   415
                       self.x3-self.x2, self.style.spaceBefore,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   416
                       fill=1,stroke=1)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   417
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   418
        self.canv.rect(self.x2 - self.x0, #spaceBefore
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   419
                       self.figureHeight * 0.95 - self.pah - self.style.spaceAfter,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   420
                       self.x3-self.x2, self.style.spaceAfter,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   421
                       fill=1,stroke=1)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   422
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   423
        self.canv.restoreState()
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   424
        #self.canv.setFillColor(colors.yellow)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   425
        self.para.drawOn(self.canv, self.x2 - self.x0,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   426
                         self.figureHeight * 0.95 - self.pah)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   427
        self.pre.drawOn(self.canv, self.x1 - self.x0,
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   428
                         self.figureHeight * 0.95 - self.prh)
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   429
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   430
        
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   431
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   432
    def getStyleText(self, style):
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   433
        """Converts style to preformatted block of text"""
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   434
        lines = []
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   435
        for (key, value) in style.__dict__.items():
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   436
            if key not in ('name','parent'):
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   437
                lines.append('%s = %s' % (key, value))
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   438
        return string.join(lines, '\n')
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   439
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   440
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   441
class ParaBox2(platdemos.Figure):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   442
    """Illustrates a paragraph side-by-side with the raw
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   443
    text, to show how the XML works."""
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   444
    def __init__(self, text, caption):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   445
        platdemos.Figure.__init__(self, 0, 0, caption)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   446
        descrStyle = ParagraphStyle('description',
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   447
                                fontName='Courier',
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   448
                                fontSize=8,
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   449
                                leading=9.6)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   450
        textStyle = B
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   451
        self.text = text
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   452
        self.left = Paragraph('<![CDATA[' + text + ']]>', descrStyle)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   453
        self.right = Paragraph(text, B)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   454
        
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   455
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   456
    def wrap(self, availWidth, availHeight):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   457
        self.width = availWidth * 0.9
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   458
        colWidth = 0.4 * self.width
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   459
        lw, self.lh = self.left.wrap(colWidth, availHeight)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   460
        rw, self.rh = self.right.wrap(colWidth, availHeight)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   461
        self.figureHeight = max(self.lh, self.rh) * 10.0/9.0
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   462
        return platdemos.Figure.wrap(self, availWidth, availHeight)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   463
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   464
    def drawFigure(self):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   465
        self.left.drawOn(self.canv,
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   466
                         self.width * 0.05,
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   467
                         self.figureHeight * 0.95 - self.lh
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   468
                         ) 
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   469
        self.right.drawOn(self.canv,
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   470
                         self.width * 0.55,
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   471
                         self.figureHeight * 0.95 - self.rh
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   472
                         ) 
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   473
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   474
def parabox(text, style, caption):
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   475
    p = ParaBox(text, style,
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   476
                'Figure <seq template="%(Chapter)s-%(Figure+)s"/>: ' + quickfix(caption)
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   477
                )
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   478
    getStory().append(p)
320
7a4ca2b5bb89 Tidied up genuserguide.py, especially figure handling; began
andy_robinson
parents: 318
diff changeset
   479
    
344
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   480
def parabox2(text, caption):
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   481
    p = ParaBox2(text, 
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   482
                'Figure <seq template="%(Chapter)s-%(Figure+)s"/>: ' + quickfix(caption)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   483
                )
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   484
    getStory().append(p)
dd6e41c2b0ed Paragraphs chapter pretty much complete. Fancy cover.
andy_robinson
parents: 341
diff changeset
   485
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   486
def pencilnote():
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   487
    getStory().append(examples.NoteAnnotation())
381
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   488
    
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   489
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   490
from reportlab.lib.colors import tan, green
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   491
def handnote(xoffset=0, size=None, fillcolor=tan, strokecolor=green):
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   492
    getStory().append(examples.HandAnnotation(xoffset,size,fillcolor,strokecolor))
2ca856765ed1 various mods
aaron_watters
parents: 371
diff changeset
   493
    
296
a5e584b6d61b Lots of graphical examples added
aaron_watters
parents: 293
diff changeset
   494
        
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   495
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   496
#make a singleton, created when requested rather
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   497
#than each time a chapter imports it.
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   498
_story = None
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   499
def getStory():
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   500
    global _story
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   501
    if _story is None:
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   502
        _story = []
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   503
    return _story
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   504
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   505
        
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   506
def run():
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   507
    doc = RLDocTemplate('userguide.pdf',pagesize = letter)
283
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   508
50f6c1be3e51 2nd try. more text
aaron_watters
parents: 273
diff changeset
   509
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   510
    #this builds the story    
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   511
    #resetStory()
323
5795e28c5910 Platypus Start
rgbecker
parents: 320
diff changeset
   512
337
76141601ec1f Broke out chapter 1
andy_robinson
parents: 336
diff changeset
   513
    import ch1_intro
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   514
    import ch2_graphics
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   515
    import ch3_pdffeatures
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   516
    import ch4_platypus_concepts
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   517
    import ch5_paragraphs
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   518
    import ch6_tables
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   519
    import ch7_custom
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   520
    import ch8_future
337
76141601ec1f Broke out chapter 1
andy_robinson
parents: 336
diff changeset
   521
    
370
d3ddde4cc30b begin app_demos.py
rgbecker
parents: 369
diff changeset
   522
    import app_demos
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   523
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   524
    # I don't know WHAT is going on here.
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   525
    # the submodules all do 'import *',
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   526
    # and the story they have access to
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   527
    # contains it all; but the one defined
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   528
    # in this module seems to be empty.
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   529
    #if I just call getStory, it has no
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   530
    #items!
334
6f9c206a34c0 Added paragraph examples and widget to User Guide
andy_robinson
parents: 331
diff changeset
   531
    
341
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   532
    story = ch8_future.getStory()
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   533
    print 'Built story contains %d flowables...' % len(story)
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   534
    doc.build(story)
27c68d524504 Broke up the user guide into chapters.
andy_robinson
parents: 340
diff changeset
   535
    print 'Saved userguide.pdf'
317
fce6dad947c3 Pushed down most existing lessons one level; added
andy_robinson
parents: 314
diff changeset
   536
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   537
    
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   538
    
273
cd705b27b6a5 initial checkin. user guide generation framework.
aaron_watters
parents:
diff changeset
   539
if __name__=="__main__":
336
c0fcae4341cf Separated out actual text from genuserguide, so it can be broken into
andy_robinson
parents: 334
diff changeset
   540
    run()