mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Wordwrap the text used for docstrings.
Put the signatures for the ctors before the text, just like the other functions, methods. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71694 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -78,6 +78,16 @@ def nci(text, numSpaces=0, stripLeading=True):
|
||||
newText = '\n'.join(lines) + '\n'
|
||||
return newText
|
||||
|
||||
|
||||
def wrapText(text):
|
||||
import textwrap
|
||||
lines = []
|
||||
tw = textwrap.TextWrapper(width=70, break_long_words=False)
|
||||
for line in text.split('\n'):
|
||||
lines.append(tw.fill(line))
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# io.StringIO reads/writes unicode objects for both Python 2.7 and 3.x. For
|
||||
|
||||
@@ -15,7 +15,7 @@ objects produced by the ETG scripts.
|
||||
import sys, os, re
|
||||
import etgtools.extractors as extractors
|
||||
import etgtools.generators as generators
|
||||
from etgtools.generators import nci, Utf8EncodingStream, textfile_open
|
||||
from etgtools.generators import nci, Utf8EncodingStream, textfile_open, wrapText
|
||||
|
||||
|
||||
divider = '//' + '-'*75 + '\n'
|
||||
@@ -545,23 +545,38 @@ from .%s import *
|
||||
|
||||
# get the docstring text
|
||||
text = nci(extractors.flattenNode(item.briefDoc, False))
|
||||
text = wrapText(text)
|
||||
|
||||
|
||||
#if isinstance(item, extractors.ClassDef):
|
||||
# # append the function signatures for the class constructors (if any) to the class' docstring
|
||||
# try:
|
||||
# ctor = item.find(item.name)
|
||||
# sigs = ctor.collectPySignatures()
|
||||
# if sigs:
|
||||
# text += '\n' + '\n'.join(sigs)
|
||||
# except extractors.ExtractorError:
|
||||
# pass
|
||||
#else:
|
||||
# # Prepend function signature string(s) for functions and methods
|
||||
# sigs = item.collectPySignatures()
|
||||
# if sigs:
|
||||
# if text:
|
||||
# text = '\n\n' + text
|
||||
# text = '\n'.join(sigs) + text
|
||||
|
||||
if isinstance(item, extractors.ClassDef):
|
||||
# append the function signatures for the class constructors (if any) to the class' docstring
|
||||
try:
|
||||
ctor = item.find(item.name)
|
||||
sigs = ctor.collectPySignatures()
|
||||
if sigs:
|
||||
text += '\n' + '\n'.join(sigs)
|
||||
except extractors.ExtractorError:
|
||||
pass
|
||||
else:
|
||||
# Prepend function signature string(s) for functions and methods
|
||||
sigs = item.collectPySignatures()
|
||||
if sigs:
|
||||
if text:
|
||||
text = '\n\n' + text
|
||||
text = '\n'.join(sigs) + text
|
||||
if sigs:
|
||||
if text:
|
||||
text = '\n\n' + text
|
||||
text = '\n'.join(sigs) + text
|
||||
|
||||
# write the docstring directive and the text
|
||||
stream.write('%s%%Docstring\n' % indent)
|
||||
|
||||
Reference in New Issue
Block a user