Update of /cvsroot/pywin32/pywin32/AutoDuck
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv3249
Modified Files:
Tag: py3k
BuildHHP.py Dump2HHC.py InsertExternalOverviews.py
makedfromi.py py2d.py pyhtml.fmt pywin32.mak
Log Message:
correct previous checkin and merge trunk autoduck changes
Index: pywin32.mak
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/pywin32.mak,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -C2 -d -r1.20 -r1.20.2.1
*** pywin32.mak 24 May 2008 08:17:54 -0000 1.20
--- pywin32.mak 28 Jan 2009 11:16:51 -0000 1.20.2.1
***************
*** 96,100 ****
$(ISAPI_SOURCE_DIR)\*.cpp $(ISAPI_SOURCE_DIR)\*.h $(GENDIR)\isapi_modules.d
! GENERATED_D = $(GENDIR)\sspi.d
SOURCE=$(WIN32_SOURCE) $(WIN32COM_SOURCE) $(PYTHONWIN_SOURCE) $(ISAPI_SOURCE) $(GENERATED_D)
--- 96,100 ----
$(ISAPI_SOURCE_DIR)\*.cpp $(ISAPI_SOURCE_DIR)\*.h $(GENDIR)\isapi_modules.d
! GENERATED_D = $(GENDIR)\sspi.d $(GENDIR)\win32timezone.d
SOURCE=$(WIN32_SOURCE) $(WIN32COM_SOURCE) $(PYTHONWIN_SOURCE) $(ISAPI_SOURCE) $(GENERATED_D)
***************
*** 121,124 ****
--- 121,127 ----
$(PYTHON) py2d.py sspi > $(GENDIR)\sspi.d
+ $(GENDIR)\win32timezone.d: py2d.py pseudo
+ $(PYTHON) py2d.py win32timezone > $(GENDIR)\win32timezone.d
+
"$(GENDIR)\$(TARGET).hhc" : $(SOURCE) Dump2HHC.py $(DOCUMENT_FILE)
rem Run autoduck over each category so we can create a nested TOC.
Index: py2d.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/py2d.py,v
retrieving revision 1.1.4.1
retrieving revision 1.1.4.2
diff -C2 -d -r1.1.4.1 -r1.1.4.2
*** py2d.py 26 Nov 2008 09:03:28 -0000 1.1.4.1
--- py2d.py 28 Jan 2009 11:16:51 -0000 1.1.4.2
***************
*** 1,4 ****
--- 1,8 ----
import sys
import types
+ import re
+
+ def ad_escape(s):
+ return re.sub(r"([^<]*)<([^>]*)>", r"\g<1>\\<\g<2>\\>", s)
class DocInfo:
***************
*** 19,23 ****
info.default = ""
if len(defs):
! info.default = defs.pop()
ret.append(info)
ret.reverse()
--- 23,30 ----
info.default = ""
if len(defs):
! default = repr(defs.pop())
! # the default may be an object, so the repr gives '<...>' - and
! # the angle brackets screw autoduck.
! info.default = default.replace("<", "").replace(">", "")
ret.append(info)
ret.reverse()
***************
*** 32,45 ****
return ret
def format_desc(desc):
if not desc:
return ""
! lines = desc.splitlines()
! chunks = [lines[0]]
! for line in lines[1:]:
! line = line.strip()
! if not line:
! line = "<nl>"
! chunks.append( "// " + line )
return "\n".join(chunks)
--- 39,85 ----
return ret
+ def should_build_function(build_info):
+ return build_info.ob.__doc__ and not build_info.ob.__name__.startswith('_')
+
+ # docstring aware paragraph generator. Isn't there something in docutils
+ # we can use?
+ def gen_paras(val):
+ chunks = []
+ in_docstring = False
+ for line in val.splitlines():
+ line = ad_escape(line.strip())
+ if not line or (not in_docstring and line.startswith(">>> ")):
+ if chunks:
+ yield chunks
+ chunks = []
+ if not line:
+ in_docstring = False
+ continue
+ in_docstring = True
+ chunks.append(line)
+ yield chunks or ['']
+
def format_desc(desc):
+ # A little complicated! Given the docstring for a module, we want to:
+ # write:
+ # 'first_para_of_docstring'
+ # '@comm next para of docstring'
+ # '@comm next para of docstring' ... etc
+ # BUT - also handling enbedded doctests, where we write
+ # '@iex >>> etc.'
if not desc:
return ""
! g = gen_paras(desc)
! first = next(g)
! chunks = [first[0]]
! chunks.extend(["// " + l for l in first[1:]])
! for lines in g:
! first = lines[0]
! if first.startswith(">>> "):
! prefix = "// @iex \n// "
! else:
! prefix = "\n// @comm "
! chunks.append(prefix + first)
! chunks.extend(["// " + l for l in lines[1:]])
return "\n".join(chunks)
***************
*** 50,59 ****
classes = []
constants = []
! for name, ob in mod.__dict__.items():
if name.startswith("_"):
continue
if hasattr(ob, "__module__") and ob.__module__ != mod_name:
continue
! if type(ob)==types.ClassType:
classes.append(BuildInfo(name, ob))
elif type(ob)==types.FunctionType:
--- 90,99 ----
classes = []
constants = []
! for name, ob in list(mod.__dict__.items()):
if name.startswith("_"):
continue
if hasattr(ob, "__module__") and ob.__module__ != mod_name:
continue
! if type(ob) in [type, type]:
classes.append(BuildInfo(name, ob))
elif type(ob)==types.FunctionType:
***************
*** 63,68 ****
--- 103,115 ----
info = BuildInfo(mod_name, mod)
print("// @module %s|%s" % (mod_name, format_desc(info.desc)), file=fp)
+ functions = [f for f in functions if should_build_function(f)]
for ob in functions:
print("// @pymeth %s|%s" % (ob.name, ob.short_desc), file=fp)
+ for ob in classes:
+ # only classes with docstrings get printed.
+ if not ob.ob.__doc__:
+ continue
+ ob_name = mod_name + "." + ob.name
+ print("// @pyclass %s|%s" % (ob.name, ob.short_desc), file=fp)
for ob in functions:
print("// @pymethod |%s|%s|%s" % (mod_name, ob.name, format_desc(ob.desc)), file=fp)
***************
*** 71,85 ****
for ob in classes:
ob_name = mod_name + "." + ob.name
print("// @object %s|%s" % (ob_name, format_desc(ob.desc)), file=fp)
func_infos = []
! for n, o in ob.ob.__dict__.items():
! if type(o)==types.FunctionType:
info = BuildInfo(n, o)
! func_infos.append(info)
for fi in func_infos:
print("// @pymeth %s|%s" % (fi.name, fi.short_desc), file=fp)
for fi in func_infos:
print("// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc)), file=fp)
for ai in BuildArgInfos(fi.ob):
print("// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc), file=fp)
--- 118,142 ----
for ob in classes:
+ # only classes with docstrings get printed.
+ if not ob.ob.__doc__:
+ continue
ob_name = mod_name + "." + ob.name
print("// @object %s|%s" % (ob_name, format_desc(ob.desc)), file=fp)
func_infos = []
! # We need to iter the keys then to a getattr() so the funky descriptor
! # things work.
! for n in ob.ob.__dict__.keys():
! o = getattr(ob.ob, n)
! if isinstance(o, (types.FunctionType, types.MethodType)):
info = BuildInfo(n, o)
! if should_build_function(info):
! func_infos.append(info)
for fi in func_infos:
print("// @pymeth %s|%s" % (fi.name, fi.short_desc), file=fp)
for fi in func_infos:
print("// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc)), file=fp)
+ if hasattr(fi.ob, 'im_self') and fi.ob.im_self is ob.ob:
+ print("// @comm This is a @classmethod.", file=fp)
+ print("// @pymethod |%s|%s|%s" % (ob_name, fi.name, format_desc(fi.desc)), file=fp)
for ai in BuildArgInfos(fi.ob):
print("// @pyparm |%s|%s|%s" % (ai.name, ai.default, ai.short_desc), file=fp)
***************
*** 87,91 ****
for (name, val) in constants:
desc = "%s = %r" % (name, val)
! if type(val) in (int, long):
desc += " (0x%x)" % (val,)
print("// @const %s|%s|%s" % (mod_name, name, desc), file=fp)
--- 144,148 ----
for (name, val) in constants:
desc = "%s = %r" % (name, val)
! if type(val) in (int, int):
desc += " (0x%x)" % (val,)
print("// @const %s|%s|%s" % (mod_name, name, desc), file=fp)
Index: makedfromi.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/makedfromi.py,v
retrieving revision 1.8.4.2
retrieving revision 1.8.4.3
diff -C2 -d -r1.8.4.2 -r1.8.4.3
*** makedfromi.py 28 Jan 2009 11:12:57 -0000 1.8.4.2
--- makedfromi.py 28 Jan 2009 11:16:51 -0000 1.8.4.3
***************
*** 80,84 ****
extra_tags.append("// " + doc + '\n')
except:
! print "Line %d is badly formed - %s" % (lineNo, str(sys.exc_value))
lineNo = lineNo + 1
--- 80,84 ----
extra_tags.append("// " + doc + '\n')
except:
! print("Line %d is badly formed - %s" % (lineNo, str(sys.exc_value)))
lineNo = lineNo + 1
***************
*** 109,113 ****
fields = string.split(meth,'|')
if len(fields)<>3:
! print "**Error - %s does not have enough fields" % meth
else:
outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
--- 109,113 ----
fields = string.split(meth,'|')
if len(fields)<>3:
! print("**Error - %s does not have enough fields" % meth)
else:
outFile.write("// @pymethod %s|%s|%s|%s\n" % (fields[0],thisModName,fields[1], fields[2]))
***************
*** 143,149 ****
outName = a
msg = string.join(args)
! except getopt.error, msg:
! print msg
! print "Usage: %s [-o output_name] [-p com_parent] filename" % sys.argv[0]
return
--- 143,149 ----
outName = a
msg = string.join(args)
! except getopt.error as msg:
! print(msg)
! print("Usage: %s [-o output_name] [-p com_parent] filename" % sys.argv[0])
return
Index: Dump2HHC.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/Dump2HHC.py,v
retrieving revision 1.6.4.2
retrieving revision 1.6.4.3
diff -C2 -d -r1.6.4.2 -r1.6.4.3
*** Dump2HHC.py 28 Jan 2009 11:12:57 -0000 1.6.4.2
--- Dump2HHC.py 28 Jan 2009 11:16:51 -0000 1.6.4.3
***************
*** 143,147 ****
if d.has_key(top.name):
! print "Duplicate named %s detected: %s" % (top.type, top.name)
# Skip the property fields line for module/object
--- 143,147 ----
if d.has_key(top.name):
! print("Duplicate named %s detected: %s" % (top.type, top.name))
# Skip the property fields line for module/object
***************
*** 216,220 ****
def _genCategoryHTMLFromDict(dict, output):
! keys = dict.keys()
keys.sort()
for key in keys:
--- 216,220 ----
def _genCategoryHTMLFromDict(dict, output):
! keys = list(dict.keys())
keys.sort()
for key in keys:
***************
*** 255,259 ****
def _genItemsFromDict(dict, cat, output, target, do_children = 1):
CHM = "mk:@MSITStore:%s.chm::/" % target
! keys = dict.keys()
keys.sort()
for k in keys:
--- 255,259 ----
def _genItemsFromDict(dict, cat, output, target, do_children = 1):
CHM = "mk:@MSITStore:%s.chm::/" % target
! keys = list(dict.keys())
keys.sort()
for k in keys:
Index: pyhtml.fmt
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/pyhtml.fmt,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C2 -d -r1.12 -r1.12.2.1
*** pyhtml.fmt 4 May 2008 12:59:57 -0000 1.12
--- pyhtml.fmt 28 Jan 2009 11:16:51 -0000 1.12.2.1
***************
*** 260,263 ****
--- 260,270 ----
.post=$(deflist_e)
+ .tag=pyclass, html, 2, 2
+ .pre=$(rmh)Classes$(rmhe)$(par)$(deflist)
+ .format=$(term1)<A HREF="#module.1.#1.html">$1</A>$(line)
+ $(def1)$2 $(par)
+ .post=$(deflist_e)
+ .if=exists($module.1)
+
.tag=pymeth, html, 2, 2
.pre=$(rmh)Methods$(rmhe)$(par)$(deflist)
***************
*** 521,526 ****
.tag=iex, html, 1, 8, 1
! .format=$(ex)$1$(par)
! $(ex)$(par)
.post=$(exe)
--- 528,533 ----
.tag=iex, html, 1, 8, 1
! .pre=$(ex)
! .format=$1$(par)
.post=$(exe)
Index: BuildHHP.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/BuildHHP.py,v
retrieving revision 1.9.4.2
retrieving revision 1.9.4.3
diff -C2 -d -r1.9.4.2 -r1.9.4.3
*** BuildHHP.py 28 Jan 2009 11:12:57 -0000 1.9.4.2
--- BuildHHP.py 28 Jan 2009 11:16:51 -0000 1.9.4.3
***************
*** 40,44 ****
new = glob.glob(g)
if len(new)==0:
! print "The pattern '%s' yielded no files!" % (g,)
lFiles = lFiles + new
# lFiles is now the list of origin files.
--- 40,44 ----
new = glob.glob(g)
if len(new)==0:
! print("The pattern '%s' yielded no files!" % (g,))
lFiles = lFiles + new
# lFiles is now the list of origin files.
***************
*** 66,70 ****
# else we have a trailing slash - it means we _expect_ it to be a patch as-is.
assert os.path.isdir(sCommonPrefix) and sCommonPrefix[-1]=="\\", "commonprefix splitting aint gunna work!"
! print "sCommonPrefix=", sCommonPrefix
# Ok, now remove this common prefix from every file:
lRelativeFiles = []
--- 66,70 ----
# else we have a trailing slash - it means we _expect_ it to be a patch as-is.
assert os.path.isdir(sCommonPrefix) and sCommonPrefix[-1]=="\\", "commonprefix splitting aint gunna work!"
! print("sCommonPrefix=", sCommonPrefix)
# Ok, now remove this common prefix from every file:
lRelativeFiles = []
Index: InsertExternalOverviews.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/AutoDuck/InsertExternalOverviews.py,v
retrieving revision 1.2.4.2
retrieving revision 1.2.4.3
diff -C2 -d -r1.2.4.2 -r1.2.4.3
*** InsertExternalOverviews.py 28 Jan 2009 11:12:57 -0000 1.2.4.2
--- InsertExternalOverviews.py 28 Jan 2009 11:16:51 -0000 1.2.4.3
***************
*** 29,33 ****
for item in cat.overviewItems.items:
dict[item.name] = item.href
! keys = dict.keys()
keys.sort()
for k in keys:
--- 29,33 ----
for item in cat.overviewItems.items:
dict[item.name] = item.href
! keys = list(dict.keys())
keys.sort()
for k in keys:
***************
*** 45,49 ****
def main():
if len(sys.argv) != 2:
! print "Invalid args"
sys.exit(1)
file = sys.argv[1]
--- 45,49 ----
def main():
if len(sys.argv) != 2:
! print("Invalid args")
sys.exit(1)
file = sys.argv[1]
|