Exemplo n.º 1
0
 def remember(self, file, moduleDocument, basename=""):
     """
     Public method to remember a documentation file.
     
     @param file The filename to be remembered. (string)
     @param moduleDocument The ModuleDocument object containing the
         information for the file.
     @param basename The basename of the file hierarchy to be documented.
         The basename is stripped off the filename if it starts with
         the basename.
     """
     self.remembered = True
     if basename:
         file = file.replace(basename, "")
     
     if "__init__" in file:
         dir = os.path.dirname(file)
         udir = os.path.dirname(dir)
         if udir:
             upackage = udir.replace(os.sep, ".")
             try:
                 elt = self.packages[upackage]
             except KeyError:
                 elt = self.packages["00index"]
         else:
             elt = self.packages["00index"]
         package = dir.replace(os.sep, ".")
         elt["subpackages"][package] = moduleDocument.name()
         
         self.packages[package] = {
             "subpackages": {},
             "modules": {}
         }
         
         kwEntry = ("{0} (Package)".format(package.split('.')[-1]),
                    joinext("index-{0}".format(package), ".html"))
         if kwEntry not in self.keywords:
             self.keywords.append(kwEntry)
         
         if moduleDocument.isEmpty():
             return
     
     package = os.path.dirname(file).replace(os.sep, ".")
     try:
         elt = self.packages[package]
     except KeyError:
         elt = self.packages["00index"]
     elt["modules"][moduleDocument.name()] = moduleDocument.name()
     
     if "__init__" not in file:
         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():
         kwEntry = (kw[0], "{0}{1}".format(
             joinext(moduleDocument.name(), ".html"), kw[1]))
         if kwEntry not in self.keywords:
             self.keywords.append(kwEntry)
Exemplo n.º 2
0
    def remember(self, file, moduleDocument, basename=""):
        """
        Public method to remember a documentation file.
        
        @param file The filename to be remembered. (string)
        @param moduleDocument The ModuleDocument object containing the
            information for the file.
        @param basename The basename of the file hierarchy to be documented.
            The basename is stripped off the filename if it starts with
            the basename.
        """
        self.remembered = True
        if basename:
            file = file.replace(basename, "")

        if "__init__" in file:
            dirName = os.path.dirname(file)
            udir = os.path.dirname(dirName)
            if udir:
                upackage = udir.replace(os.sep, ".")
                try:
                    elt = self.packages[upackage]
                except KeyError:
                    elt = self.packages["00index"]
            else:
                elt = self.packages["00index"]
            package = dirName.replace(os.sep, ".")
            elt["subpackages"][package] = moduleDocument.name()

            self.packages[package] = {"subpackages": {}, "modules": {}}

            kwEntry = ("{0} (Package)".format(package.split('.')[-1]),
                       joinext("index-{0}".format(package), ".html"))
            if kwEntry not in self.keywords:
                self.keywords.append(kwEntry)

            if moduleDocument.isEmpty():
                return

        package = os.path.dirname(file).replace(os.sep, ".")
        try:
            elt = self.packages[package]
        except KeyError:
            elt = self.packages["00index"]
        elt["modules"][moduleDocument.name()] = moduleDocument.name()

        if "__init__" not in file:
            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():
            kwEntry = (kw[0],
                       "{0}{1}".format(joinext(moduleDocument.name(), ".html"),
                                       kw[1]))
            if kwEntry not in self.keywords:
                self.keywords.append(kwEntry)
Exemplo n.º 3
0
 def __generateSections(self, package, level):
     """
     Private method to generate the sections part.
     
     @param package name of the package to process (string)
     @param level indentation level (integer)
     @return sections part (string)
     """
     indent = level * "  "
     indent1 = indent + "  "
     s = indent + '<section title="{0}" ref="{1}">\n'.format(
         package == "00index" and self.title or package,
         package == "00index" and joinext("index", ".html") or joinext("index-{0}".format(package), ".html"),
     )
     for subpack in sorted(self.packages[package]["subpackages"]):
         s += self.__generateSections(subpack, level + 1)
         s += "\n"
     for mod in sorted(self.packages[package]["modules"]):
         s += indent1 + '<section title="{0}" ref="{1}" />\n'.format(mod, joinext(mod, ".html"))
     s += indent + "</section>"
     return s
Exemplo n.º 4
0
 def __generateSections(self, package, level):
     """
     Private method to generate the sections part.
     
     @param package name of the package to process (string)
     @param level indentation level (integer)
     @return sections part (string)
     """
     indent = level * '  '
     indent1 = indent + '  '
     s = indent + '<section title="{0}" ref="{1}">\n'.format(
         package == "00index" and self.title or package,
         package == "00index" and joinext("index", ".html")
         or joinext("index-{0}".format(package), ".html"))
     for subpack in sorted(self.packages[package]["subpackages"]):
         s += self.__generateSections(subpack, level + 1)
         s += '\n'
     for mod in sorted(self.packages[package]["modules"]):
         s += indent1 + '<section title="{0}" ref="{1}" />\n'.format(
             mod, joinext(mod, ".html"))
     s += indent + '</section>'
     return s
 def __generateSections(self, package, level):
     """
     Private method to generate the sections part.
     
     @param package name of the package to process (string)
     @param level indentation level (integer)
     @return sections part (string)
     """
     indent = level * '  '
     indent1 = indent + '  '
     s  = indent + '<section title="%s" ref="%s">\n' % \
         (package == "00index" and self.title or package, 
          package == "00index" and \
             joinext("index", ".html") or \
             joinext("index-%s" % package, ".html"))
     for subpack in sorted(self.packages[package]["subpackages"]):
         s += self.__generateSections(subpack, level + 1)
     for mod in sorted(self.packages[package]["modules"]):
         s += indent1 + '<section title="%s" ref="%s" />\n' % \
             (mod, joinext(mod, ".html"))
     s += indent + '</section>\n'
     return s
Exemplo n.º 6
0
 def __writeIndex(self, packagename, package, newline=None):
     """
     Private method to generate an index file for a package.
     
     @param packagename The name of the package. (string)
     @param package A dictionary with information about the package.
     @param newline newline character to be used (string)
     @return The name of the generated index file.
     """
     if packagename == "00index":
         f = os.path.join(self.outputDir, "index")
         title = "Table of contents"
     else:
         f = os.path.join(self.outputDir, "index-{0}".format(packagename))
         title = packagename
     
     filename = joinext(f, ".html")
     
     subpackages = ""
     modules = ""
     
     # 1) subpackages
     if package["subpackages"]:
         subpacks = package["subpackages"]
         names = sorted(list(subpacks.keys()))
         lst = []
         for name in names:
             link = joinext("index-{0}".format(name), ".html")
             lst.append(self.indexListEntryTemplate.format(**{
                 "Description": subpacks[name],
                 "Name": name.split(".")[-1],
                 "Link": link,
             }))
         subpackages = self.indexListPackagesTemplate.format(**{
             "Entries": "".join(lst),
         })
         
     # 2) modules
     if package["modules"]:
         mods = package["modules"]
         names = sorted(list(mods.keys()))
         lst = []
         for name in names:
             link = joinext(name, ".html")
             nam = name.split(".")[-1]
             if nam == "__init__":
                 nam = name.split(".")[-2]
             lst.append(self.indexListEntryTemplate.format(**{
                 "Description": mods[name],
                 "Name": nam,
                 "Link": link,
             }))
         modules = self.indexListModulesTemplate.format(**{
             "Entries": "".join(lst),
         })
         
     doc = self.headerTemplate.format(
         **{"Title": title,
            "Style": self.stylesheet}) + \
         self.indexBodyTemplate.format(
             **{"Title": title,
                "Description": package["description"],
                "Subpackages": subpackages,
                "Modules": modules}) + \
         self.footerTemplate
 
     f = open(filename, "w", encoding="utf-8", newline=newline)
     f.write(doc)
     f.close()
 
     return filename
 def __writeIndex(self, packagename, package):
     """
     Private method to generate an index file for a package.
     
     @param packagename The name of the package. (string)
     @param package A dictionary with information about the package.
     @return The name of the generated index file.
     """
     if packagename == "00index":
         f = os.path.join(self.outputDir, "index")
         title = "Table of contents"
     else:
         f = os.path.join(self.outputDir, "index-%s" % packagename)
         title = packagename
     
     filename = joinext(f, ".html")
     
     subpackages = ""
     modules = ""
     
     # 1) subpackages
     if package["subpackages"]:
         subpacks = package["subpackages"]
         names = subpacks.keys()
         names.sort()
         lst = []
         for name in names:
             link = joinext("index-%s" % name, ".html")
             lst.append(self.indexListEntryTemplate % {
                 "Description" : subpacks[name],
                 "Name" : name.split(".")[-1],
                 "Link" : link,
             })
         subpackages = self.indexListPackagesTemplate % {
             "Entries" : "".join(lst),
         }
         
     # 2) modules
     if package["modules"]:
         mods = package["modules"]
         names = mods.keys()
         names.sort()
         lst = []
         for name in names:
             link = joinext(name, ".html")
             nam = name.split(".")[-1]
             if nam == "__init__":
                 nam = name.split(".")[-2]
             lst.append(self.indexListEntryTemplate % {
                 "Description" : mods[name],
                 "Name" : nam,
                 "Link" : link,
             })
         modules = self.indexListModulesTemplate % {
             "Entries" : "".join(lst),
         }
         
     doc = self.headerTemplate % { \
             "Title" : title,
             "Style" : self.stylesheet} + \
           self.indexBodyTemplate % { \
             "Title" : title,
             "Description" : package["description"],
             "Subpackages" : subpackages,
             "Modules" : modules,
           } + \
           self.footerTemplate
 
     f = open(filename, "wb")
     f.write(doc)
     f.close()
 
     return filename