Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL
In directory sc8-pr-cvs1:/tmp/cvs-serv30486/happydoclib/docset/docset_TAL
Modified Files:
__init__.py
Log Message:
Fix output filename handling.
Add ability to specify the tempalte set and path.
Implement writeTOCFile().
Raise exceptions in the methods that still need to be implemented.
Index: __init__.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_TAL/__init__.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** __init__.py 26 Jan 2003 19:12:58 -0000 1.1
--- __init__.py 16 Mar 2003 16:27:44 -0000 1.2
***************
*** 55,58 ****
--- 55,59 ----
# Import system modules
#
+ import os
import sys
***************
*** 64,67 ****
--- 65,70 ----
from happydoclib.trace import trace
+ from happydoclib.docset.docset_TAL.templateset import TemplateSet
+
#
# Module
***************
*** 77,80 ****
--- 80,88 ----
"""
+ DEFAULT_TEMPLATE_SET = 'default'
+ DEFAULT_TEMPLATE_PATH = os.path.join(os.path.dirname(__file__),
+ 'templates',
+ )
+
def __init__(self, scanner,
title,
***************
*** 105,111 ****
--- 113,168 ----
extraParameters=extraParameters,
)
+
+ self.template_name = extraParameters.get('template_name',
+ self.DEFAULT_TEMPLATE_SET)
+
+ self.template_path = extraParameters.get('template_path',
+ self.DEFAULT_TEMPLATE_PATH)
+
+ self.template_set = TemplateSet(os.path.join(self.template_path,
+ self.template_name)
+ )
+
trace.outof(outputLevel=TRACE_LEVEL)
return
+
+ def getOutputFilenameForPackageTreeNode(self, packageTreeNode, includePath=1):
+ """Returns a filename where documentation for packageTreeNode should be written.
+
+ The filename will be in the output directory, possibly in a
+ subdirectory based on the path from the input root to the
+ input file.
+
+ For example::
+
+ input_directory : /foo/input
+ containing : /foo/input/bar.py
+ output_directory : /foo/output
+
+ results in : /foo/output/input/bar.py
+ """
+ trace.into('TALDocset', 'getOutputFilenameForPackageTreeNode',
+ outputLevel=TRACE_LEVEL)
+ filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode(
+ self,
+ packageTreeNode,
+ includePath=includePath,
+ )
+
+ if packageTreeNode.getMimeType() == ('application/x-directory', None):
+ #
+ # This is a directory.
+ #
+ filename_with_extension = os.path.join(filename, 'index.html')
+ else:
+ #
+ # This is not a directory (file, module, class, etc.).
+ #
+ filename_with_extension = '%s.html' % filename
+
+ trace.outof(filename_with_extension, outputLevel=TRACE_LEVEL)
+ return filename_with_extension
+
def _initializeWriters(self):
"""Hook to allow subclasses to register writers without having to
***************
*** 115,118 ****
--- 172,187 ----
return
+ def renderTemplateToFile(self, template, outputFilename,
+ packageTreeNode,
+ **extraContext):
+
+ rendered_text = template.render(extraContext)
+
+ output = self.openOutput(outputFilename, packageTreeNode)
+ output.write(rendered_text)
+ output.close()
+
+ return
+
def writeTOCFile(self, packageTreeNode):
"""Write the table of contents for a directory.
***************
*** 123,130 ****
for that directory should be written as appropriate.
"""
! self.statusMessage('writeTOCFile needs work')
return
! def writeFileHeader(self, output, packageTreeNode, title='', subtitle=''):
"""Does nothing.
"""
--- 192,218 ----
for that directory should be written as appropriate.
"""
! trace.into('TALDocset', 'writeTOCFile',
! packageTreeNode=packageTreeNode,
! outputLevel=TRACE_LEVEL,
! )
!
! output_filename = self.getOutputFilenameForPackageTreeNode(
! packageTreeNode)
!
! template = self.template_set['toc.pt']
!
! self.renderTemplateToFile(
! template,
! output_filename,
! packageTreeNode,
! title=self.title,
! subtitle=packageTreeNode.getRelativeFilename(),
! )
!
! trace.outof(outputLevel=TRACE_LEVEL)
return
! def writeFileHeader(self, output, packageTreeNode,
! title='', subtitle=''):
"""Does nothing.
"""
***************
*** 140,143 ****
--- 228,232 ----
"""
self.statusMessage('processPythonFile needs work')
+ raise NotImplementedError('processPythonFile')
return
***************
*** 150,153 ****
--- 239,243 ----
"""
self.statusMessage('processPlainTextFile needs work')
+ raise NotImplementedError('processPlainTextFile')
return
***************
*** 156,159 ****
--- 246,250 ----
"""
self.statusMessage('processPythonClass needs work')
+ raise NotImplementedError('processPythonClass')
return
|