2007-01-24 22:24:01 +08:00
|
|
|
""" run 'py.test --apigen=<this script>' to get documentation exported
|
|
|
|
|
|
|
|
exports to /tmp/output by default, set the environment variable
|
|
|
|
'APIGEN_TARGET' to override
|
|
|
|
"""
|
|
|
|
|
|
|
|
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-01-24 22:24:01 +08:00
|
|
|
|
|
|
|
def get_documentable_items(pkgdir):
|
2007-01-26 00:46:56 +08:00
|
|
|
sys.path.insert(0, str(pkgdir.dirpath()))
|
|
|
|
rootmod = __import__(pkgdir.basename)
|
2007-01-30 18:34:08 +08:00
|
|
|
return 'py', pkg_to_dict(rootmod)
|
2007-01-24 22:24:01 +08:00
|
|
|
|
|
|
|
def build(pkgdir, dsa):
|
|
|
|
l = linker.Linker()
|
|
|
|
proj = project.Project()
|
|
|
|
|
|
|
|
if 'APIGEN_TARGET' in os.environ:
|
|
|
|
targetdir = py.path.local(os.environ['APIGEN_TARGET'])
|
|
|
|
else:
|
|
|
|
targetdir = pkgdir.dirpath().join('apigen')
|
|
|
|
targetdir.ensure(dir=True)
|
|
|
|
|
|
|
|
all_names = dsa._get_names(filter=lambda x, y: True)
|
|
|
|
namespace_tree = htmlgen.create_namespace_tree(all_names)
|
2007-01-26 23:34:28 +08:00
|
|
|
apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree)
|
2007-01-24 22:24:01 +08:00
|
|
|
spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir)
|
|
|
|
|
2007-01-26 23:34:28 +08:00
|
|
|
ns_data = apb.prepare_namespace_pages()
|
2007-01-24 22:24:01 +08:00
|
|
|
class_names = dsa.get_class_names()
|
2007-01-26 23:34:28 +08:00
|
|
|
class_data = apb.prepare_class_pages(class_names)
|
2007-01-24 22:24:01 +08:00
|
|
|
function_names = dsa.get_function_names()
|
2007-01-26 23:34:28 +08:00
|
|
|
func_data = apb.prepare_function_pages(function_names)
|
2007-01-24 22:24:01 +08:00
|
|
|
source_data = spb.prepare_pages(pkgdir)
|
|
|
|
|
|
|
|
apb.build_namespace_pages(ns_data, proj)
|
|
|
|
apb.build_class_pages(class_data, proj)
|
2007-01-26 21:01:27 +08:00
|
|
|
#apb.build_method_pages(method_data, proj)
|
2007-01-24 22:24:01 +08:00
|
|
|
apb.build_function_pages(func_data, proj)
|
|
|
|
spb.build_pages(source_data, proj, pkgdir)
|
|
|
|
|