2007-01-24 22:24:01 +08:00
|
|
|
""" run 'py.test --apigen=<this script>' to get documentation exported
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import py
|
2007-01-26 00:46:56 +08:00
|
|
|
import sys
|
2007-01-24 22:24:01 +08:00
|
|
|
from py.__.apigen import htmlgen
|
|
|
|
from py.__.apigen import linker
|
|
|
|
from py.__.apigen import project
|
2007-01-30 00:11:15 +08:00
|
|
|
from py.__.apigen.tracer.docstorage import pkg_to_dict
|
2007-02-14 07:56:57 +08:00
|
|
|
from py.__.doc.conftest import get_apigenpath
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-02-06 21:19:16 +08:00
|
|
|
from layout import LayoutPage
|
|
|
|
|
2007-02-04 22:35:28 +08:00
|
|
|
def get_documentable_items_pkgdir(pkgdir):
|
|
|
|
""" get all documentable items from an initpkg pkgdir
|
|
|
|
|
|
|
|
this is a generic implementation, import as 'get_documentable_items'
|
|
|
|
from your module when using initpkg to get all public stuff in the
|
|
|
|
package documented
|
|
|
|
"""
|
2007-01-26 00:46:56 +08:00
|
|
|
sys.path.insert(0, str(pkgdir.dirpath()))
|
|
|
|
rootmod = __import__(pkgdir.basename)
|
2007-02-02 07:58:57 +08:00
|
|
|
d = pkg_to_dict(rootmod)
|
2007-02-04 22:35:28 +08:00
|
|
|
return pkgdir.basename, d
|
|
|
|
|
|
|
|
def get_documentable_items(pkgdir):
|
|
|
|
pkgname, pkgdict = get_documentable_items_pkgdir(pkgdir)
|
2007-02-02 09:18:06 +08:00
|
|
|
from py.__.execnet.channel import Channel
|
2007-02-09 01:28:55 +08:00
|
|
|
pkgdict['execnet.Channel'] = Channel
|
2007-02-11 10:04:36 +08:00
|
|
|
Channel.__apigen_hide_from_nav__ = True
|
2007-02-04 22:35:28 +08:00
|
|
|
return pkgname, pkgdict
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-03-22 23:06:41 +08:00
|
|
|
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)
|
|
|
|
|
2007-02-01 21:56:31 +08:00
|
|
|
def build(pkgdir, dsa, capture):
|
2007-02-06 21:19:16 +08:00
|
|
|
# create a linker (link database) for cross-linking
|
2007-02-07 08:24:21 +08:00
|
|
|
l = linker.TempLinker()
|
2007-02-06 21:19:16 +08:00
|
|
|
|
|
|
|
# create a project.Project instance to contain the LayoutPage instances
|
2007-01-24 22:24:01 +08:00
|
|
|
proj = project.Project()
|
|
|
|
|
2007-02-06 21:19:16 +08:00
|
|
|
# output dir
|
2007-02-14 07:56:57 +08:00
|
|
|
from py.__.conftest import option
|
|
|
|
targetdir = get_apigenpath()
|
2007-02-14 08:11:26 +08:00
|
|
|
targetdir.ensure(dir=True)
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-02-06 21:19:16 +08:00
|
|
|
# find out what to build
|
2007-01-24 22:24:01 +08:00
|
|
|
all_names = dsa._get_names(filter=lambda x, y: True)
|
|
|
|
namespace_tree = htmlgen.create_namespace_tree(all_names)
|
2007-02-06 21:19:16 +08:00
|
|
|
|
|
|
|
# and build it
|
2007-02-02 04:10:48 +08:00
|
|
|
apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree,
|
2007-02-07 08:24:21 +08:00
|
|
|
proj, capture, LayoutPage)
|
|
|
|
spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir, proj, capture,
|
2007-03-22 23:06:41 +08:00
|
|
|
LayoutPage, dirfilter=sourcedirfilter)
|
2007-01-24 22:24:01 +08:00
|
|
|
|
2007-02-07 08:24:21 +08:00
|
|
|
apb.build_namespace_pages()
|
|
|
|
class_names = dsa.get_class_names()
|
|
|
|
apb.build_class_pages(class_names)
|
|
|
|
function_names = dsa.get_function_names()
|
|
|
|
apb.build_function_pages(function_names)
|
|
|
|
spb.build_pages(pkgdir)
|
|
|
|
l.replace_dirpath(targetdir)
|
|
|
|
|