sources for apigen.py [rev. unknown]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
""" run 'py.test --apigen=<this script>' to get documentation exported
"""
import os
import py
import sys
from py.__.apigen import htmlgen
from py.__.apigen import linker
from py.__.apigen import project
from py.__.apigen.tracer.docstorage import pkg_to_dict
from py.__.doc.conftest import get_apigenpath
from layout import LayoutPage
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
    """
    sys.path.insert(0, str(pkgdir.dirpath()))
    rootmod = __import__(pkgdir.basename)
    d = pkg_to_dict(rootmod)
    return pkgdir.basename, d
def get_documentable_items(pkgdir):
    pkgname, pkgdict = get_documentable_items_pkgdir(pkgdir)
    from py.__.execnet.channel import Channel
    pkgdict['execnet.Channel'] = Channel
    Channel.__apigen_hide_from_nav__ = True
    return pkgname, pkgdict
def build(pkgdir, dsa, capture):
    # create a linker (link database) for cross-linking
    l = linker.TempLinker()
    # create a project.Project instance to contain the LayoutPage instances
    proj = project.Project()
    # output dir
    from py.__.conftest import option
    targetdir = get_apigenpath()
    targetdir.ensure(dir=True)
    # find out what to build
    all_names = dsa._get_names(filter=lambda x, y: True)
    namespace_tree = htmlgen.create_namespace_tree(all_names)
    # and build it
    apb = htmlgen.ApiPageBuilder(targetdir, l, dsa, pkgdir, namespace_tree,
                                 proj, capture, LayoutPage)
    spb = htmlgen.SourcePageBuilder(targetdir, l, pkgdir, proj, capture,
                                    LayoutPage)
    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)