1
2
3
4
5
6
7
8
9 """
10 Predefined CSS stylesheets for the HTML outputter (L{epydoc.docwriter.html}).
11
12 @type STYLESHEETS: C{dictionary} from C{string} to C{(string, string)}
13 @var STYLESHEETS: A dictionary mapping from stylesheet names to CSS
14 stylesheets and descriptions. A single stylesheet may have
15 multiple names. Currently, the following stylesheets are defined:
16 - C{default}: The default stylesheet (synonym for C{white}).
17 - C{white}: Black on white, with blue highlights (similar to
18 javadoc).
19 - C{blue}: Black on steel blue.
20 - C{green}: Black on green.
21 - C{black}: White on black, with blue highlights
22 - C{grayscale}: Grayscale black on white.
23 - C{none}: An empty stylesheet.
24 """
25 __docformat__ = 'epytext en'
26
27 import re
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 _LAYOUT = """
46
47 /* Tables */
48 table.help { margin-left: auto; margin-right: auto; }
49 th.summary, th.details, th.index
50 { text-align: left; font-size: 120%; }
51 th.group { text-align: left; font-size: 120%;
52 font-style: italic; }
53
54 /* Documentation page titles */
55 h2.module { margin-top: 0.2em; }
56 h2.class { margin-top: 0.2em; }
57 h2.type { margin-top: 0.2em; }
58 h2.py-src { margin-top: 0.2em; }
59
60 /* Headings */
61 h1.help { text-align: center; }
62 h1.heading { font-size: +140%; font-style: italic;
63 font-weight: bold; }
64 h2.heading { font-size: +125%; font-style: italic;
65 font-weight: bold; }
66 h3.heading { font-size: +110%; font-style: italic;
67 font-weight: normal; }
68 h1.tocheading { text-align: center; font-size: 105%; margin: 0;
69 font-weight: bold; padding: 0; }
70 h2.tocheading { font-size: 100%; margin: 0.5em 0 0 -0.3em;
71 font-weight: bold; }
72
73 /* Table of contents */
74 p.toc { margin: 0; padding: 0; }
75
76 /* Base tree */
77 pre.base-tree { font-size: 80%; margin: 0; }
78
79 /* Summary Sections */
80 p.varlist { padding: 0 0 0 7em; text-indent: -7em;
81 margin: 0; }
82 .varlist-header { font-weight: bold; }
83 p.imports { padding: 0 0 0 7em; text-indent: -7em; }
84 .imports-header { font-weight: bold; }
85
86 /* Details Sections */
87 table.func-details { border-width: 2px; border-style: groove;
88 padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
89 h3.func-detail { margin: 0 0 1em 0; }
90 table.var-details { border-width: 2px; border-style: groove;
91 padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
92 h3.var-details { margin: 0 0 1em 0; }
93 table.prop-details { border-width: 2px; border-style: groove;
94 padding: 0 1em 0 1em; margin: 0.4em 0 0 0; }
95 h3.prop-details { margin: 0 0 1em 0; }
96
97 /* Function signatures */
98 .sig { font-weight: bold; }
99
100 /* Doctest blocks */
101 .py-prompt { font-weight: bold;}
102 pre.doctestblock { padding: .5em; margin: 1em;
103 border-width: 1px; border-style: solid; }
104 table pre.doctestblock
105 { padding: .5em; margin: 1em;
106 border-width: 1px; border-style: solid; }
107
108 /* Variable values */
109 pre.variable { padding: .5em; margin: 0;
110 border-width: 1px; border-style: solid; }
111
112 /* Navigation bar */
113 table.navbar { border-width: 2px; border-style: groove; }
114 .nomargin { margin: 0; }
115
116 /* This is used in <div> sections containing tables of private
117 values, to make them flow more seamlessly with the table that
118 comes before them. */
119 .continue { border-top: 0; }
120
121 /* Links */
122 a.navbar { text-decoration: none; }
123
124 /* Source Code Listings */
125 pre.py-src { border: 2px solid black; }
126 div.highlight-hdr { border-top: 2px solid black;
127 border-bottom: 1px solid black; }
128 div.highlight { border-bottom: 2px solid black; }
129 a.pysrc-toggle { text-decoration: none; }
130 .py-line { border-left: 2px solid black; margin-left: .2em;
131 padding-left: .4em; }
132 .lineno { font-style: italic; font-size: 90%;
133 padding-left: .5em; }
134 /*a.py-name { text-decoration: none; }*/
135
136 /* For Graphs */
137 .graph-without-title { border: none; }
138 .graph-with-title { border: 1px solid black; }
139 .graph-title { font-weight: bold; }
140
141 /* Lists */
142 ul { margin-top: 0; }
143
144 /* Misc. */
145 .footer { font-size: 85%; }
146 .header { font-size: 85%; }
147 .breadcrumbs { font-size: 85%; font-weight: bold; }
148 .options { font-size: 70%; }
149 .rtype, .ptype, .vtype
150 { font-size: 85%; }
151 dt { font-weight: bold; }
152 .small { font-size: 85%; }
153
154 h2 span.codelink { font-size: 58%; font-weight: normal; }
155 span.codelink { font-size: 85%; font-weight; normal; }
156 """
157
158
159
160 _WHITE = _LAYOUT + """
161 /* Body color */
162 body { background: #ffffff; color: #000000; }
163
164 /* Tables */
165 table.summary, table.details, table.index
166 { background: #e8f0f8; color: #000000; }
167 tr.summary, tr.details, tr.index
168 { background: #70b0ff; color: #000000; }
169 th.group { background: #c0e0f8; color: #000000; }
170
171 /* Details Sections */
172 table.func-details { background: #e8f0f8; color: #000000;
173 border-color: #c0d0d0; }
174 h3.func-detail { background: transparent; color: #000000; }
175 table.var-details { background: #e8f0f8; color: #000000;
176 border-color: #c0d0d0; }
177 h3.var-details { background: transparent; color: #000000; }
178 table.prop-details { background: #e8f0f8; color: #000000;
179 border-color: #c0d0d0; }
180 h3.prop-details { background: transparent; color: #000000; }
181
182 /* Function signatures */
183 .sig { background: transparent; color: #000000; }
184 .sig-name { background: transparent; color: #006080; }
185 .sig-arg, .sig-kwarg, .sig-vararg
186 { background: transparent; color: #008060; }
187 .sig-default { background: transparent; color: #602000; }
188 .summary-sig { background: transparent; color: #000000; }
189 .summary-sig-name { background: transparent; color: #204080; }
190 .summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
191 { background: transparent; color: #008060; }
192
193 /* Souce code listings & doctest blocks */
194 .py-src { background: transparent; color: #000000; }
195 .py-prompt { background: transparent; color: #005050; }
196 .py-string { background: transparent; color: #006030; }
197 .py-comment { background: transparent; color: #003060; }
198 .py-keyword { background: transparent; color: #600000; }
199 .py-output { background: transparent; color: #404040; }
200 .py-name { background: transparent; color: #000050; }
201 .py-name:link { background: transparent; color: #000050; }
202 .py-name:visited { background: transparent; color: #000050; }
203 .py-number { background: transparent; color: #005000; }
204 .py-def-name { background: transparent; color: #000060;
205 font-weight: bold; }
206 .py-base-class { background: transparent; color: #000060; }
207 .py-param { background: transparent; color: #000060; }
208 .py-docstring { background: transparent; color: #006030; }
209 .py-decorator { background: transparent; color: #804020; }
210
211 pre.doctestblock { background: #f4faff; color: #000000;
212 border-color: #708890; }
213 table pre.doctestblock
214 { background: #dce4ec; color: #000000;
215 border-color: #708890; }
216 div.py-src { background: #f0f0f0; }
217 div.highlight-hdr { background: #d8e8e8; }
218 div.highlight { background: #d0e0e0; }
219
220
221 /* Variable values */
222 pre.variable { background: #dce4ec; color: #000000;
223 border-color: #708890; }
224 .variable-linewrap { background: transparent; color: #604000; }
225 .variable-ellipsis { background: transparent; color: #604000; }
226 .variable-quote { background: transparent; color: #604000; }
227 .re { background: transparent; color: #000000; }
228 .re-char { background: transparent; color: #006030; }
229 .re-op { background: transparent; color: #600000; }
230 .re-group { background: transparent; color: #003060; }
231 .re-ref { background: transparent; color: #404040; }
232
233 /* Navigation bar */
234 table.navbar { background: #a0c0ff; color: #0000ff;
235 border-color: #c0d0d0; }
236 th.navbar { background: #a0c0ff; color: #0000ff; }
237 th.navselect { background: #70b0ff; color: #000000; }
238
239 /* Links */
240 a:link { background: transparent; color: #0000ff; }
241 a:visited { background: transparent; color: #204080; }
242 a.navbar:link { background: transparent; color: #0000ff; }
243 a.navbar:visited { background: transparent; color: #204080; }
244 """
245
246
247 _OLD_BLUE = _LAYOUT + """
248 /* Body color */
249 body { background: #88a0a8; color: #000000; }
250
251 /* Tables */
252 table.summary, table.details, table.index
253 { background: #a8c0c8; color: #000000; }
254 tr.summary { background: #c0e0e0; color: #000000; }
255 tr.details, tr.index
256 { background: #c0e0e0; color: #000000; }
257 th.group { background: #bad8e0; color: #000000; }
258
259 /* Documentation page titles */
260 h2.module { margin-top: 0.2em; }
261 h2.class { margin-top: 0.2em ; }
262
263 /* Headings */
264 h1.heading { background: transparent; color: #002040; }
265 h2.heading { background: transparent; color: #002040; }
266 h3.heading { background: transparent; color: #002040; }
267
268 /* Details Sections */
269 table.func-details { background: #a8c0c8; color: #000000;
270 border-color: #c0d0d0; }
271 h3.func-detail { background: transparent; color: #000000; }
272 table.var-details { background: #a8c0c8; color: #000000;
273 border-color: #c0d0d0; }
274 h3.var-details { background: transparent; color: #000000; }
275 table.prop-details { background: #a8c0c8; color: #000000;
276 border-color: #c0d0d0; }
277 h3.prop-details { background: transparent; color: #000000; }
278
279 /* Function signatures */
280 .sig { background: transparent; color: #000000; }
281 .sig-name { background: transparent; color: #006080; }
282 .sig-arg, .sig-kwarg, .sig-vararg
283 { background: transparent; color: #008060; }
284 .sig-default { background: transparent; color: #602000; }
285 .summary-sig { background: transparent; color: #000000; }
286 .summary-sig-name { background: transparent; color: #104060; }
287 .summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
288 { background: transparent; color: #008060; }
289
290 /* Souce code listings & doctest blocks */
291 .py-src { background: transparent; color: #000000; }
292 .py-prompt { background: transparent; color: #005050; }
293 .py-string { background: transparent; color: #006030; }
294 .py-comment { background: transparent; color: #003060; }
295 .py-keyword { background: transparent; color: #600000; }
296 .py-output { background: transparent; color: #404040; }
297 .py-name { background: transparent; color: #000050; }
298 .py-name:link { background: transparent; color: #000050; }
299 .py-name:visited { background: transparent; color: #000050; }
300 .py-number { background: transparent; color: #005000; }
301 .py-def-name { background: transparent; color: #000060;
302 font-weight: bold; }
303 .py-base-class { background: transparent; color: #000060; }
304 .py-param { background: transparent; color: #000060; }
305 .py-docstring { background: transparent; color: #006030; }
306 .py-decorator { background: transparent; color: #804020; }
307
308 pre.doctestblock { background: #90a8b0; color: #000000; }
309 border-color: #708890; }
310 table pre.doctestblock
311 { background: #b0c8d0; color: #000000;
312 border-color: #708890; }
313 div.py-src { background: #f0f0f0; }
314 div.highlight-hdr { background: #d8e8e8; }
315 div.highlight { background: #d0e0e0; }
316
317 /* Variable values */
318 pre.variable { background: #b0c8d0; color: #000000;
319 border-color: #708890; }
320 .variable-linewrap { background: transparent; color: #604000; }
321 .variable-ellipsis { background: transparent; color: #604000; }
322 .variable-quote { background: transparent; color: #604000; }
323 .re { background: transparent; color: #000000; }
324 .re-char { background: transparent; color: #006030; }
325 .re-op { background: transparent; color: #600000; }
326 .re-group { background: transparent; color: #003060; }
327 .re-ref { background: transparent; color: #404040; }
328
329 /* Navigation bar */
330 table.navbar { background: #607880; color: #b8d0d0;
331 border-color: #c0d0d0; }
332 th.navbar { background: #607880; color: #b8d0d0; }
333 th.navselect { background: #88a0a8; color: #000000; }
334
335 /* Links */
336 a:link { background: transparent; color: #104060; }
337 a:visited { background: transparent; color: #082840; }
338 a.navbar:link { background: transparent; color: #b8d0d0; }
339 a.navbar:visited { background: transparent; color: #b8d0d0; }
340 """
341
342
343 _BLUE = _LAYOUT + """
344 /* Body color */
345 body { background: #b0c8d0; color: #000000; }
346
347 /* Tables */
348 table.summary, table.details, table.index
349 { background: #c8e0e8; color: #000000; }
350 tr.summary { background: #dcf4fc; color: #000000; }
351 tr.details, tr.index
352 { background: #dcf4fc; color: #000000; }
353 th.group { background: #bad8e0; color: #000000; }
354
355 /* Documentation page titles */
356 h2.module { margin-top: 0.2em; }
357 h2.class { margin-top: 0.2em ; }
358
359 /* Headings */
360 h1.heading { background: transparent; color: #002060; }
361 h2.heading { background: transparent; color: #002060; }
362 h3.heading { background: transparent; color: #002060; }
363
364 /* Details Sections */
365 table.func-details { background: #c8e0e8; color: #000000;
366 border-color: #c0d0d0; }
367 h3.func-detail { background: transparent; color: #000000; }
368 table.var-details { background: #c8e0e8; color: #000000;
369 border-color: #ffffff; }
370 h3.var-details { background: transparent; color: #000000; }
371 table.prop-details { background: #c8e0e8; color: #000000;
372 border-color: #ffffff; }
373 h3.prop-details { background: transparent; color: #000000; }
374
375 /* Function signatures */
376 .sig { background: transparent; color: #000000; }
377 .sig-name { background: transparent; color: #006080; }
378 .sig-arg, .sig-kwarg, .sig-vararg
379 { background: transparent; color: #008060; }
380 .sig-default { background: transparent; color: #602000; }
381 .summary-sig { background: transparent; color: #000000; }
382 .summary-sig-name { background: transparent; color: #082840; }
383 .summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg
384 { background: transparent; color: #008060; }
385
386 /* Souce code listings & doctest blocks */
387 .py-src { background: transparent; color: #000000; }
388 .py-prompt { background: transparent; color: #006070; }
389 .py-string { background: transparent; color: #007050; }
390 .py-comment { background: transparent; color: #004080; }
391 .py-keyword { background: transparent; color: #800000; }
392 .py-output { background: transparent; color: #484848; }
393 .py-name { background: transparent; color: #000050; }
394 .py-name:link { background: transparent; color: #000050; }
395 .py-name:visited { background: transparent; color: #000050; }
396 .py-number { background: transparent; color: #005000; }
397 .py-def-name { background: transparent; color: #000060;
398 font-weight: bold; }
399 .py-base-class { background: transparent; color: #000060; }
400 .py-param { background: transparent; color: #000060; }
401 .py-docstring { background: transparent; color: #006030; }
402 .py-decorator { background: transparent; color: #804020; }
403
404 pre.doctestblock { background: #c8e0e8; color: #000000;
405 border-color: #708890; }
406 table pre.doctestblock
407 { background: #c0d8e0; color: #000000;
408 border-color: #708890; }
409 div.py-src { background: #f0f0f0; }
410 div.highlight-hdr { background: #d8e8e8; }
411 div.highlight { background: #d0e0e0; }
412
413 /* Variable values */
414 pre.variable { background: #c0d8e0; color: #000000;
415 border-color: #708890; }
416 .variable-linewrap { background: transparent; color: #705000; }
417 .variable-ellipsis { background: transparent; color: #705000; }
418 .variable-quote { background: transparent; color: #705000; }
419 .re { background: transparent; color: #000000; }
420 .re-char { background: transparent; color: #007050; }
421 .re-op { background: transparent; color: #800000; }
422 .re-group { background: transparent; color: #004080; }
423 .re-ref { background: transparent; color: #484848; }
424
425 /* Navigation bar */
426 table.navbar { background: #688088; color: #d8f0f0;
427 border-color: #c0d0d0; }
428 th.navbar { background: #688088; color: #d8f0f0; }
429 th.navselect { background: #88a0a8; color: #000000; }
430
431 /* Links */
432 a:link { background: transparent; color: #104060; }
433 a:visited { background: transparent; color: #082840; }
434 a.navbar:link { background: transparent; color: #d8f0f0; }
435 a.navbar:visited { background: transparent; color: #d8f0f0; }
436 """
437
438
439
440
441
442
443
444
445 _COLOR_RE = re.compile(r'#(..)(..)(..)')
446
448 """
449 Given a regexp match for a color, return the reverse-video version
450 of that color.
451
452 @param match: A regular expression match.
453 @type match: C{Match}
454 @return: The reverse-video color.
455 @rtype: C{string}
456 """
457 str = '#'
458 for color in match.groups():
459 str += '%02x' % (255-int(color, 16))
460 return str
461
462
463 _OLD_GREEN = _COLOR_RE.sub(r'#\1\3\2', _OLD_BLUE)
464 _GREEN = _COLOR_RE.sub(r'#\1\3\2', _BLUE)
465
466
467 _BLACK = _COLOR_RE.sub(r'#\3\2\1', _COLOR_RE.sub(_rv, _WHITE))
468
469
470 _GRAYSCALE = _COLOR_RE.sub(r'#\2\2\2', _WHITE)
471
472
473
474
475
476
477 STYLESHEETS = {
478 'white': (_WHITE, "Black on white, with blue highlights"),
479 'blue': (_BLUE, "Black on steel blue"),
480 'green': (_GREEN, "Black on green"),
481 'black': (_BLACK, "White on black, with blue highlights"),
482 'grayscale': (_GRAYSCALE, "Grayscale black on white"),
483 'default': (_WHITE, "Default stylesheet (=white)"),
484 'none': (_LAYOUT, "A base stylesheet (no color modifications)"),
485 }
486