[svn r41080] Added support for filtering listdir() calls in the SourcePageBuilder, using it
to filter out hidden files and the 'build' subdir of greenlet. --HG-- branch : trunk
This commit is contained in:
parent
e3715545fb
commit
417d97c850
|
@ -31,6 +31,11 @@ def get_documentable_items(pkgdir):
|
|||
Channel.__apigen_hide_from_nav__ = True
|
||||
return pkgname, pkgdict
|
||||
|
||||
def sourcedirfilter(p):
|
||||
return ('.svn' not in str(p).split(p.sep) and
|
||||
not p.basename.startswith('.') and
|
||||
str(p).find('c-extension%sgreenlet%sbuild' % (p.sep, p.sep)) == -1)
|
||||
|
||||
def build(pkgdir, dsa, capture):
|
||||
# create a linker (link database) for cross-linking
|
||||
l = linker.TempLinker()
|
||||
|
@ -51,7 +56,7 @@ def build(pkgdir, dsa, capture):
|
|||
apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree,
|
||||
proj, capture, LayoutPage)
|
||||
spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir, proj, capture,
|
||||
LayoutPage)
|
||||
LayoutPage, dirfilter=sourcedirfilter)
|
||||
|
||||
apb.build_namespace_pages()
|
||||
class_names = dsa.get_class_names()
|
||||
|
|
|
@ -81,7 +81,7 @@ def get_param_htmldesc(linker, func):
|
|||
return inspect.formatargspec(*inspect.getargspec(func))
|
||||
|
||||
# some helper functionality
|
||||
def source_dirs_files(fspath):
|
||||
def source_dirs_files(fspath, fil=None):
|
||||
""" returns a tuple (dirs, files) for fspath
|
||||
|
||||
dirs are all the subdirs, files are the files which are interesting
|
||||
|
@ -93,7 +93,7 @@ def source_dirs_files(fspath):
|
|||
"""
|
||||
dirs = []
|
||||
files = []
|
||||
for child in fspath.listdir():
|
||||
for child in fspath.listdir(fil=fil):
|
||||
if child.basename.startswith('.'):
|
||||
continue
|
||||
if child.check(dir=True):
|
||||
|
@ -203,13 +203,14 @@ class AbstractPageBuilder(object):
|
|||
class SourcePageBuilder(AbstractPageBuilder):
|
||||
""" builds the html for a source docs page """
|
||||
def __init__(self, base, linker, projroot, project, capture=None,
|
||||
pageclass=LayoutPage):
|
||||
pageclass=LayoutPage, dirfilter=None):
|
||||
self.base = base
|
||||
self.linker = linker
|
||||
self.projroot = projroot
|
||||
self.project = project
|
||||
self.capture = capture
|
||||
self.pageclass = pageclass
|
||||
self.dirfilter = dirfilter
|
||||
|
||||
def build_navigation(self, fspath):
|
||||
nav = H.Navigation(class_='sidebar')
|
||||
|
@ -240,7 +241,7 @@ class SourcePageBuilder(AbstractPageBuilder):
|
|||
else:
|
||||
# we're a file, build our parent's children only
|
||||
dirpath = fspath.dirpath()
|
||||
diritems, fileitems = source_dirs_files(dirpath)
|
||||
diritems, fileitems = source_dirs_files(dirpath, self.dirfilter)
|
||||
for dir in diritems:
|
||||
nav.append(H.NavigationItem(self.linker, dir.strpath, dir.basename,
|
||||
indent, False))
|
||||
|
@ -265,7 +266,7 @@ class SourcePageBuilder(AbstractPageBuilder):
|
|||
return tag, nav
|
||||
|
||||
def build_dir_page(self, fspath):
|
||||
dirs, files = source_dirs_files(fspath)
|
||||
dirs, files = source_dirs_files(fspath, self.dirfilter)
|
||||
dirs = [(p.basename, self.linker.get_lazyhref(str(p))) for p in dirs]
|
||||
files = [(p.basename, self.linker.get_lazyhref(str(p))) for p in files]
|
||||
tag = H.DirList(dirs, files)
|
||||
|
@ -281,7 +282,15 @@ class SourcePageBuilder(AbstractPageBuilder):
|
|||
return tag, nav
|
||||
|
||||
def build_pages(self, base):
|
||||
for fspath in [base] + list(base.visit()):
|
||||
def visit(p):
|
||||
dirs, files = source_dirs_files(p, self.dirfilter)
|
||||
for d in dirs:
|
||||
yield d
|
||||
for sp in visit(d):
|
||||
yield sp
|
||||
for f in files:
|
||||
yield f
|
||||
for fspath in [base] + list(visit(base)):
|
||||
if fspath.ext in ['.pyc', '.pyo']:
|
||||
continue
|
||||
if self.capture:
|
||||
|
|
|
@ -62,10 +62,6 @@
|
|||
border: 0px;
|
||||
}
|
||||
|
||||
#hosts {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body onload="main()">
|
||||
|
@ -114,12 +110,10 @@
|
|||
</table>
|
||||
<fieldset id="messagebox_fieldset">
|
||||
<legend><b>Data [<a href="javascript:hide_messagebox()">hide</a>]:</b></legend>
|
||||
<a name="message">
|
||||
<div id="messagebox"></div>
|
||||
</a>
|
||||
<a name="message"> </a>
|
||||
<div id="messagebox"></div>
|
||||
</fieldset>
|
||||
<a name="aftermessage">
|
||||
<div id="testmain"></div>
|
||||
</a>
|
||||
<a name="aftermessage"> </a>
|
||||
<div id="testmain"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue