10 |
10 |
11 import sys |
11 import sys |
12 import os |
12 import os |
13 |
13 |
14 from Utilities import joinext |
14 from Utilities import joinext |
|
15 |
|
16 from . import TemplatesListsStyleCSS |
15 |
17 |
16 |
18 |
17 class IndexGenerator: |
19 class IndexGenerator: |
18 """ |
20 """ |
19 Class implementing the index generator for the builtin documentation |
21 Class implementing the index generator for the builtin documentation |
20 generator. |
22 generator. |
21 """ |
23 """ |
22 def __init__(self, outputDir, colors, stylesheet=None): |
24 def __init__(self, outputDir): |
23 """ |
25 """ |
24 Constructor |
26 Constructor |
25 |
27 |
26 @param outputDir The output directory for the files. (string) |
28 @param outputDir The output directory for the files |
27 @param colors Dictionary specifying the various colors for the output. |
29 @type str |
28 (dictionary of strings) |
|
29 @param stylesheet the style to be used for the generated pages (string) |
|
30 """ |
30 """ |
31 self.outputDir = outputDir |
31 self.outputDir = outputDir |
32 self.packages = { |
32 self.packages = { |
33 "00index": { |
33 "00index": { |
34 "description": "", |
34 "description": "", |
36 "modules": {} |
36 "modules": {} |
37 } |
37 } |
38 } |
38 } |
39 self.remembered = False |
39 self.remembered = False |
40 |
40 |
41 self.stylesheet = stylesheet |
41 # TODO: replace these assignments |
42 |
42 self.headerTemplate = TemplatesListsStyleCSS.headerTemplate |
43 if self.stylesheet: |
43 self.footerTemplate = TemplatesListsStyleCSS.footerTemplate |
44 from . import TemplatesListsStyleCSS |
44 self.indexBodyTemplate = TemplatesListsStyleCSS.indexBodyTemplate |
45 self.headerTemplate = TemplatesListsStyleCSS.headerTemplate |
45 self.indexListPackagesTemplate = ( |
46 self.footerTemplate = TemplatesListsStyleCSS.footerTemplate |
46 TemplatesListsStyleCSS.indexListPackagesTemplate) |
47 self.indexBodyTemplate = TemplatesListsStyleCSS.indexBodyTemplate |
47 self.indexListModulesTemplate = ( |
48 self.indexListPackagesTemplate = ( |
48 TemplatesListsStyleCSS.indexListModulesTemplate) |
49 TemplatesListsStyleCSS.indexListPackagesTemplate) |
49 self.indexListEntryTemplate = ( |
50 self.indexListModulesTemplate = ( |
50 TemplatesListsStyleCSS.indexListEntryTemplate) |
51 TemplatesListsStyleCSS.indexListModulesTemplate) |
|
52 self.indexListEntryTemplate = ( |
|
53 TemplatesListsStyleCSS.indexListEntryTemplate) |
|
54 else: |
|
55 from . import TemplatesListsStyle |
|
56 self.headerTemplate = ( |
|
57 TemplatesListsStyle.headerTemplate.format(**colors)) |
|
58 self.footerTemplate = ( |
|
59 TemplatesListsStyle.footerTemplate.format(**colors)) |
|
60 self.indexBodyTemplate = ( |
|
61 TemplatesListsStyle.indexBodyTemplate.format(**colors)) |
|
62 self.indexListPackagesTemplate = ( |
|
63 TemplatesListsStyle.indexListPackagesTemplate.format(**colors)) |
|
64 self.indexListModulesTemplate = ( |
|
65 TemplatesListsStyle.indexListModulesTemplate.format(**colors)) |
|
66 self.indexListEntryTemplate = ( |
|
67 TemplatesListsStyle.indexListEntryTemplate.format(**colors)) |
|
68 |
51 |
69 def remember(self, file, moduleDocument, basename=""): |
52 def remember(self, file, moduleDocument, basename=""): |
70 """ |
53 """ |
71 Public method to remember a documentation file. |
54 Public method to remember a documentation file. |
72 |
55 |
168 "Entries": "".join(lst), |
151 "Entries": "".join(lst), |
169 }) |
152 }) |
170 |
153 |
171 doc = ( |
154 doc = ( |
172 self.headerTemplate.format( |
155 self.headerTemplate.format( |
173 **{"Title": title, |
156 **{"Title": title} |
174 "Style": self.stylesheet} |
|
175 ) + self.indexBodyTemplate.format( |
157 ) + self.indexBodyTemplate.format( |
176 **{"Title": title, |
158 **{"Title": title, |
177 "Description": package["description"], |
159 "Description": package["description"], |
178 "Subpackages": subpackages, |
160 "Subpackages": subpackages, |
179 "Modules": modules} |
161 "Modules": modules} |