示例#1
0
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)
示例#2
0
def test_create_namespace_tree():
    tree = htmlgen.create_namespace_tree(['foo.bar.baz'])
    assert tree == {'': ['foo'],
                    'foo': ['foo.bar'],
                    'foo.bar': ['foo.bar.baz']}
    tree = htmlgen.create_namespace_tree(['foo.bar.baz', 'foo.bar.qux'])
    assert tree == {'': ['foo'],
                    'foo': ['foo.bar'],
                    'foo.bar': ['foo.bar.baz', 'foo.bar.qux']}
    tree = htmlgen.create_namespace_tree(['pkg.sub.func',
                                          'pkg.SomeClass',
                                          'pkg.SomeSubClass'])
    assert tree == {'': ['pkg'],
                    'pkg.sub': ['pkg.sub.func'],
                    'pkg': ['pkg.sub', 'pkg.SomeClass',
                            'pkg.SomeSubClass']}