[library-web] [htmlfiles] make tarball_doc_elem attribute optional



commit 9ad26cf14e71a76ee8ab305e8c866392462eed8d
Author: Frédéric Péters <fpeters 0d be>
Date:   Sat Aug 8 17:44:56 2009 +0200

    [htmlfiles] make tarball_doc_elem attribute optional

 src/modtypes/htmlfiles.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/modtypes/htmlfiles.py b/src/modtypes/htmlfiles.py
index a356e5b..581ba5f 100644
--- a/src/modtypes/htmlfiles.py
+++ b/src/modtypes/htmlfiles.py
@@ -33,6 +33,8 @@ from base import DocModule
 class HtmlFilesModule(DocModule):
     '''Class for documentation shipped in a tarball as HTML files'''
     transform_mode = None
+    index_filename = None
+    tarball_doc_elem = None
 
     html2html_xsl_file = os.path.join(data_dir, 'xslt', 'html2html.xsl')
 
@@ -44,6 +46,8 @@ class HtmlFilesModule(DocModule):
         self.modulename = self.tarball_doc_elem.attrib.get('doc_module')
         if self.tarball_doc_elem.find('transform-mode') is not None:
             self.transform_mode = self.tarball_doc_elem.find('transform-mode').text
+        if self.tarball_doc_elem.find('index') is not None:
+            self.index_filename = self.tarball_doc_elem.find('index').text
         return self
     create_from_tar = classmethod(create_from_tar)
 
@@ -130,14 +134,15 @@ class HtmlFilesModule(DocModule):
         if not doc:
             return
 
-        doc.category = self.tarball_doc_elem.get('category')
-        doc.toc_id = doc.category
+        if self.tarball_doc_elem:
+            doc.category = self.tarball_doc_elem.get('category')
+            doc.toc_id = doc.category
 
-        if self.tarball_doc_elem.find('index') is not None:
+        if self.index_filename:
             path = os.path.join(web_output_dir, 'index.html')
             if os.path.islink(path):
                 os.unlink(path)
-            os.symlink(self.tarball_doc_elem.find('index').text, path)
+            os.symlink(self.index_filename, path)
 
         self.install_version_symlinks(doc)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]