def test_htmlpage(self):
# html.page does not choke on unicode
with test.test_support.temp_cwd():
with captured_stdout() as output:
pydoc.writedoc(self.Q)
self.assertEqual(output.getvalue(), 'wrote Q.html\n')
python类writedoc()的实例源码
def test_htmlpage(self):
# html.page does not choke on unicode
with test.test_support.temp_cwd():
with captured_stdout() as output:
pydoc.writedoc(self.Q)
self.assertEqual(output.getvalue(), 'wrote Q.html\n')
def test_htmlpage(self):
# html.page does not choke on unicode
with test.test_support.temp_cwd():
with captured_stdout() as output:
pydoc.writedoc(self.Q)
self.assertEqual(output.getvalue(), 'wrote Q.html\n')
def createPyDocs(self, filename, dir):
"""Create an HTML module documentation using pydoc."""
import pydoc
package, module = os.path.split(filename)
module = os.path.splitext(module)[0]
if package:
module = package.replace('/', '.') + '.' + module
targetName = '%s/%s.html' % (dir, module)
self.printMsg('Creating %s...' % targetName)
saveDir = os.getcwd()
os.chdir(dir)
try:
stdout = sys.stdout
sys.stdout = StringIO()
try:
try:
pydoc.writedoc(module)
except Exception:
pass
msg = sys.stdout.getvalue()
finally:
sys.stdout = stdout
finally:
os.chdir(saveDir)
if msg:
self.printMsg(msg)