[Python-checkins] CVS: python/nondist/sandbox/help htmldoc.py,1.3,1.4
Ka-Ping Yee
python-dev@python.org
Sun, 14 Jan 2001 13:48:26 -0800
Update of /cvsroot/python/python/nondist/sandbox/help
In directory usw-pr-cvs1:/tmp/cvs-serv16861
Modified Files:
htmldoc.py
Log Message:
Show packages in index.
Index: htmldoc.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/help/htmldoc.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** htmldoc.py 2001/01/14 11:49:50 1.3
--- htmldoc.py 2001/01/14 21:48:24 1.4
***************
*** 107,110 ****
--- 107,121 ----
return name
+ def modpkglink((name, ispackage, path)):
+ if path:
+ url = '%s.%s.html' % (path, name)
+ else:
+ url = '%s.html' % name
+ if ispackage:
+ text = '<strong>%s</strong> (package)' % name
+ else:
+ text = name
+ return '<a href="%s">%s</a>' % (url, text)
+
def modulelink(object):
return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
***************
*** 214,219 ****
else: doc = '<p><small><em>no doc string</em></small>\n'
results.append(doc)
! if modules:
contents = multicolumn(modules, modulelink)
results.append(section('<big><strong>Modules</strong></big>',
--- 225,252 ----
else: doc = '<p><small><em>no doc string</em></small>\n'
results.append(doc)
+
+ if hasattr(object, '__path__'):
+ modpkgs = []
+ modnames = []
+ for file in os.listdir(object.__path__[0]):
+ if file[:1] != '_':
+ path = os.path.join(object.__path__[0], file)
+ if file[-3:] == '.py' and file[:-3] not in modnames:
+ modpkgs.append((file[:-3], 0, name))
+ modnames.append(file[:-3])
+ elif file[-4:] == '.pyc' and file[:-4] not in modnames:
+ modpkgs.append((file[:-4], 0, name))
+ modnames.append(file[:-4])
+ elif os.path.isdir(path):
+ init = os.path.join(path, '__init__.py')
+ initc = os.path.join(path, '__init__.pyc')
+ if os.path.isfile(init) or os.path.isfile(initc):
+ modpkgs.append((file, 1, name))
+ modpkgs.sort()
+ contents = multicolumn(modpkgs, modpkglink)
+ results.append(section('<big><strong>Package Contents</strong></big>',
+ '#ffffff', '#aa55cc', contents))
! elif modules:
contents = multicolumn(modules, modulelink)
results.append(section('<big><strong>Modules</strong></big>',
***************
*** 319,341 ****
def index(dir):
! modules = []
! packages = []
for file in os.listdir(dir):
! path = dir + '/' + file
! if os.path.isfile(path):
! if file[-3:] == '.py':
! modules.append(file[:-3])
! elif file[-11:] == 'module.so':
! modules.append(file[:-11])
! elif file[-13:] == 'module.so.1':
! modules.append(file[:-13])
! elif os.path.isdir(path):
! if os.path.exists(path + '/__init__.py'):
! packages.append(file)
!
! def modulelink(name):
! return '<a href="%s.html">%s</a>' % (name, name)
! modules.sort()
! contents = multicolumn(modules, modulelink)
results = section('<big><strong>%s</strong></big>' % dir,
'#ffffff', '#ee77aa', contents)
--- 352,379 ----
def index(dir):
! modpkgs = []
! modnames = []
for file in os.listdir(dir):
! if file[:1] != '_':
! path = os.path.join(dir, file)
! if os.path.isfile(path):
! if file[-3:] == '.py' and file[:-3] not in modnames:
! modpkgs.append((file[:-3], 0, ''))
! modnames.append(file[:-3])
! elif file[-4:] == '.pyc' and file[:-4] not in modnames:
! modpkgs.append((file[:-4], 0, ''))
! modnames.append(file[:-4])
! elif file[-11:] == 'module.so':
! modpkgs.append((file[:-11], 0, ''))
! elif file[-13:] == 'module.so.1':
! modpkgs.append((file[:-13], 0, ''))
! elif os.path.isdir(path):
! init = os.path.join(path, '__init__.py')
! initc = os.path.join(path, '__init__.pyc')
! if os.path.isfile(init) or os.path.isfile(initc):
! modpkgs.append((file, 1, ''))
!
! modpkgs.sort()
! contents = multicolumn(modpkgs, modpkglink)
results = section('<big><strong>%s</strong></big>' % dir,
'#ffffff', '#ee77aa', contents)
***************
*** 348,358 ****
if os.path.isdir(arg):
for file in os.listdir(arg):
! if file[-3:] == '.py':
modnames.append(file[:-3])
elif file[-9:] == 'module.so':
modnames.append(file[:-9])
else:
! if arg[-3:] == '.py':
modnames.append(arg[:-3])
else:
modnames.append(arg)
--- 386,400 ----
if os.path.isdir(arg):
for file in os.listdir(arg):
! if file[-3:] == '.py' and file[:-3] not in modnames:
modnames.append(file[:-3])
+ elif file[-4:] == '.pyc' and file[:-4] not in modnames:
+ modnames.append(file[:-4])
elif file[-9:] == 'module.so':
modnames.append(file[:-9])
else:
! if arg[-3:] == '.py' and file[:-3] not in modnames:
modnames.append(arg[:-3])
+ elif arg[-4:] == '.pyc' and file[:-4] not in modnames:
+ modnames.append(arg[:-4])
else:
modnames.append(arg)