[Happydoc-checkins] CVS: HappyDoc3/happydoclib/docset base.py,1.2,1.3
Brought to you by:
doughellmann,
krlosaqp
|
From: Doug H. <dou...@us...> - 2002-12-07 15:31:48
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib/docset
In directory sc8-pr-cvs1:/tmp/cvs-serv31740/happydoclib/docset
Modified Files:
base.py
Log Message:
Add mappings to handle images by copying them.
Add openOutput() and closeOutput().
Add writePlainTextFile().
Index: base.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/docset/base.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** base.py 1 Dec 2002 22:36:53 -0000 1.2
--- base.py 7 Dec 2002 15:31:45 -0000 1.3
***************
*** 62,65 ****
--- 62,66 ----
import happydoclib
from happydoclib.trace import trace
+ from happydoclib.docstring import getConverterFactoryForFile, getConverterFactory
#
***************
*** 173,187 ****
mimetype_writer_mapping = {
! 'text/x-python': 'writePythonFile',
! 'text/x-text': 'writePlainTextFile',
! 'text/x-structured': 'writePlainTextFile',
! 'text/html': 'copyInputFileToOutput',
}
mimetype_extension_mapping = {
! 'text/x-python': { 'remove_existing':1,},
! 'text/plain': { 'remove_existing':1,},
! 'text/x-structured': { 'remove_existing':1,},
! 'text/html': { 'remove_existing':1,},
}
--- 174,191 ----
mimetype_writer_mapping = {
! 'text/x-python' : 'writePythonFile',
! 'text/plain' : 'writePlainTextFile',
! 'text/x-structured' : 'writePlainTextFile',
! 'text/html' : 'copyInputFileToOutput',
! 'image/gif' : 'copyInputFileToOutput',
! 'image/jpeg' : 'copyInputFileToOutput',
! 'image/png' : 'copyInputFileToOutput',
}
mimetype_extension_mapping = {
! 'text/x-python' : { 'remove_existing':1,},
! 'text/plain' : { 'remove_existing':1,},
! 'text/x-structured' : { 'remove_existing':1,},
! 'text/html' : { 'remove_existing':1,},
}
***************
*** 332,335 ****
--- 336,381 ----
file.close()
+ trace.outof()
+ return
+
+ def openOutput(self, name, title=None, subtitle=None):
+ f = open(name, 'wt')
+ self.writeFileHeader(f, title=title, subtitle=subtitle)
+ return f
+
+ def closeOutput(self, output):
+ self.writeFileFooter(output)
+ output.close()
+ return
+
+ def writePlainTextFile(self, packageTreeNode):
+ trace.into('MultiFileDocSet', 'writePlainTextFile',
+ packageTreeNode=packageTreeNode,
+ )
+
+ canonical_path = packageTreeNode.getPath(1)
+ canonical_filename = apply(os.path.join, canonical_path)
+ output_filename = self.getOutputFilenameForPackageTreeNode(packageTreeNode)
+
+ self.statusMessage('Translating: "%s"\n to: "%s"' % (
+ canonical_filename,
+ output_filename,
+ ))
+
+ converter_factory = getConverterFactoryForFile(canonical_filename)
+ converter = converter_factory()
+
+ input_file = converter.getExternalDocumentationFile(canonical_filename)
+
+ raw_body = str(input_file)
+
+ cooked_body = converter.convert(raw_body, 'html', level=3)
+
+ output_file = self.openOutput(output_filename)
+
+ output_file.write(cooked_body)
+
+ self.closeOutput(output_file)
+
trace.outof()
return
|