165 package == "00index" and \ |
165 package == "00index" and \ |
166 joinext("index", ".html") or \ |
166 joinext("index", ".html") or \ |
167 joinext("index-%s" % package, ".html")) |
167 joinext("index-%s" % package, ".html")) |
168 for subpack in sorted(self.packages[package]["subpackages"]): |
168 for subpack in sorted(self.packages[package]["subpackages"]): |
169 s += self.__generateSections(subpack, level + 1) |
169 s += self.__generateSections(subpack, level + 1) |
|
170 s += '\n' |
170 for mod in sorted(self.packages[package]["modules"]): |
171 for mod in sorted(self.packages[package]["modules"]): |
171 s += indent1 + '<section title="%s" ref="%s" />\n' % \ |
172 s += indent1 + '<section title="%s" ref="%s" />\n' % \ |
172 (mod, joinext(mod, ".html")) |
173 (mod, joinext(mod, ".html")) |
173 s += indent + '</section>\n' |
174 s += indent + '</section>' |
174 return s |
175 return s |
175 |
176 |
176 def generateFiles(self, basename = ""): |
177 def __convertEol(self, txt, newline): |
|
178 """ |
|
179 Private method to convert the newline characters. |
|
180 |
|
181 @param txt text to be converted (string) |
|
182 @param newline newline character to be used (string) |
|
183 @return converted text (string) |
|
184 """ |
|
185 # step 1: normalize eol to '\n' |
|
186 txt = txt.replace("\r\n", "\n").replace("\r", "\n") |
|
187 |
|
188 # step 2: convert to the target eol |
|
189 if newline is None: |
|
190 return txt.replace("\n", os.linesep) |
|
191 elif newline in ["\r", "\r\n"]: |
|
192 return txt.replace("\n", newline) |
|
193 else: |
|
194 return txt |
|
195 |
|
196 def generateFiles(self, basename = "", newline = None): |
177 """ |
197 """ |
178 Public method to generate all index files. |
198 Public method to generate all index files. |
179 |
199 |
180 @param basename The basename of the file hierarchy to be documented. |
200 @param basename The basename of the file hierarchy to be documented. |
181 The basename is stripped off the filename if it starts with |
201 The basename is stripped off the filename if it starts with |
182 the basename. |
202 the basename. |
|
203 @param newline newline character to be used (string) |
183 """ |
204 """ |
184 if not self.remembered: |
205 if not self.remembered: |
185 sys.stderr.write("No QtHelp to generate.\n") |
206 sys.stderr.write("No QtHelp to generate.\n") |
186 return |
207 return |
187 |
208 |
208 "sections" : sections, |
229 "sections" : sections, |
209 "keywords" : keywords, |
230 "keywords" : keywords, |
210 "files" : files, |
231 "files" : files, |
211 } |
232 } |
212 |
233 |
|
234 txt = self.__convertEol(HelpProject % helpAttribs, newline) |
213 f = codecs.open(os.path.join(self.outputDir, HelpProjectFile), 'w', 'utf-8') |
235 f = codecs.open(os.path.join(self.outputDir, HelpProjectFile), 'w', 'utf-8') |
214 f.write(HelpProject % helpAttribs) |
236 f.write(txt) |
215 f.close() |
237 f.close() |
216 |
238 |
217 if self.createCollection and \ |
239 if self.createCollection and \ |
218 not os.path.exists(os.path.join(self.outputDir, HelpCollectionProjectFile)): |
240 not os.path.exists(os.path.join(self.outputDir, HelpCollectionProjectFile)): |
219 collectionAttribs = { |
241 collectionAttribs = { |
220 "helpfile" : HelpHelpFile, |
242 "helpfile" : HelpHelpFile, |
221 } |
243 } |
222 |
244 |
|
245 txt = self.__convertEol(HelpCollection % collectionAttribs, newline) |
223 f = codecs.open(os.path.join(self.outputDir, HelpCollectionProjectFile), |
246 f = codecs.open(os.path.join(self.outputDir, HelpCollectionProjectFile), |
224 'w', 'utf-8') |
247 'w', 'utf-8') |
225 f.write(HelpCollection % collectionAttribs) |
248 f.write(txt) |
226 f.close() |
249 f.close() |
227 |
250 |
228 sys.stdout.write("QtHelp files written.\n") |
251 sys.stdout.write("QtHelp files written.\n") |
229 sys.stdout.write("Generating QtHelp documentation...\n") |
252 sys.stdout.write("Generating QtHelp documentation...\n") |
230 sys.stdout.flush() |
253 sys.stdout.flush() |