Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv19632/happydoclib/docset
Modified Files:
docset_MultiHTMLFile.py
Log Message:
Added docstrings to a few existing methods.
Added first draft of code to generate the import statements when
documenting a module. There are still places where hrefs can be
inserted instead of just the name of the object, and the formatting
needs to be fixed up when all of that is done.
Index: docset_MultiHTMLFile.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/docset_MultiHTMLFile.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** docset_MultiHTMLFile.py 15 Dec 2002 17:02:26 -0000 1.9
--- docset_MultiHTMLFile.py 27 Dec 2002 18:37:05 -0000 1.10
***************
*** 63,66 ****
--- 63,67 ----
import happydoclib
from happydoclib.docset import base
+ from happydoclib.sysmodules import getPythonSystemModuleURL
from happydoclib.trace import trace
***************
*** 87,90 ****
--- 88,105 ----
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('MultiHTMLFileDocSet', 'getOutputFilenameForPackageTreeNode')
filename = base.MultiFileDocSet.getOutputFilenameForPackageTreeNode(
***************
*** 109,113 ****
def writeFileHeader(self, output, title='', subtitle=''):
!
title_bg = self.levelOneHeadingBackgroundColor
title_fg = self.levelOneHeadingForegroundColor
--- 124,129 ----
def writeFileHeader(self, output, title='', subtitle=''):
! """Given an open output stream, write a header using the title and subtitle.
! """
title_bg = self.levelOneHeadingBackgroundColor
title_fg = self.levelOneHeadingForegroundColor
***************
*** 147,151 ****
def writeFileFooter(self, output):
!
root = 'Need URL for root'
date_str = time.ctime(time.time())
--- 163,168 ----
def writeFileFooter(self, output):
! """Given an open output stream, write a footer using the title and subtitle.
! """
root = 'Need URL for root'
date_str = time.ctime(time.time())
***************
*** 172,175 ****
--- 189,203 ----
def _writeDescriptiveList(self, output, descriptiveList):
+ """Write a list including descriptions.
+
+ Arguments
+
+ output -- Open output stream.
+
+ descriptiveList -- Sequence of (name, description,
+ description_format) values to be included in the output
+ list.
+
+ """
output.write('<!-- _writeDescriptiveList -->\n')
output.write('<table border="0" cellpadding="3" cellspacing="0">\n')
***************
*** 192,195 ****
--- 220,225 ----
def _computeRelativeHREF(self, source, destination):
+ """Compute the HREF to point from the output file of source to destination.
+ """
relative_path = source.getPathToNode(destination)
if not relative_path:
***************
*** 207,219 ****
relative_path = relative_path[:-1] + (output_name,)
href = '/'.join(relative_path)
return href
! def _getAnchorTagForPackageTreeNode(self, source, destination):
href = self._computeRelativeHREF(source, destination)
! return '<a href="%s">%s</a>' % (href, destination.getName())
def _writeTOCReferencesSection(self, output, packageTreeNode, title, moduleList):
! descriptive_list = [ (self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat()
for name, node in moduleList ]
if descriptive_list:
--- 237,279 ----
relative_path = relative_path[:-1] + (output_name,)
+ #
+ # If the destination is a directory, add 'index.html' to the end.
+ #
+ #print destination.getName(), destination.getMimeType()
+ #if destination.getMimeType() == ('application/x-directory', None):
+ # print 'adding index.html'
+ # relative_path += ('index.html',)
+ # print relative_path
+
href = '/'.join(relative_path)
+ #print href
return href
! def _getAnchorTagForPackageTreeNode(self, source, destination, title=None):
! """Return a anchor tag to be included in the documentation of
! source that points to the destination.
! """
! if title is None:
! title = destination.getName()
href = self._computeRelativeHREF(source, destination)
! return '<a href="%s">%s</a>' % (href, title)
def _writeTOCReferencesSection(self, output, packageTreeNode, title, moduleList):
! """Write a list of references in the table of contents.
!
! Arguments
!
! output -- Open output stream on which to write.
!
! packageTreeNode -- The node for which the section is being
! written.
!
! title -- Title of the reference section.
!
! moduleList -- A list of nodes to be included in the
! reference section.
!
! """
! descriptive_list = [(self._getAnchorTagForPackageTreeNode(packageTreeNode, node), ) + node.getSummaryAndFormat()
for name, node in moduleList ]
if descriptive_list:
***************
*** 224,227 ****
--- 284,292 ----
def writeTOCFile(self, packageTreeNode):
+ """Write the table of contents for a directory.
+
+ The packageTreeNode is a directory, and the table of contents
+ for that directory should be written as appropriate.
+ """
trace.into('MultiHTMLFile', 'writeTOCFile',
packageTreeNode=packageTreeNode,
***************
*** 313,334 ****
return
! def _writePythonFileInfoToOutput(self, output, packageTreeNode):
! """Writes part of the Python file information to the output stream.
! """
! #
! # Imports
! #
#
! # Functions
#
! #
# Classes
- #
return
def writePythonFile(self, packageTreeNode):
trace.into('MultiHTMLFileDocSet', 'writePythonFile',
packageTreeNode=packageTreeNode,
--- 378,512 ----
return
! def _writeImportWithFrom(self, output, pacakgeTreeNode, moduleReference, symbolReferences):
! output.write('from %s import %s<br>' % (moduleReference,
! ', '.join(symbolReferences),
! )
! )
! return
!
! def _writeImport(self, output, packageTreeNode, moduleReference):
! output.write('import %s<br>' % moduleReference)
! return
!
! def _writeImportForPythonSystemModule(self, output, packageTreeNode, name, symbols, url):
! ref = '<a href="%s">%s</a>' % (url, name)
! if symbols:
! self._writeImportWithFrom(output,
! packageTreeNode,
! ref,
! symbols,
! )
! else:
! self._writeImport(output,
! packageTreeNode,
! ref,
! )
! return
+
+ def _writeImportForKnownModule(self, output, packageTreeNode, referencedModule, symbols):
#
! # Compute the href from here to there.
#
+ ref = self._getAnchorTagForPackageTreeNode(
+ packageTreeNode,
+ referencedModule,
+ )
! if symbols:
! symbol_refs = []
!
! for symbol in symbols:
! symbol_module = referencedModule.findNodeFromDottedName(symbol)
! if symbol_module is not None:
! symbol_ref = self._getAnchorTagForPackageTreeNode(
! packageTreeNode,
! symbol_module,
! title=symbol,
! )
! else:
! symbol_ref = symbol
!
! symbol_refs.append( symbol_ref )
!
! self._writeImportWithFrom(output,
! packageTreeNode,
! ref,
! symbol_refs,
! )
! else:
! self._writeImport(output,
! packageTreeNode,
! ref,
! )
! return
!
!
! def _writePythonFileImportsToOutput(self, output, packageTreeNode):
! """Writes the list of imported modules for the packageTreeNode.
! """
! import_data = packageTreeNode.module_info.getImportData()
! if import_data:
! output.write('<h4>Imported Modules</h4>\n')
! output.write('<p>\n')
!
! for name, symbols in import_data:
! ref = None
!
! #
! # Check if the name is a Python system module.
! #
! url = getPythonSystemModuleURL(name)
! if url:
! self._writeImportForPythonSystemModule(output,
! packageTreeNode,
! name,
! symbols,
! url,
! )
! continue
!
! #
! # Check to see if the name is another module we know about.
! #
! referenced_module = packageTreeNode.findNodeFromDottedName(name)
! if referenced_module:
! self._writeImportForKnownModule(output,
! packageTreeNode,
! referenced_module,
! symbols,
! )
! continue
!
! #
! # Default to the module name for the reference.
! #
! if symbols:
! self._writeImportWithFrom(output,
! packageTreeNode,
! name,
! symbols,
! )
! else:
! self._writeImport(output,
! packageTreeNode,
! name,
! )
!
! output.write('</p>\n')
! return
!
! def _writePythonFileInfoToOutput(self, output, packageTreeNode):
! """Writes parts of the Python file information to the output stream.
! """
! self._writePythonFileImportsToOutput(output, packageTreeNode)
! # Functions
# Classes
return
def writePythonFile(self, packageTreeNode):
+ """Handler for text/x-python nodes.
+ """
trace.into('MultiHTMLFileDocSet', 'writePythonFile',
packageTreeNode=packageTreeNode,
|