annotate Tools/scripts/texi2html.py @ 74006:88198b93ff2f

Issue #13560: Add PyUnicode_EncodeLocale() * Use PyUnicode_EncodeLocale() in time.strftime() if wcsftime() is not available * Document my last changes in Misc/NEWS
author Victor Stinner <victor.stinner@haypocalc.com>
date Sat, 17 Dec 2011 04:13:41 +0100
parents fcfe324663a6
children 332b93ce7bf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
59522
fcfe324663a6 convert shebang lines: python -> python3
Benjamin Peterson <benjamin@python.org>
parents: 51776
diff changeset
1 #! /usr/bin/env python3
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Convert GNU texinfo files into HTML, one file per node.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # Based on Texinfo 2.14.
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
5 # Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # The input file must be a complete texinfo file, e.g. emacs.texi.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # This creates many files (one per info node) in the output directory,
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # overwriting existing files of the same name. All files created have
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # ".html" as their extension.
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 # XXX To do:
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 # - handle @comment*** correctly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 # - handle @xref {some words} correctly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 # - handle @ftable correctly (items aren't indexed?)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 # - handle @itemx properly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 # - handle @exdent properly
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 # - add links directly to the proper line from indices
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 # - check against the definitive list of @-cmds; we still miss (among others):
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 # - @defindex (hard)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 # - @c(omment) in the middle of a line (rarely used)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 # - @this* (not really needed, only used in headers anyway)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 # - @today{} (ever used outside title page?)
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
25 # More consistent handling of chapters/sections/etc.
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
26 # Lots of documentation
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
27 # Many more options:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
28 # -top designate top node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
29 # -links customize which types of links are included
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
30 # -split split at chapters or sections instead of nodes
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
31 # -name Allow different types of filename handling. Non unix systems
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
32 # will have problems with long node names
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
33 # ...
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
34 # Support the most recent texinfo version and take a good look at HTML 3.0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
35 # More debugging output (customizable) and more flexible error handling
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
36 # How about icons ?
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
38 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
39 # Robert Pyron <rpyron@alum.mit.edu>
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
40 # 1. BUGFIX: In function makefile(), strip blanks from the nodename.
51776
d06a3ebf306f Merged revisions 69846 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 47100
diff changeset
41 # This is necessary to match the behavior of parser.makeref() and
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
42 # parser.do_node().
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
43 # 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
44 # it go away, rather than fix it)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
45 # 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
46 # 4. Support added for:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
47 # @uref URL reference
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
48 # @image image file reference (see note below)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
49 # @multitable output an HTML table
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
50 # @vtable
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
51 # 5. Partial support for accents, to match MAKEINFO output
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
52 # 6. I added a new command-line option, '-H basename', to specify
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
53 # HTML Help output. This will cause three files to be created
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
54 # in the current directory:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
55 # `basename`.hhp HTML Help Workshop project file
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
56 # `basename`.hhc Contents file for the project
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
57 # `basename`.hhk Index file for the project
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
58 # When fed into HTML Help Workshop, the resulting file will be
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
59 # named `basename`.chm.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
60 # 7. A new class, HTMLHelp, to accomplish item 6.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
61 # 8. Various calls to HTMLHelp functions.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
62 # A NOTE ON IMAGES: Just as 'outputdirectory' must exist before
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
63 # running this program, all referenced images must already exist
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
64 # in outputdirectory.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
65
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 import os
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
67 import sys
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 import string
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
69 import re
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 MAGIC = '\\input texinfo'
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
73 cmprog = re.compile('^@([a-z]+)([ \t]|$)') # Command (line-oriented)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
74 blprog = re.compile('^[ \t]*$') # Blank line
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
75 kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
76 # with {} args)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
77 spprog = re.compile('[\n@{}&<>]') # Special characters in
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
78 # running text
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
79 #
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
80 # menu item (Yuck!)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
81 miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
82 # 0 1 1 2 3 34 42 0
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
83 # ----- ---------- ---------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
84 # -|-----------------------------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
85 # -----------------------------------------------------
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
86
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
88
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
89
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
90 class HTMLNode:
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
91 """Some of the parser's functionality is separated into this class.
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
92
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
93 A Node accumulates its contents, takes care of links to other Nodes
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
94 and saves itself when it is finished and all links are resolved.
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
95 """
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
96
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
97 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
98
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
99 type = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
100 cont = ''
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
101 epilogue = '</BODY></HTML>\n'
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
102
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
103 def __init__(self, dir, name, topname, title, next, prev, up):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
104 self.dirname = dir
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
105 self.name = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
106 if topname:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
107 self.topname = topname
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
108 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
109 self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
110 self.title = title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
111 self.next = next
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
112 self.prev = prev
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
113 self.up = up
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
114 self.lines = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
115
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
116 def write(self, *lines):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
117 for line in lines:
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
118 self.lines.append(line)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
119
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
120 def flush(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
121 fp = open(self.dirname + '/' + makefile(self.name), 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
122 fp.write(self.prologue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
123 fp.write(self.text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
124 fp.write(self.epilogue)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
125 fp.close()
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
126
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
127 def link(self, label, nodename, rel=None, rev=None):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
128 if nodename:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
129 if nodename.lower() == '(dir)':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
130 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
131 title = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
132 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
133 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
134 title = ' TITLE="%s"' % nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
135 self.write(label, ': <A HREF="', addr, '"', \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
136 rel and (' REL=' + rel) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
137 rev and (' REV=' + rev) or "", \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
138 title, '>', nodename, '</A> \n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
139
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
140 def finalize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
141 length = len(self.lines)
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
142 self.text = ''.join(self.lines)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
143 self.lines = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
144 self.open_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
145 self.output_links()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
146 self.close_links()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
147 links = ''.join(self.lines)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
148 self.lines = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
149 self.prologue = (
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
150 self.DOCTYPE +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
151 '\n<HTML><HEAD>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
152 ' <!-- Converted with texi2html and Python -->\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
153 ' <TITLE>' + self.title + '</TITLE>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
154 ' <LINK REL=Next HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
155 + makefile(self.next) + '" TITLE="' + self.next + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
156 ' <LINK REL=Previous HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
157 + makefile(self.prev) + '" TITLE="' + self.prev + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
158 ' <LINK REL=Up HREF="'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
159 + makefile(self.up) + '" TITLE="' + self.up + '">\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
160 '</HEAD><BODY>\n' +
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
161 links)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
162 if length > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
163 self.epilogue = '<P>\n%s</BODY></HTML>\n' % links
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
164
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
165 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
166 self.write('<HR>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
167
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
168 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
169 self.write('<HR>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
170
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
171 def output_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
172 if self.cont != self.next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
173 self.link(' Cont', self.cont)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
174 self.link(' Next', self.next, rel='Next')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
175 self.link(' Prev', self.prev, rel='Previous')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
176 self.link(' Up', self.up, rel='Up')
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
177 if self.name != self.topname:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
178 self.link(' Top', self.topname)
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
179
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
180
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
181 class HTML3Node(HTMLNode):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
182
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
183 DOCTYPE = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN//3.0">'
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
184
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
185 def open_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
186 self.write('<DIV CLASS=Navigation>\n <HR>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
187
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
188 def close_links(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
189 self.write(' <HR>\n</DIV>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
190
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
191
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
192 class TexinfoParser:
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
193
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
194 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
195 FN_ID_PATTERN = "(%(id)s)"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
196 FN_SOURCE_PATTERN = '<A NAME=footnoteref%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
197 ' HREF="#footnotetext%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
198 + FN_ID_PATTERN + '</A>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
199 FN_TARGET_PATTERN = '<A NAME=footnotetext%(id)s' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
200 ' HREF="#footnoteref%(id)s">' \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
201 + FN_ID_PATTERN + '</A>\n%(text)s<P>\n'
4405
e528c0ace4e5 (texi2html.py): Added CLASS=Navigation attribute to DIV around top/bottom
Fred Drake <fdrake@acm.org>
parents: 4392
diff changeset
202 FN_HEADER = '\n<P>\n<HR NOSHADE SIZE=1 WIDTH=200>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
203 '<STRONG><EM>Footnotes</EM></STRONG>\n<P>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
204
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
205
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
206 Node = HTMLNode
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
207
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
208 # Initialize an instance
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
209 def __init__(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
210 self.unknown = {} # statistics about unknown @-commands
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
211 self.filenames = {} # Check for identical filenames
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
212 self.debugging = 0 # larger values produce more output
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
213 self.print_headers = 0 # always print headers?
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
214 self.nodefp = None # open file we're writing to
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
215 self.nodelineno = 0 # Linenumber relative to node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
216 self.links = None # Links from current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
217 self.savetext = None # If not None, save text head instead
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
218 self.savestack = [] # If not None, save text head instead
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
219 self.htmlhelp = None # html help data
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
220 self.dirname = 'tmp' # directory where files are created
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
221 self.includedir = '.' # directory to search @include files
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
222 self.nodename = '' # name of current node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
223 self.topname = '' # name of top node (first node seen)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
224 self.title = '' # title of this whole Texinfo tree
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
225 self.resetindex() # Reset all indices
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
226 self.contents = [] # Reset table of contents
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
227 self.numbering = [] # Reset section numbering counters
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
228 self.nofill = 0 # Normal operation: fill paragraphs
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
229 self.values={'html': 1} # Names that should be parsed in ifset
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
230 self.stackinfo={} # Keep track of state in the stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
231 # XXX The following should be reset per node?!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
232 self.footnotes = [] # Reset list of footnotes
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
233 self.itemarg = None # Reset command used by @item
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
234 self.itemnumber = None # Reset number for @item in @enumerate
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
235 self.itemindex = None # Reset item index name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
236 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
237 self.nodestack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
238 self.cont = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
239 self.includedepth = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
240
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
241 # Set htmlhelp helper class
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
242 def sethtmlhelp(self, htmlhelp):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
243 self.htmlhelp = htmlhelp
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
244
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
245 # Set (output) directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
246 def setdirname(self, dirname):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
247 self.dirname = dirname
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
248
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
249 # Set include directory name
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
250 def setincludedir(self, includedir):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
251 self.includedir = includedir
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
252
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
253 # Parse the contents of an entire file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
254 def parse(self, fp):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
255 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
256 lineno = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
257 while line and (line[0] == '%' or blprog.match(line)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
258 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
259 lineno = lineno + 1
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
260 if line[:len(MAGIC)] != MAGIC:
42715
e4ade16a694f Convert raise statements in Tools/.
Collin Winter <collinw@gmail.com>
parents: 42585
diff changeset
261 raise SyntaxError('file does not begin with %r' % (MAGIC,))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
262 self.parserest(fp, lineno)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
263
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
264 # Parse the contents of a file, not expecting a MAGIC header
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
265 def parserest(self, fp, initial_lineno):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
266 lineno = initial_lineno
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
267 self.done = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
268 self.skip = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
269 self.stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
270 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
271 while not self.done:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
272 line = fp.readline()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
273 self.nodelineno = self.nodelineno + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
274 if not line:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
275 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
276 if not self.skip: self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
277 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
278 if initial_lineno > 0:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
279 print('*** EOF before @bye')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
280 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
281 lineno = lineno + 1
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
282 mo = cmprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
283 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
284 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
285 cmd = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
286 if cmd in ('noindent', 'refill'):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
287 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
288 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
289 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
290 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
291 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
292 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
293 self.command(line, mo)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
294 elif blprog.match(line) and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
295 'format' not in self.stack and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
296 'example' not in self.stack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
297 if accu:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
298 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
299 self.process(accu)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
300 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
301 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
302 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
303 self.write('<P>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
304 accu = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
305 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
306 # Append the line including trailing \n!
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
307 accu.append(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
308 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
309 if self.skip:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
310 print('*** Still skipping at the end')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
311 if self.stack:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
312 print('*** Stack not empty at the end')
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
313 print('***', self.stack)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
314 if self.includedepth == 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
315 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
316 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
317 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
318 del self.nodestack[-1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
319
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
320 # Start saving text in a buffer instead of writing it to a file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
321 def startsaving(self):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
322 if self.savetext != None:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
323 self.savestack.append(self.savetext)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
324 # print '*** Recursively saving text, expect trouble'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
325 self.savetext = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
326
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
327 # Return the text saved so far and start writing to file again
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
328 def collectsavings(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
329 savetext = self.savetext
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
330 if len(self.savestack) > 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
331 self.savetext = self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
332 del self.savestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
333 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
334 self.savetext = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
335 return savetext or ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
336
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
337 # Write text to file, or save it in a buffer, or ignore it
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
338 def write(self, *args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
339 try:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
340 text = ''.join(args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
341 except:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
342 print(args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
343 raise TypeError
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
344 if self.savetext != None:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
345 self.savetext = self.savetext + text
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
346 elif self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
347 self.nodefp.write(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
348 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
349 self.node.write(text)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
350
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
351 # Complete the current node -- write footnotes and close file
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
352 def endnode(self):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
353 if self.savetext != None:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
354 print('*** Still saving text at end of node')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
355 dummy = self.collectsavings()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
356 if self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
357 self.writefootnotes()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
358 if self.nodefp:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
359 if self.nodelineno > 20:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
360 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
361 [name, next, prev, up] = self.nodelinks[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
362 self.link('Next', next)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
363 self.link('Prev', prev)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
364 self.link('Up', up)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
365 if self.nodename != self.topname:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
366 self.link('Top', self.topname)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
367 self.write('<HR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
368 self.write('</BODY>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
369 self.nodefp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
370 self.nodefp = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
371 elif self.node:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
372 if not self.cont and \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
373 (not self.node.type or \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
374 (self.node.next and self.node.prev and self.node.up)):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
375 self.node.finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
376 self.node.flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
377 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
378 self.nodestack.append(self.node)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
379 self.node = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
380 self.nodename = ''
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
381
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
382 # Process a list of lines, expanding embedded @-commands
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
383 # This mostly distinguishes between menus and normal text
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
384 def process(self, accu):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
385 if self.debugging > 1:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
386 print('!'*self.debugging, 'process:', self.skip, self.stack, end=' ')
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
387 if accu: print(accu[0][:30], end=' ')
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
388 if accu[0][30:] or accu[1:]: print('...', end=' ')
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
389 print()
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
390 if self.inmenu():
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
391 # XXX should be done differently
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
392 for line in accu:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
393 mo = miprog.match(line)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
394 if not mo:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
395 line = line.strip() + '\n'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
396 self.expand(line)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
397 continue
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
398 bgn, end = mo.span(0)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
399 a, b = mo.span(1)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
400 c, d = mo.span(2)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
401 e, f = mo.span(3)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
402 g, h = mo.span(4)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
403 label = line[a:b]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
404 nodename = line[c:d]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
405 if nodename[0] == ':': nodename = label
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
406 else: nodename = line[e:f]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
407 punct = line[g:h]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
408 self.write(' <LI><A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
409 makefile(nodename),
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
410 '">', nodename,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
411 '</A>', punct, '\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
412 self.htmlhelp.menuitem(nodename)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
413 self.expand(line[end:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
414 else:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
415 text = ''.join(accu)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
416 self.expand(text)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
417
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
418 # find 'menu' (we might be inside 'ifset' or 'ifclear')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
419 def inmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
420 #if 'menu' in self.stack:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
421 # print 'inmenu :', self.skip, self.stack, self.stackinfo
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
422 stack = self.stack
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
423 while stack and stack[-1] in ('ifset','ifclear'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
424 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
425 if self.stackinfo[len(stack)]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
426 return 0
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
427 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
428 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
429 stack = stack[:-1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
430 return (stack and stack[-1] == 'menu')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
431
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
432 # Write a string, expanding embedded @-commands
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
433 def expand(self, text):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
434 stack = []
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
435 i = 0
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
436 n = len(text)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
437 while i < n:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
438 start = i
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
439 mo = spprog.search(text, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
440 if mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
441 i = mo.start()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
442 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
443 self.write(text[start:])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
444 break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
445 self.write(text[start:i])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
446 c = text[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
447 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
448 if c == '\n':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
449 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
450 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
451 if c == '<':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
452 self.write('&lt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
453 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
454 if c == '>':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
455 self.write('&gt;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
456 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
457 if c == '&':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
458 self.write('&amp;')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
459 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
460 if c == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
461 stack.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
462 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
463 if c == '}':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
464 if not stack:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
465 print('*** Unmatched }')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
466 self.write('}')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
467 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
468 cmd = stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
469 del stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
470 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
471 method = getattr(self, 'close_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
472 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
473 self.unknown_close(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
474 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
475 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
476 continue
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
477 if c != '@':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
478 # Cannot happen unless spprog is changed
42715
e4ade16a694f Convert raise statements in Tools/.
Collin Winter <collinw@gmail.com>
parents: 42585
diff changeset
479 raise RuntimeError('unexpected funny %r' % c)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
480 start = i
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
481 while i < n and text[i] in string.ascii_letters: i = i+1
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
482 if i == start:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
483 # @ plus non-letter: literal next character
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
484 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
485 c = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
486 if c == ':':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
487 # `@:' means no extra space after
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
488 # preceding `.', `?', `!' or `:'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
489 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
490 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
491 # `@.' means a sentence-ending period;
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
492 # `@@', `@{', `@}' quote `@', `{', `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
493 self.write(c)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
494 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
495 cmd = text[start:i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
496 if i < n and text[i] == '{':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
497 i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
498 stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
499 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
500 method = getattr(self, 'open_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
501 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
502 self.unknown_open(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
503 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
504 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
505 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
506 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
507 method = getattr(self, 'handle_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
508 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
509 self.unknown_handle(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
510 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
511 method()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
512 if stack:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
513 print('*** Stack not empty at para:', stack)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
514
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
515 # --- Handle unknown embedded @-commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
516
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
517 def unknown_open(self, cmd):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
518 print('*** No open func for @' + cmd + '{...}')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
519 cmd = cmd + '{'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
520 self.write('@', cmd)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
521 if cmd not in self.unknown:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
522 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
523 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
524 self.unknown[cmd] = self.unknown[cmd] + 1
2705
9ed45dbf2765 mods by Gregor Schmid -- very nice!
Guido van Rossum <guido@python.org>
parents: 2551
diff changeset
525
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
526 def unknown_close(self, cmd):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
527 print('*** No close func for @' + cmd + '{...}')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
528 cmd = '}' + cmd
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
529 self.write('}')
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
530 if cmd not in self.unknown:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
531 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
532 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
533 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
534
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
535 def unknown_handle(self, cmd):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
536 print('*** No handler for @' + cmd)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
537 self.write('@', cmd)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
538 if cmd not in self.unknown:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
539 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
540 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
541 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
542
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
543 # XXX The following sections should be ordered as the texinfo docs
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
544
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
545 # --- Embedded @-commands without {} argument list --
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
546
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
547 def handle_noindent(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
548
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
549 def handle_refill(self): pass
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
550
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
551 # --- Include file handling ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
552
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
553 def do_include(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
554 file = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
555 file = os.path.join(self.includedir, file)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
556 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
557 fp = open(file, 'r')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 32734
diff changeset
558 except IOError as msg:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
559 print('*** Can\'t open include file', repr(file))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
560 return
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
561 print('!'*self.debugging, '--> file', repr(file))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
562 save_done = self.done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
563 save_skip = self.skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
564 save_stack = self.stack
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
565 self.includedepth = self.includedepth + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
566 self.parserest(fp, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
567 self.includedepth = self.includedepth - 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
568 fp.close()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
569 self.done = save_done
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
570 self.skip = save_skip
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
571 self.stack = save_stack
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
572 print('!'*self.debugging, '<-- file', repr(file))
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
573
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
574 # --- Special Insertions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
575
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
576 def open_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
577 def close_dmn(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
578
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
579 def open_dots(self): self.write('...')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
580 def close_dots(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
581
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
582 def open_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
583 def close_bullet(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
584
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
585 def open_TeX(self): self.write('TeX')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
586 def close_TeX(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
587
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
588 def handle_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
589 def open_copyright(self): self.write(self.COPYRIGHT_SYMBOL)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
590 def close_copyright(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
591
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
592 def open_minus(self): self.write('-')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
593 def close_minus(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
594
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
595 # --- Accents ---
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
596
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
597 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
598 # I would like to do at least as well as makeinfo when
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
599 # it is producing HTML output:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
600 #
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
601 # input output
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
602 # @"o @"o umlaut accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
603 # @'o 'o acute accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
604 # @,{c} @,{c} cedilla accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
605 # @=o @=o macron/overbar accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
606 # @^o @^o circumflex accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
607 # @`o `o grave accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
608 # @~o @~o tilde accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
609 # @dotaccent{o} @dotaccent{o} overdot accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
610 # @H{o} @H{o} long Hungarian umlaut
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
611 # @ringaccent{o} @ringaccent{o} ring accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
612 # @tieaccent{oo} @tieaccent{oo} tie-after accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
613 # @u{o} @u{o} breve accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
614 # @ubaraccent{o} @ubaraccent{o} underbar accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
615 # @udotaccent{o} @udotaccent{o} underdot accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
616 # @v{o} @v{o} hacek or check accent
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
617 # @exclamdown{} &#161; upside-down !
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
618 # @questiondown{} &#191; upside-down ?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
619 # @aa{},@AA{} &#229;,&#197; a,A with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
620 # @ae{},@AE{} &#230;,&#198; ae,AE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
621 # @dotless{i} @dotless{i} dotless i
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
622 # @dotless{j} @dotless{j} dotless j
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
623 # @l{},@L{} l/,L/ suppressed-L,l
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
624 # @o{},@O{} &#248;,&#216; O,o with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
625 # @oe{},@OE{} oe,OE oe,OE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
626 # @ss{} &#223; es-zet or sharp S
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
627 #
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
628 # The following character codes and approximations have been
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
629 # copied from makeinfo's HTML output.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
630
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
631 def open_exclamdown(self): self.write('&#161;') # upside-down !
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
632 def close_exclamdown(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
633 def open_questiondown(self): self.write('&#191;') # upside-down ?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
634 def close_questiondown(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
635 def open_aa(self): self.write('&#229;') # a with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
636 def close_aa(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
637 def open_AA(self): self.write('&#197;') # A with circle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
638 def close_AA(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
639 def open_ae(self): self.write('&#230;') # ae ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
640 def close_ae(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
641 def open_AE(self): self.write('&#198;') # AE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
642 def close_AE(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
643 def open_o(self): self.write('&#248;') # o with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
644 def close_o(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
645 def open_O(self): self.write('&#216;') # O with slash
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
646 def close_O(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
647 def open_ss(self): self.write('&#223;') # es-zet or sharp S
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
648 def close_ss(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
649 def open_oe(self): self.write('oe') # oe ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
650 def close_oe(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
651 def open_OE(self): self.write('OE') # OE ligatures
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
652 def close_OE(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
653 def open_l(self): self.write('l/') # suppressed-l
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
654 def close_l(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
655 def open_L(self): self.write('L/') # suppressed-L
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
656 def close_L(self): pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
657
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
658 # --- Special Glyphs for Examples ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
659
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
660 def open_result(self): self.write('=&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
661 def close_result(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
662
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
663 def open_expansion(self): self.write('==&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
664 def close_expansion(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
665
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
666 def open_print(self): self.write('-|')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
667 def close_print(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
668
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
669 def open_error(self): self.write('error--&gt;')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
670 def close_error(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
671
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
672 def open_equiv(self): self.write('==')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
673 def close_equiv(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
674
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
675 def open_point(self): self.write('-!-')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
676 def close_point(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
677
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
678 # --- Cross References ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
679
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
680 def open_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
681 self.write('see ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
682 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
683 def close_pxref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
684 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
685
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
686 def open_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
687 self.write('See ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
688 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
689 def close_xref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
690 self.makeref()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
691
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
692 def open_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
693 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
694 def close_ref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
695 self.makeref()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
696
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
697 def open_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
698 self.write('See info file ')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
699 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
700 def close_inforef(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
701 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
702 args = [s.strip() for s in text.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
703 while len(args) < 3: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
704 node = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
705 file = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
706 self.write('`', file, '\', node `', node, '\'')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
707
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
708 def makeref(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
709 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
710 args = [s.strip() for s in text.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
711 while len(args) < 5: args.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
712 nodename = label = args[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
713 if args[2]: label = args[2]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
714 file = args[3]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
715 title = args[4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
716 href = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
717 if file:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
718 href = '../' + file + '/' + href
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
719 self.write('<A HREF="', href, '">', label, '</A>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
720
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
721 # rpyron 2002-05-07 uref support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
722 def open_uref(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
723 self.startsaving()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
724 def close_uref(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
725 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
726 args = [s.strip() for s in text.split(',')]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
727 while len(args) < 2: args.append('')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
728 href = args[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
729 label = args[1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
730 if not label: label = href
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
731 self.write('<A HREF="', href, '">', label, '</A>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
732
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
733 # rpyron 2002-05-07 image support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
734 # GNU makeinfo producing HTML output tries `filename.png'; if
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
735 # that does not exist, it tries `filename.jpg'. If that does
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
736 # not exist either, it complains. GNU makeinfo does not handle
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
737 # GIF files; however, I include GIF support here because
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
738 # MySQL documentation uses GIF files.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
739
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
740 def open_image(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
741 self.startsaving()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
742 def close_image(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
743 self.makeimage()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
744 def makeimage(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
745 text = self.collectsavings()
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
746 args = [s.strip() for s in text.split(',')]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
747 while len(args) < 5: args.append('')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
748 filename = args[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
749 width = args[1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
750 height = args[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
751 alt = args[3]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
752 ext = args[4]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
753
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
754 # The HTML output will have a reference to the image
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
755 # that is relative to the HTML output directory,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
756 # which is what 'filename' gives us. However, we need
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
757 # to find it relative to our own current directory,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
758 # so we construct 'imagename'.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
759 imagelocation = self.dirname + '/' + filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
760
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
761 if os.path.exists(imagelocation+'.png'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
762 filename += '.png'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
763 elif os.path.exists(imagelocation+'.jpg'):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
764 filename += '.jpg'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
765 elif os.path.exists(imagelocation+'.gif'): # MySQL uses GIF files
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
766 filename += '.gif'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
767 else:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
768 print("*** Cannot find image " + imagelocation)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
769 #TODO: what is 'ext'?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
770 self.write('<IMG SRC="', filename, '"', \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
771 width and (' WIDTH="' + width + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
772 height and (' HEIGHT="' + height + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
773 alt and (' ALT="' + alt + '"') or "", \
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
774 '/>' )
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
775 self.htmlhelp.addimage(imagelocation)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
776
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
777
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
778 # --- Marking Words and Phrases ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
779
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
780 # --- Other @xxx{...} commands ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
781
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
782 def open_(self): pass # Used by {text enclosed in braces}
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
783 def close_(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
784
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
785 open_asis = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
786 close_asis = close_
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
787
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
788 def open_cite(self): self.write('<CITE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
789 def close_cite(self): self.write('</CITE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
790
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
791 def open_code(self): self.write('<CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
792 def close_code(self): self.write('</CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
793
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
794 def open_t(self): self.write('<TT>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
795 def close_t(self): self.write('</TT>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
796
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
797 def open_dfn(self): self.write('<DFN>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
798 def close_dfn(self): self.write('</DFN>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
799
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
800 def open_emph(self): self.write('<EM>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
801 def close_emph(self): self.write('</EM>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
802
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
803 def open_i(self): self.write('<I>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
804 def close_i(self): self.write('</I>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
805
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
806 def open_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
807 # if self.savetext <> None:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
808 # print '*** Recursive footnote -- expect weirdness'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
809 id = len(self.footnotes) + 1
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
810 self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)})
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
811 self.startsaving()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
812
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
813 def close_footnote(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
814 id = len(self.footnotes) + 1
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
815 self.footnotes.append((id, self.collectsavings()))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
816
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
817 def writefootnotes(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
818 self.write(self.FN_HEADER)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
819 for id, text in self.footnotes:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
820 self.write(self.FN_TARGET_PATTERN
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
821 % {'id': repr(id), 'text': text})
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
822 self.footnotes = []
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
823
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
824 def open_file(self): self.write('<CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
825 def close_file(self): self.write('</CODE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
826
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
827 def open_kbd(self): self.write('<KBD>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
828 def close_kbd(self): self.write('</KBD>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
829
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
830 def open_key(self): self.write('<KEY>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
831 def close_key(self): self.write('</KEY>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
832
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
833 def open_r(self): self.write('<R>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
834 def close_r(self): self.write('</R>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
835
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
836 def open_samp(self): self.write('`<SAMP>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
837 def close_samp(self): self.write('</SAMP>\'')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
838
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
839 def open_sc(self): self.write('<SMALLCAPS>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
840 def close_sc(self): self.write('</SMALLCAPS>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
841
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
842 def open_strong(self): self.write('<STRONG>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
843 def close_strong(self): self.write('</STRONG>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
844
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
845 def open_b(self): self.write('<B>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
846 def close_b(self): self.write('</B>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
847
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
848 def open_var(self): self.write('<VAR>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
849 def close_var(self): self.write('</VAR>')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
850
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
851 def open_w(self): self.write('<NOBREAK>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
852 def close_w(self): self.write('</NOBREAK>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
853
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
854 def open_url(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
855 def close_url(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
856 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
857 self.write('<A HREF="', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
858
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
859 def open_email(self): self.startsaving()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
860 def close_email(self):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
861 text = self.collectsavings()
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
862 self.write('<A HREF="mailto:', text, '">', text, '</A>')
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
863
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
864 open_titlefont = open_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
865 close_titlefont = close_
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
866
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
867 def open_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
868 def close_small(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
869
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
870 def command(self, line, mo):
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
871 a, b = mo.span(1)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
872 cmd = line[a:b]
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
873 args = line[b:].strip()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
874 if self.debugging > 1:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
875 print('!'*self.debugging, 'command:', self.skip, self.stack, \
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
876 '@' + cmd, args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
877 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
878 func = getattr(self, 'do_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
879 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
880 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
881 func = getattr(self, 'bgn_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
882 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
883 # don't complain if we are skipping anyway
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
884 if not self.skip:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
885 self.unknown_cmd(cmd, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
886 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
887 self.stack.append(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
888 func(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
889 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
890 if not self.skip or cmd == 'end':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
891 func(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
892
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
893 def unknown_cmd(self, cmd, args):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
894 print('*** unknown', '@' + cmd, args)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
895 if cmd not in self.unknown:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
896 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
897 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
898 self.unknown[cmd] = self.unknown[cmd] + 1
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
899
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
900 def do_end(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
901 words = args.split()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
902 if not words:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
903 print('*** @end w/o args')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
904 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
905 cmd = words[0]
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
906 if not self.stack or self.stack[-1] != cmd:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
907 print('*** @end', cmd, 'unexpected')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
908 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
909 del self.stack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
910 try:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
911 func = getattr(self, 'end_' + cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
912 except AttributeError:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
913 self.unknown_end(cmd)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
914 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
915 func()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
916
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
917 def unknown_end(self, cmd):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
918 cmd = 'end ' + cmd
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
919 print('*** unknown', '@' + cmd)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
920 if cmd not in self.unknown:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
921 self.unknown[cmd] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
922 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
923 self.unknown[cmd] = self.unknown[cmd] + 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
924
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
925 # --- Comments ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
926
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
927 def do_comment(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
928 do_c = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
929
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
930 # --- Conditional processing ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
931
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
932 def bgn_ifinfo(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
933 def end_ifinfo(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
934
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
935 def bgn_iftex(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
936 def end_iftex(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
937
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
938 def bgn_ignore(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
939 def end_ignore(self): self.skip = self.skip - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
940
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
941 def bgn_tex(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
942 def end_tex(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
943
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
944 def do_set(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
945 fields = args.split(' ')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
946 key = fields[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
947 if len(fields) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
948 value = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
949 else:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
950 value = ' '.join(fields[1:])
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
951 self.values[key] = value
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
952
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
953 def do_clear(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
954 self.values[args] = None
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
955
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
956 def bgn_ifset(self, args):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
957 if args not in self.values or self.values[args] is None:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
958 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
959 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
960 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
961 self.stackinfo[len(self.stack)] = 0
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
962 def end_ifset(self):
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
963 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
964 if self.stackinfo[len(self.stack) + 1]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
965 self.skip = self.skip - 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
966 del self.stackinfo[len(self.stack) + 1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
967 except KeyError:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
968 print('*** end_ifset: KeyError :', len(self.stack) + 1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
969
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
970 def bgn_ifclear(self, args):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
971 if args in self.values and self.values[args] is not None:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
972 self.skip = self.skip + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
973 self.stackinfo[len(self.stack)] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
974 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
975 self.stackinfo[len(self.stack)] = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
976 def end_ifclear(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
977 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
978 if self.stackinfo[len(self.stack) + 1]:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
979 self.skip = self.skip - 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
980 del self.stackinfo[len(self.stack) + 1]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
981 except KeyError:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
982 print('*** end_ifclear: KeyError :', len(self.stack) + 1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
983
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
984 def open_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
985 self.startsaving()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
986
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
987 def close_value(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
988 key = self.collectsavings()
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
989 if key in self.values:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
990 self.write(self.values[key])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
991 else:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
992 print('*** Undefined value: ', key)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
993
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
994 # --- Beginning a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
995
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
996 do_finalout = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
997 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
998 do_setfilename = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
999
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1000 def do_settitle(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1001 self.startsaving()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1002 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1003 self.title = self.collectsavings()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1004 def do_parskip(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1005
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1006 # --- Ending a file ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1007
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1008 def do_bye(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1009 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1010 self.done = 1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1011
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1012 # --- Title page ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1013
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1014 def bgn_titlepage(self, args): self.skip = self.skip + 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1015 def end_titlepage(self): self.skip = self.skip - 1
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1016 def do_shorttitlepage(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1017
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1018 def do_center(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1019 # Actually not used outside title page...
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1020 self.write('<H1>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1021 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1022 self.write('</H1>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1023 do_title = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1024 do_subtitle = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1025 do_author = do_center
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1026
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1027 do_vskip = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1028 do_vfill = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1029 do_smallbook = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1030
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1031 do_paragraphindent = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1032 do_setchapternewpage = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1033 do_headings = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1034 do_footnotestyle = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1035
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1036 do_evenheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1037 do_evenfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1038 do_oddheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1039 do_oddfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1040 do_everyheading = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1041 do_everyfooting = do_comment
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1042
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1043 # --- Nodes ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1044
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1045 def do_node(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1046 self.endnode()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1047 self.nodelineno = 0
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1048 parts = [s.strip() for s in args.split(',')]
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1049 while len(parts) < 4: parts.append('')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1050 self.nodelinks = parts
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1051 [name, next, prev, up] = parts[:4]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1052 file = self.dirname + '/' + makefile(name)
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1053 if file in self.filenames:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1054 print('*** Filename already in use: ', file)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1055 else:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1056 if self.debugging: print('!'*self.debugging, '--- writing', file)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1057 self.filenames[file] = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1058 # self.nodefp = open(file, 'w')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1059 self.nodename = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1060 if self.cont and self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1061 self.nodestack[-1].cont = self.nodename
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1062 if not self.topname: self.topname = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1063 title = name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1064 if self.title: title = title + ' -- ' + self.title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1065 self.node = self.Node(self.dirname, self.nodename, self.topname,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1066 title, next, prev, up)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1067 self.htmlhelp.addnode(self.nodename,next,prev,up,file)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1068
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1069 def link(self, label, nodename):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1070 if nodename:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1071 if nodename.lower() == '(dir)':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1072 addr = '../dir.html'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1073 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1074 addr = makefile(nodename)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1075 self.write(label, ': <A HREF="', addr, '" TYPE="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1076 label, '">', nodename, '</A> \n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1077
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1078 # --- Sectioning commands ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1079
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1080 def popstack(self, type):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1081 if (self.node):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1082 self.node.type = type
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1083 while self.nodestack:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1084 if self.nodestack[-1].type > type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1085 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1086 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1087 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1088 elif self.nodestack[-1].type == type:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1089 if not self.nodestack[-1].next:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1090 self.nodestack[-1].next = self.node.name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1091 if not self.node.prev:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1092 self.node.prev = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1093 self.nodestack[-1].finalize()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1094 self.nodestack[-1].flush()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1095 del self.nodestack[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1096 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1097 if type > 1 and not self.node.up:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1098 self.node.up = self.nodestack[-1].name
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1099 break
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1100
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1101 def do_chapter(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1102 self.heading('H1', args, 0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1103 self.popstack(1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1104
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1105 def do_unnumbered(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1106 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1107 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1108 def do_appendix(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1109 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1110 self.popstack(1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1111 def do_top(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1112 self.heading('H1', args, -1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1113 def do_chapheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1114 self.heading('H1', args, -1)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1115 def do_majorheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1116 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1117
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1118 def do_section(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1119 self.heading('H1', args, 1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1120 self.popstack(2)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1121
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1122 def do_unnumberedsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1123 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1124 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1125 def do_appendixsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1126 self.heading('H1', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1127 self.popstack(2)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1128 do_appendixsection = do_appendixsec
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1129 def do_heading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1130 self.heading('H1', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1131
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1132 def do_subsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1133 self.heading('H2', args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1134 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1135 def do_unnumberedsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1136 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1137 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1138 def do_appendixsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1139 self.heading('H2', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1140 self.popstack(3)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1141 def do_subheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1142 self.heading('H2', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1143
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1144 def do_subsubsection(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1145 self.heading('H3', args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1146 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1147 def do_unnumberedsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1148 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1149 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1150 def do_appendixsubsubsec(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1151 self.heading('H3', args, -1)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1152 self.popstack(4)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1153 def do_subsubheading(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1154 self.heading('H3', args, -1)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1155
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1156 def heading(self, type, args, level):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1157 if level >= 0:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1158 while len(self.numbering) <= level:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1159 self.numbering.append(0)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1160 del self.numbering[level+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1161 self.numbering[level] = self.numbering[level] + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1162 x = ''
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1163 for i in self.numbering:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 23896
diff changeset
1164 x = x + repr(i) + '.'
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1165 args = x + ' ' + args
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1166 self.contents.append((level, args, self.nodename))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1167 self.write('<', type, '>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1168 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1169 self.write('</', type, '>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1170 if self.debugging or self.print_headers:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1171 print('---', args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1172
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1173 def do_contents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1174 # pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1175 self.listcontents('Table of Contents', 999)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1176
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1177 def do_shortcontents(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1178 pass
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1179 # self.listcontents('Short Contents', 0)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1180 do_summarycontents = do_shortcontents
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1181
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1182 def listcontents(self, title, maxlevel):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1183 self.write('<H1>', title, '</H1>\n<UL COMPACT PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1184 prevlevels = [0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1185 for level, title, node in self.contents:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1186 if level > maxlevel:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1187 continue
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1188 if level > prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1189 # can only advance one level at a time
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1190 self.write(' '*prevlevels[-1], '<UL PLAIN>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1191 prevlevels.append(level)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1192 elif level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1193 # might drop back multiple levels
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1194 while level < prevlevels[-1]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1195 del prevlevels[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1196 self.write(' '*prevlevels[-1],
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1197 '</UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1198 self.write(' '*level, '<LI> <A HREF="',
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1199 makefile(node), '">')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1200 self.expand(title)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1201 self.write('</A>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1202 self.write('</UL>\n' * len(prevlevels))
2705
9ed45dbf2765 mods by Gregor Schmid -- very nice!
Guido van Rossum <guido@python.org>
parents: 2551
diff changeset
1203
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1204 # --- Page lay-out ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1205
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1206 # These commands are only meaningful in printed text
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1207
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1208 def do_page(self, args): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1209
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1210 def do_need(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1211
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1212 def bgn_group(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1213 def end_group(self): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1214
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1215 # --- Line lay-out ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1216
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1217 def do_sp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1218 if self.nofill:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1219 self.write('\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1220 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1221 self.write('<P>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1222
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1223 def do_hline(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1224 self.write('<HR>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1225
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1226 # --- Function and variable definitions ---
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1227
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1228 def bgn_deffn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1229 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1230 self.do_deffnx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1231
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1232 def end_deffn(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1233 self.write('</DL>\n')
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1234
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1235 def do_deffnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1236 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1237 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1238 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1239 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1240 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1241 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1242 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1243 self.index('fn', name)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1244
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1245 def bgn_defun(self, args): self.bgn_deffn('Function ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1246 end_defun = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1247 def do_defunx(self, args): self.do_deffnx('Function ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1248
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1249 def bgn_defmac(self, args): self.bgn_deffn('Macro ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1250 end_defmac = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1251 def do_defmacx(self, args): self.do_deffnx('Macro ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1252
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1253 def bgn_defspec(self, args): self.bgn_deffn('{Special Form} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1254 end_defspec = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1255 def do_defspecx(self, args): self.do_deffnx('{Special Form} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1256
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1257 def bgn_defvr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1258 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1259 self.do_defvrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1260
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1261 end_defvr = end_deffn
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1262
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1263 def do_defvrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1264 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1265 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1266 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1267 self.expand('@code{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1268 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1269 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1270 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1271 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1272 self.index('vr', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1273
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1274 def bgn_defvar(self, args): self.bgn_defvr('Variable ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1275 end_defvar = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1276 def do_defvarx(self, args): self.do_defvrx('Variable ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1277
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1278 def bgn_defopt(self, args): self.bgn_defvr('{User Option} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1279 end_defopt = end_defvr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1280 def do_defoptx(self, args): self.do_defvrx('{User Option} ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1281
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1282 # --- Ditto for typed languages ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1283
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1284 def bgn_deftypefn(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1285 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1286 self.do_deftypefnx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1287
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1288 end_deftypefn = end_deffn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1289
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1290 def do_deftypefnx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1291 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1292 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1293 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1294 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1295 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1296 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1297 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1298 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1299
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1300
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1301 def bgn_deftypefun(self, args): self.bgn_deftypefn('Function ' + args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1302 end_deftypefun = end_deftypefn
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1303 def do_deftypefunx(self, args): self.do_deftypefnx('Function ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1304
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1305 def bgn_deftypevr(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1306 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1307 self.do_deftypevrx(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1308
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1309 end_deftypevr = end_deftypefn
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1310
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1311 def do_deftypevrx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1312 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1313 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1314 [category, datatype, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1315 self.expand('@code{%s} @b{%s}' % (datatype, name))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1316 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1317 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1318 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1319 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1320 self.index('fn', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1321
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1322 def bgn_deftypevar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1323 self.bgn_deftypevr('Variable ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1324 end_deftypevar = end_deftypevr
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1325 def do_deftypevarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1326 self.do_deftypevrx('Variable ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1327
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1328 # --- Ditto for object-oriented languages ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1329
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1330 def bgn_defcv(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1331 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1332 self.do_defcvx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1333
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1334 end_defcv = end_deftypevr
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1335
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1336 def do_defcvx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1337 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1338 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1339 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1340 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1341 # If there are too many arguments, show them
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1342 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1343 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1344 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1345 self.index('vr', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1346
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1347 def bgn_defivar(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1348 self.bgn_defcv('{Instance Variable} ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1349 end_defivar = end_defcv
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1350 def do_defivarx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1351 self.do_defcvx('{Instance Variable} ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1352
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1353 def bgn_defop(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1354 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1355 self.do_defopx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1356
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1357 end_defop = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1358
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1359 def do_defopx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1360 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1361 words = splitwords(args, 3)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1362 [category, classname, name], rest = words[:3], words[3:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1363 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1364 for word in rest: self.expand(' ' + makevar(word))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1365 #self.expand(' -- %s of @code{%s}' % (category, classname))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1366 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1367 self.index('fn', '%s @r{on %s}' % (name, classname))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1368
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1369 def bgn_defmethod(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1370 self.bgn_defop('Method ' + args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1371 end_defmethod = end_defop
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1372 def do_defmethodx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1373 self.do_defopx('Method ' + args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1374
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1375 # --- Ditto for data types ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1376
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1377 def bgn_deftp(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1378 self.write('<DL>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1379 self.do_deftpx(args)
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1380
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1381 end_deftp = end_defcv
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1382
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1383 def do_deftpx(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1384 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1385 words = splitwords(args, 2)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1386 [category, name], rest = words[:2], words[2:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1387 self.expand('@b{%s}' % name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1388 for word in rest: self.expand(' ' + word)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1389 #self.expand(' -- ' + category)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1390 self.write('\n<DD>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1391 self.index('tp', name)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1392
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1393 # --- Making Lists and Tables
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1394
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1395 def bgn_enumerate(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1396 if not args:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1397 self.write('<OL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1398 self.stackinfo[len(self.stack)] = '</OL>\n'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1399 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1400 self.itemnumber = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1401 self.write('<UL>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1402 self.stackinfo[len(self.stack)] = '</UL>\n'
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1403 def end_enumerate(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1404 self.itemnumber = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1405 self.write(self.stackinfo[len(self.stack) + 1])
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1406 del self.stackinfo[len(self.stack) + 1]
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1407
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1408 def bgn_itemize(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1409 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1410 self.write('<UL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1411 def end_itemize(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1412 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1413 self.write('</UL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1414
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1415 def bgn_table(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1416 self.itemarg = args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1417 self.write('<DL>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1418 def end_table(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1419 self.itemarg = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1420 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1421
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1422 def bgn_ftable(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1423 self.itemindex = 'fn'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1424 self.bgn_table(args)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1425 def end_ftable(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1426 self.itemindex = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1427 self.end_table()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1428
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1429 def bgn_vtable(self, args):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1430 self.itemindex = 'vr'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1431 self.bgn_table(args)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1432 def end_vtable(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1433 self.itemindex = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1434 self.end_table()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1435
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1436 def do_item(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1437 if self.itemindex: self.index(self.itemindex, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1438 if self.itemarg:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1439 if self.itemarg[0] == '@' and self.itemarg[1] and \
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
1440 self.itemarg[1] in string.ascii_letters:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1441 args = self.itemarg + '{' + args + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1442 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1443 # some other character, e.g. '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1444 args = self.itemarg + ' ' + args
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1445 if self.itemnumber != None:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1446 args = self.itemnumber + '. ' + args
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1447 self.itemnumber = increment(self.itemnumber)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1448 if self.stack and self.stack[-1] == 'table':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1449 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1450 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1451 self.write('\n<DD>')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1452 elif self.stack and self.stack[-1] == 'multitable':
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1453 self.write('<TR><TD>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1454 self.expand(args)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1455 self.write('</TD>\n</TR>\n')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1456 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1457 self.write('<LI>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1458 self.expand(args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1459 self.write(' ')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1460 do_itemx = do_item # XXX Should suppress leading blank line
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1461
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1462 # rpyron 2002-05-07 multitable support
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1463 def bgn_multitable(self, args):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1464 self.itemarg = None # should be handled by columnfractions
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1465 self.write('<TABLE BORDER="">\n')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1466 def end_multitable(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1467 self.itemarg = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1468 self.write('</TABLE>\n<BR>\n')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1469 def handle_columnfractions(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1470 # It would be better to handle this, but for now it's in the way...
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1471 self.itemarg = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1472 def handle_tab(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1473 self.write('</TD>\n <TD>')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1474
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1475 # --- Enumerations, displays, quotations ---
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1476 # XXX Most of these should increase the indentation somehow
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1477
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1478 def bgn_quotation(self, args): self.write('<BLOCKQUOTE>')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1479 def end_quotation(self): self.write('</BLOCKQUOTE>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1480
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1481 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1482 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1483 self.write('<PRE>')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1484 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1485 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1486 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1487
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1488 bgn_lisp = bgn_example # Synonym when contents are executable lisp code
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1489 end_lisp = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1490
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1491 bgn_smallexample = bgn_example # XXX Should use smaller font
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1492 end_smallexample = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1493
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1494 bgn_smalllisp = bgn_lisp # Ditto
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1495 end_smalllisp = end_lisp
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1496
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1497 bgn_display = bgn_example
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1498 end_display = end_example
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1499
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1500 bgn_format = bgn_display
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1501 end_format = end_display
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1502
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1503 def do_exdent(self, args): self.expand(args + '\n')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1504 # XXX Should really mess with indentation
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1505
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1506 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1507 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1508 self.write('<PRE>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1509 def end_flushleft(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1510 self.write('</PRE>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1511 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1512
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1513 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1514 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1515 self.write('<ADDRESS COMPACT>\n')
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1516 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1517 self.write('</ADDRESS>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1518 self.nofill = self.nofill - 1
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1519
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1520 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1521 self.write('<DIR>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1522 self.write(' <STRONG><EM>Menu</EM></STRONG><P>\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1523 self.htmlhelp.beginmenu()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1524 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1525 self.write('</DIR>\n')
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1526 self.htmlhelp.endmenu()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1527
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1528 def bgn_cartouche(self, args): pass
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1529 def end_cartouche(self): pass
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1530
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1531 # --- Indices ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1532
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1533 def resetindex(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1534 self.noncodeindices = ['cp']
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1535 self.indextitle = {}
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1536 self.indextitle['cp'] = 'Concept'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1537 self.indextitle['fn'] = 'Function'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1538 self.indextitle['ky'] = 'Keyword'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1539 self.indextitle['pg'] = 'Program'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1540 self.indextitle['tp'] = 'Type'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1541 self.indextitle['vr'] = 'Variable'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1542 #
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1543 self.whichindex = {}
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1544 for name in self.indextitle:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1545 self.whichindex[name] = []
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1546
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1547 def user_index(self, name, args):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1548 if name in self.whichindex:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1549 self.index(name, args)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1550 else:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1551 print('*** No index named', repr(name))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1552
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1553 def do_cindex(self, args): self.index('cp', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1554 def do_findex(self, args): self.index('fn', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1555 def do_kindex(self, args): self.index('ky', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1556 def do_pindex(self, args): self.index('pg', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1557 def do_tindex(self, args): self.index('tp', args)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1558 def do_vindex(self, args): self.index('vr', args)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1559
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1560 def index(self, name, args):
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1561 self.whichindex[name].append((args, self.nodename))
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1562 self.htmlhelp.index(args, self.nodename)
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1563
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1564 def do_synindex(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1565 words = args.split()
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1566 if len(words) != 2:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1567 print('*** bad @synindex', args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1568 return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1569 [old, new] = words
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1570 if old not in self.whichindex or \
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1571 new not in self.whichindex:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1572 print('*** bad key(s) in @synindex', args)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1573 return
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1574 if old != new and \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1575 self.whichindex[old] is not self.whichindex[new]:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1576 inew = self.whichindex[new]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1577 inew[len(inew):] = self.whichindex[old]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1578 self.whichindex[old] = inew
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1579 do_syncodeindex = do_synindex # XXX Should use code font
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1580
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1581 def do_printindex(self, args):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1582 words = args.split()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1583 for name in words:
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1584 if name in self.whichindex:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1585 self.prindex(name)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1586 else:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1587 print('*** No index named', repr(name))
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1588
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1589 def prindex(self, name):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1590 iscodeindex = (name not in self.noncodeindices)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1591 index = self.whichindex[name]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1592 if not index: return
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1593 if self.debugging:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1594 print('!'*self.debugging, '--- Generating', \
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1595 self.indextitle[name], 'index')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1596 # The node already provides a title
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1597 index1 = []
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1598 junkprog = re.compile('^(@[a-z]+)?{')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1599 for key, node in index:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1600 sortkey = key.lower()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1601 # Remove leading `@cmd{' from sort key
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1602 # -- don't bother about the matching `}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1603 oldsortkey = sortkey
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1604 while 1:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1605 mo = junkprog.match(sortkey)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1606 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1607 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1608 i = mo.end()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1609 sortkey = sortkey[i:]
9309
bd9d38d64369 Fix multi-arg list.append() calls.
Guido van Rossum <guido@python.org>
parents: 9105
diff changeset
1610 index1.append((sortkey, key, node))
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1611 del index[:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1612 index1.sort()
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1613 self.write('<DL COMPACT>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1614 prevkey = prevnode = None
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1615 for sortkey, key, node in index1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1616 if (key, node) == (prevkey, prevnode):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1617 continue
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1618 if self.debugging > 1: print('!'*self.debugging, key, ':', node)
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1619 self.write('<DT>')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1620 if iscodeindex: key = '@code{' + key + '}'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1621 if key != prevkey:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1622 self.expand(key)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1623 self.write('\n<DD><A HREF="%s">%s</A>\n' % (makefile(node), node))
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1624 prevkey, prevnode = key, node
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1625 self.write('</DL>\n')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1626
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1627 # --- Final error reports ---
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1628
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1629 def report(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1630 if self.unknown:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1631 print('--- Unrecognized commands ---')
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1632 cmds = sorted(self.unknown.keys())
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1633 for cmd in cmds:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1634 print(cmd.ljust(20), self.unknown[cmd])
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1635
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1636
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1637 class TexinfoParserHTML3(TexinfoParser):
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1638
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1639 COPYRIGHT_SYMBOL = "&copy;"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1640 FN_ID_PATTERN = "[%(id)s]"
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1641 FN_SOURCE_PATTERN = '<A ID=footnoteref%(id)s ' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1642 'HREF="#footnotetext%(id)s">' + FN_ID_PATTERN + '</A>'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1643 FN_TARGET_PATTERN = '<FN ID=footnotetext%(id)s>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1644 '<P><A HREF="#footnoteref%(id)s">' + FN_ID_PATTERN \
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1645 + '</A>\n%(text)s</P></FN>\n'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1646 FN_HEADER = '<DIV CLASS=footnotes>\n <HR NOSHADE WIDTH=200>\n' \
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1647 ' <STRONG><EM>Footnotes</EM></STRONG>\n <P>\n'
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1648
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1649 Node = HTML3Node
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1650
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1651 def bgn_quotation(self, args): self.write('<BQ>')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1652 def end_quotation(self): self.write('</BQ>\n')
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1653
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1654 def bgn_example(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1655 # this use of <CODE> would not be legal in HTML 2.0,
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1656 # but is in more recent DTDs.
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1657 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1658 self.write('<PRE CLASS=example><CODE>')
4507
18927abdc262 (texi2html.py): Minor improvement to HTML 3.0 output for code examples.
Fred Drake <fdrake@acm.org>
parents: 4405
diff changeset
1659 def end_example(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1660 self.write("</CODE></PRE>\n")
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1661 self.nofill = self.nofill - 1
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1662
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1663 def bgn_flushleft(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1664 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1665 self.write('<PRE CLASS=flushleft>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1666
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1667 def bgn_flushright(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1668 self.nofill = self.nofill + 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1669 self.write('<DIV ALIGN=right CLASS=flushright><ADDRESS COMPACT>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1670 def end_flushright(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1671 self.write('</ADDRESS></DIV>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1672 self.nofill = self.nofill - 1
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1673
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1674 def bgn_menu(self, args):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1675 self.write('<UL PLAIN CLASS=menu>\n')
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1676 self.write(' <LH>Menu</LH>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1677 def end_menu(self):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1678 self.write('</UL>\n')
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1679
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
1680
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1681 # rpyron 2002-05-07
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1682 class HTMLHelp:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1683 """
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1684 This class encapsulates support for HTML Help. Node names,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1685 file names, menu items, index items, and image file names are
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1686 accumulated until a call to finalize(). At that time, three
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1687 output files are created in the current directory:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1688
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1689 `helpbase`.hhp is a HTML Help Workshop project file.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1690 It contains various information, some of
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1691 which I do not understand; I just copied
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1692 the default project info from a fresh
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1693 installation.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1694 `helpbase`.hhc is the Contents file for the project.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1695 `helpbase`.hhk is the Index file for the project.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1696
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1697 When these files are used as input to HTML Help Workshop,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1698 the resulting file will be named:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1699
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1700 `helpbase`.chm
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1701
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1702 If none of the defaults in `helpbase`.hhp are changed,
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1703 the .CHM file will have Contents, Index, Search, and
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1704 Favorites tabs.
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1705 """
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1706
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1707 codeprog = re.compile('@code{(.*?)}')
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1708
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1709 def __init__(self,helpbase,dirname):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1710 self.helpbase = helpbase
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1711 self.dirname = dirname
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1712 self.projectfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1713 self.contentfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1714 self.indexfile = None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1715 self.nodelist = []
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1716 self.nodenames = {} # nodename : index
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1717 self.nodeindex = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1718 self.filenames = {} # filename : filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1719 self.indexlist = [] # (args,nodename) == (key,location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1720 self.current = ''
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1721 self.menudict = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1722 self.dumped = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1723
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1724
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1725 def addnode(self,name,next,prev,up,filename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1726 node = (name,next,prev,up,filename)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1727 # add this file to dict
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1728 # retrieve list with self.filenames.values()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1729 self.filenames[filename] = filename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1730 # add this node to nodelist
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1731 self.nodeindex[name] = len(self.nodelist)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1732 self.nodelist.append(node)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1733 # set 'current' for menu items
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1734 self.current = name
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1735 self.menudict[self.current] = []
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1736
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1737 def menuitem(self,nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1738 menu = self.menudict[self.current]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1739 menu.append(nodename)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1740
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1741
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1742 def addimage(self,imagename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1743 self.filenames[imagename] = imagename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1744
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1745 def index(self, args, nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1746 self.indexlist.append((args,nodename))
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1747
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1748 def beginmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1749 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1750
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1751 def endmenu(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1752 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1753
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1754 def finalize(self):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1755 if not self.helpbase:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1756 return
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1757
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1758 # generate interesting filenames
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1759 resultfile = self.helpbase + '.chm'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1760 projectfile = self.helpbase + '.hhp'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1761 contentfile = self.helpbase + '.hhc'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1762 indexfile = self.helpbase + '.hhk'
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1763
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1764 # generate a reasonable title
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1765 title = self.helpbase
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1766
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1767 # get the default topic file
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1768 (topname,topnext,topprev,topup,topfile) = self.nodelist[0]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1769 defaulttopic = topfile
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1770
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1771 # PROJECT FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1772 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1773 fp = open(projectfile,'w')
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1774 print('[OPTIONS]', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1775 print('Auto Index=Yes', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1776 print('Binary TOC=No', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1777 print('Binary Index=Yes', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1778 print('Compatibility=1.1', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1779 print('Compiled file=' + resultfile + '', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1780 print('Contents file=' + contentfile + '', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1781 print('Default topic=' + defaulttopic + '', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1782 print('Error log file=ErrorLog.log', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1783 print('Index file=' + indexfile + '', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1784 print('Title=' + title + '', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1785 print('Display compile progress=Yes', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1786 print('Full-text search=Yes', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1787 print('Default window=main', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1788 print('', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1789 print('[WINDOWS]', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1790 print('main=,"' + contentfile + '","' + indexfile
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1791 + '","","",,,,,0x23520,222,0x1046,[10,10,780,560],'
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1792 '0xB0000,,,,,,0', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1793 print('', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1794 print('[FILES]', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1795 print('', file=fp)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1796 self.dumpfiles(fp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1797 fp.close()
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 32734
diff changeset
1798 except IOError as msg:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1799 print(projectfile, ':', msg)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1800 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1801
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1802 # CONTENT FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1803 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1804 fp = open(contentfile,'w')
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1805 print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1806 print('<!-- This file defines the table of contents -->', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1807 print('<HTML>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1808 print('<HEAD>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1809 print('<meta name="GENERATOR"'
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1810 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1811 print('<!-- Sitemap 1.0 -->', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1812 print('</HEAD>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1813 print('<BODY>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1814 print(' <OBJECT type="text/site properties">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1815 print(' <param name="Window Styles" value="0x800025">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1816 print(' <param name="comment" value="title:">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1817 print(' <param name="comment" value="base:">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1818 print(' </OBJECT>', file=fp)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1819 self.dumpnodes(fp)
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1820 print('</BODY>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1821 print('</HTML>', file=fp)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1822 fp.close()
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 32734
diff changeset
1823 except IOError as msg:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1824 print(contentfile, ':', msg)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1825 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1826
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1827 # INDEX FILE
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1828 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1829 fp = open(indexfile ,'w')
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1830 print('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1831 print('<!-- This file defines the index -->', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1832 print('<HTML>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1833 print('<HEAD>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1834 print('<meta name="GENERATOR"'
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1835 'content="Microsoft&reg; HTML Help Workshop 4.1">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1836 print('<!-- Sitemap 1.0 -->', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1837 print('</HEAD>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1838 print('<BODY>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1839 print('<OBJECT type="text/site properties">', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1840 print('</OBJECT>', file=fp)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1841 self.dumpindex(fp)
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1842 print('</BODY>', file=fp)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1843 print('</HTML>', file=fp)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1844 fp.close()
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 32734
diff changeset
1845 except IOError as msg:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1846 print(indexfile , ':', msg)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1847 sys.exit(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1848
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1849 def dumpfiles(self, outfile=sys.stdout):
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1850 filelist = sorted(self.filenames.values())
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1851 for filename in filelist:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1852 print(filename, file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1853
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1854 def dumpnodes(self, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1855 self.dumped = {}
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1856 if self.nodelist:
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
1857 nodename, dummy, dummy, dummy, dummy = self.nodelist[0]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1858 self.topnode = nodename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1859
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1860 print('<UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1861 for node in self.nodelist:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1862 self.dumpnode(node,0,outfile)
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1863 print('</UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1864
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1865 def dumpnode(self, node, indent=0, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1866 if node:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1867 # Retrieve info for this node
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1868 (nodename,next,prev,up,filename) = node
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1869 self.current = nodename
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1870
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1871 # Have we been dumped already?
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
1872 if nodename in self.dumped:
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1873 return
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1874 self.dumped[nodename] = 1
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1875
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1876 # Print info for this node
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1877 print(' '*indent, end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1878 print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1879 print('<param name="Name" value="' + nodename +'">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1880 print('<param name="Local" value="'+ filename +'">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1881 print('</OBJECT>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1882
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1883 # Does this node have menu items?
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1884 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1885 menu = self.menudict[nodename]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1886 self.dumpmenu(menu,indent+2,outfile)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1887 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1888 pass
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1889
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1890 def dumpmenu(self, menu, indent=0, outfile=sys.stdout):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1891 if menu:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1892 currentnode = self.current
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1893 if currentnode != self.topnode: # XXX this is a hack
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1894 print(' '*indent + '<UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1895 indent += 2
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1896 for item in menu:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1897 menunode = self.getnode(item)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1898 self.dumpnode(menunode,indent,outfile)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1899 if currentnode != self.topnode: # XXX this is a hack
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1900 print(' '*indent + '</UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1901 indent -= 2
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1902
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1903 def getnode(self, nodename):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1904 try:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1905 index = self.nodeindex[nodename]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1906 return self.nodelist[index]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1907 except KeyError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1908 return None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1909 except IndexError:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1910 return None
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1911
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1912 # (args,nodename) == (key,location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1913 def dumpindex(self, outfile=sys.stdout):
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1914 print('<UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1915 for (key,location) in self.indexlist:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1916 key = self.codeexpand(key)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1917 location = makefile(location)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1918 location = self.dirname + '/' + location
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1919 print('<LI><OBJECT type="text/sitemap">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1920 print('<param name="Name" value="' + key + '">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1921 print('<param name="Local" value="' + location + '">', end=' ', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1922 print('</OBJECT>', file=outfile)
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
1923 print('</UL>', file=outfile)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1924
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1925 def codeexpand(self, line):
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1926 co = self.codeprog.match(line)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1927 if not co:
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1928 return line
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1929 bgn, end = co.span(0)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1930 a, b = co.span(1)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1931 line = line[:bgn] + line[a:b] + line[end:]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1932 return line
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1933
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
1934
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1935 # Put @var{} around alphabetic substrings
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1936 def makevar(str):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1937 return '@var{'+str+'}'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1938
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1939
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1940 # Split a string in "words" according to findwordend
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1941 def splitwords(str, minlength):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1942 words = []
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1943 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1944 n = len(str)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1945 while i < n:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1946 while i < n and str[i] in ' \t\n': i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1947 if i >= n: break
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1948 start = i
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1949 i = findwordend(str, i, n)
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1950 words.append(str[start:i])
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1951 while len(words) < minlength: words.append('')
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1952 return words
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1953
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1954
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1955 # Find the end of a "word", matching braces and interpreting @@ @{ @}
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1956 fwprog = re.compile('[@{} ]')
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1957 def findwordend(str, i, n):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1958 level = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1959 while i < n:
8134
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1960 mo = fwprog.search(str, i)
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1961 if not mo:
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1962 break
c7d99f6d2e2f Use the (new) standard script #! line
Barry Warsaw <barry@python.org>
parents: 4507
diff changeset
1963 i = mo.start()
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1964 c = str[i]; i = i+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1965 if c == '@': i = i+1 # Next character is not special
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1966 elif c == '{': level = level+1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1967 elif c == '}': level = level-1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1968 elif c == ' ' and level <= 0: return i-1
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1969 return n
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1970
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1971
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1972 # Convert a node name into a file name
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1973 def makefile(nodename):
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
1974 nodename = nodename.strip()
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1975 return fixfunnychars(nodename) + '.html'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1976
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1977
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1978 # Characters that are perfectly safe in filenames and hyperlinks
18781
01ae962df885 Use string.ascii_letters instead of string.letters (SF bug #226706).
Fred Drake <fdrake@acm.org>
parents: 15930
diff changeset
1979 goodchars = string.ascii_letters + string.digits + '!@-=+.'
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1980
3016
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1981 # Replace characters that aren't perfectly safe by dashes
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1982 # Underscores are bad since Cern HTTPD treats them as delimiters for
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1983 # encoding times, so you get mismatches if you compress your files:
7ae332472629 many fixes by anonymous contributor
Guido van Rossum <guido@python.org>
parents: 2705
diff changeset
1984 # a.html.gz will map to a_b.html.gz
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1985 def fixfunnychars(addr):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1986 i = 0
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1987 while i < len(addr):
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1988 c = addr[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1989 if c not in goodchars:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1990 c = '-'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1991 addr = addr[:i] + c + addr[i+1:]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1992 i = i + len(c)
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1993 return addr
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1994
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1995
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1996 # Increment a string used as an enumeration
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
1997 def increment(s):
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
1998 if not s:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
1999 return '1'
42585
b623777f22b0 Remove string.{letters,lowercase,uppercase}.
Martin v. Löwis <martin@v.loewis.de>
parents: 42427
diff changeset
2000 for sequence in string.digits, string.ascii_lowercase, string.ascii_uppercase:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2001 lastc = s[-1]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2002 if lastc in sequence:
23896
ad1d862fb632 Mechanically translated string method calls to string methods.
Fred Drake <fdrake@acm.org>
parents: 23895
diff changeset
2003 i = sequence.index(lastc) + 1
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2004 if i >= len(sequence):
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2005 if len(s) == 1:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2006 s = sequence[0]*2
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2007 if s == '00':
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2008 s = '10'
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2009 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2010 s = increment(s[:-1]) + sequence[0]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2011 else:
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2012 s = s[:-1] + sequence[i]
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2013 return s
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2014 return s # Don't increment
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2015
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2016
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2017 def test():
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2018 import sys
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2019 debugging = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2020 print_headers = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2021 cont = 0
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2022 html3 = 0
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2023 htmlhelp = ''
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 9309
diff changeset
2024
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2025 while sys.argv[1] == ['-d']:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2026 debugging = debugging + 1
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2027 del sys.argv[1]
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2028 if sys.argv[1] == '-p':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2029 print_headers = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2030 del sys.argv[1]
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2031 if sys.argv[1] == '-c':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2032 cont = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2033 del sys.argv[1]
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2034 if sys.argv[1] == '-3':
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2035 html3 = 1
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2036 del sys.argv[1]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2037 if sys.argv[1] == '-H':
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2038 helpbase = sys.argv[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2039 del sys.argv[1:3]
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 42715
diff changeset
2040 if len(sys.argv) != 3:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
2041 print('usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
2042 'inputfile outputdirectory')
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2043 sys.exit(2)
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2044
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2045 if html3:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2046 parser = TexinfoParserHTML3()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2047 else:
9105
9eb2d6f6fd3f nannified
Guido van Rossum <guido@python.org>
parents: 8134
diff changeset
2048 parser = TexinfoParser()
4392
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2049 parser.cont = cont
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2050 parser.debugging = debugging
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2051 parser.print_headers = print_headers
72a0cfda2004 (texi2html.py): Tightened the generated HTML slightly. Added -p option to
Fred Drake <fdrake@acm.org>
parents: 4307
diff changeset
2052
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2053 file = sys.argv[1]
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2054 dirname = sys.argv[2]
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2055 parser.setdirname(dirname)
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2056 parser.setincludedir(os.path.dirname(file))
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2057
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2058 htmlhelp = HTMLHelp(helpbase, dirname)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2059 parser.sethtmlhelp(htmlhelp)
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2060
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2061 try:
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2062 fp = open(file, 'r')
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 32734
diff changeset
2063 except IOError as msg:
42427
46625e6122e9 Convert print statements to function calls in Tools/.
Collin Winter <collinw@gmail.com>
parents: 40587
diff changeset
2064 print(file, ':', msg)
32734
b1d142d71482 WTF is with this script? It contained illegal syntax and illegal
Tim Peters <tim.peters@gmail.com>
parents: 31515
diff changeset
2065 sys.exit(1)
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2066
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2067 parser.parse(fp)
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2068 fp.close()
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2069 parser.report()
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2070
23895
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2071 htmlhelp.finalize()
02c5045d5b4e SF patch #552837, submitted by Robert Pyron:
Fred Drake <fdrake@acm.org>
parents: 18781
diff changeset
2072
2551
c55dddbfcf7c new, from ../Demo/www
Guido van Rossum <guido@python.org>
parents:
diff changeset
2073
4307
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2074 if __name__ == "__main__":
2eec35e2afff (texi2html.py): Use "if __name__ == '__main__':" test. Adjust indentation
Fred Drake <fdrake@acm.org>
parents: 3998
diff changeset
2075 test()