DocumentationTools/QtHelpGenerator.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2677
3d4277929fb3
parent 2989
7efa8b8b6903
child 3060
5883ce99ee12
--- a/DocumentationTools/QtHelpGenerator.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/DocumentationTools/QtHelpGenerator.py	Fri Oct 18 23:00:41 2013 +0200
@@ -4,7 +4,8 @@
 #
 
 """
-Module implementing the QtHelp generator for the builtin documentation generator.
+Module implementing the QtHelp generator for the builtin documentation
+generator.
 """
 
 from __future__ import unicode_literals    # __IGNORE_WARNING__
@@ -56,11 +57,12 @@
 
 class QtHelpGenerator(object):
     """
-    Class implementing the QtHelp generator for the builtin documentation generator.
+    Class implementing the QtHelp generator for the builtin documentation
+    generator.
     """
     def __init__(self, htmlDir,
-                 outputDir, namespace, virtualFolder, filterName, filterAttributes,
-                 title, createCollection):
+                 outputDir, namespace, virtualFolder, filterName,
+                 filterAttributes, title, createCollection):
         """
         Constructor
         
@@ -69,17 +71,19 @@
         @param namespace namespace to be used (string)
         @param virtualFolder virtual folder to be used (string)
         @param filterName name of the custom filter (string)
-        @param filterAttributes ':' separated list of filter attributes (string)
+        @param filterAttributes ':' separated list of filter attributes
+            (string)
         @param title title to be used for the generated help (string)
-        @param createCollection flag indicating the generation of the collection
-            files (boolean)
+        @param createCollection flag indicating the generation of the
+            collection files (boolean)
         """
         self.htmlDir = htmlDir
         self.outputDir = outputDir
         self.namespace = namespace
         self.virtualFolder = virtualFolder
         self.filterName = filterName
-        self.filterAttributes = filterAttributes and filterAttributes.split(':') or []
+        self.filterAttributes = \
+            filterAttributes and filterAttributes.split(':') or []
         self.relPath = relpath(self.htmlDir, self.outputDir)
         self.title = title
         self.createCollection = createCollection
@@ -143,8 +147,9 @@
         elt["modules"][moduleDocument.name()] = moduleDocument.name()
         
         if "__init__" not in file:
-            kwEntry = ("{0} (Module)".format(moduleDocument.name().split('.')[-1]),
-                       joinext(moduleDocument.name(), ".html"))
+            kwEntry = (
+                "{0} (Module)".format(moduleDocument.name().split('.')[-1]),
+                joinext(moduleDocument.name(), ".html"))
             if kwEntry not in self.keywords:
                 self.keywords.append(kwEntry)
         for kw in moduleDocument.getQtHelpKeywords():
@@ -215,13 +220,16 @@
                 basename = "{0}.".format(basename)
         
         sections = self.__generateSections("00index", 3)
-        filesList = sorted([e for e in os.listdir(self.htmlDir) if e.endswith('.html')])
-        files = "\n".join(["      <file>{0}</file>".format(f) for f in filesList])
-        filterAttribs = "\n".join(["    <filterAttribute>{0}</filterAttribute>".format(a) \
-                                  for a in sorted(self.filterAttributes)])
+        filesList = sorted(
+            [e for e in os.listdir(self.htmlDir) if e.endswith('.html')])
+        files = "\n".join(
+            ["      <file>{0}</file>".format(f) for f in filesList])
+        filterAttribs = "\n".join(
+            ["    <filterAttribute>{0}</filterAttribute>".format(a)
+             for a in sorted(self.filterAttributes)])
         keywords = "\n".join(
             ['      <keyword name="{0}" id="{1}" ref="{2}" />'.format(
-             html_encode(kw[0]), html_encode(kw[0]), html_encode(kw[1])) \
+             html_encode(kw[0]), html_encode(kw[0]), html_encode(kw[1]))
              for kw in sorted(self.keywords)])
         
         helpAttribs = {
@@ -241,12 +249,14 @@
         f.close()
         
         if self.createCollection and \
-           not os.path.exists(os.path.join(self.outputDir, HelpCollectionProjectFile)):
+           not os.path.exists(
+                os.path.join(self.outputDir, HelpCollectionProjectFile)):
             collectionAttribs = {
                 "helpfile": HelpHelpFile,
             }
             
-            txt = self.__convertEol(HelpCollection.format(**collectionAttribs), newline)
+            txt = self.__convertEol(
+                HelpCollection.format(**collectionAttribs), newline)
             f = open(os.path.join(self.outputDir, HelpCollectionProjectFile),
                      "w", encoding="utf-8", newline=newline)
             f.write(txt)
@@ -259,10 +269,12 @@
         
         cwd = os.getcwd()
         # generate the compressed files
-        shutil.copy(os.path.join(self.outputDir, HelpProjectFile), self.htmlDir)
+        shutil.copy(
+            os.path.join(self.outputDir, HelpProjectFile), self.htmlDir)
         os.chdir(self.htmlDir)
-        subprocess.call([os.path.join(getQtBinariesPath(), "qhelpgenerator"),
-                         "source.qhp", "-o", os.path.join(self.outputDir, HelpHelpFile)])
+        subprocess.call([
+            os.path.join(getQtBinariesPath(), "qhelpgenerator"),
+            "source.qhp", "-o", os.path.join(self.outputDir, HelpHelpFile)])
         os.remove(HelpProjectFile)
         
         if self.createCollection:
@@ -270,7 +282,8 @@
             sys.stdout.flush()
             sys.stderr.flush()
             os.chdir(self.outputDir)
-            subprocess.call([os.path.join(getQtBinariesPath(), "qcollectiongenerator"),
-                             "source.qhcp", "-o", "collection.qhc"])
+            subprocess.call([
+                os.path.join(getQtBinariesPath(), "qcollectiongenerator"),
+                "source.qhcp", "-o", "collection.qhc"])
         
         os.chdir(cwd)

eric ide

mercurial