Example #1
0
def print_packageOverview(prefix, pkgname, encoded_pkgname, descr,
                          modules_list, modules_description):

    pkgspan = newTag('span', content=pkgname, attributes={"class": "pkgname"})
    heading = newTag('h3',
                     content=["Overview of package ", pkgspan],
                     newlines=False)
    description = newTag('p', content=descr)
    items = []
    for module in sorted(modules_list):
        link = newTag('a',
                      content=module,
                      attributes={
                          "href": module + ".html",
                          "target": 'moduleFrame'
                      })
        mod_dt = newTag('dt',
                        content=link,
                        attributes={"style": "padding-top:0.5em;"},
                        newlines=False)
        mod_descr = newTag('dd', content=modules_description[module])
        items.extend([mod_dt, mod_descr])
    modules_dl = newTag('dl', content=items)
    body = newTag('body', content=[heading, description, modules_dl])

    fileBaseName = encoded_pkgname + "-overview"
    printout(body,
             prefix,
             title="Overview of package " + pkgname,
             output_file=fileBaseName)
Example #2
0
def print_packageListFrame(prefix, allModulesFile, src_tree, packages):
    title = "Overview of CP2K API"
    heading = newTag('h2', content=title)

    link = newTag('a',
                  content="All Modules",
                  attributes={
                      "href": allModulesFile,
                      "target": "packageFrame",
                      "style": 'font-style:oblique;'
                  })
    allModLink_div = newTag('div', content=link)

    pkglist = getTree(src_tree, packages)
    pkgdir = "."
    pkgname = encode_package_name(pkgdir)
    pkgdescr = packages[pkgdir]['description']
    rootnode = newTag('a',
                      content="[root]",
                      attributes={
                          "href":
                          pkgname + "-frame.html",
                          "target":
                          "packageFrame",
                          "title":
                          pkgdescr,
                          "style":
                          'font-style:oblique;',
                          "onclick":
                          "resetModuleFrameWithPkgDescr('root', '" + pkgname +
                          "')"
                      })
    fakelist = newTag('ul',
                      content=newTag('li', content=[rootnode, pkglist]),
                      attributes={"class": "nobullet"})
    list_heading = newTag('h4',
                          content="Packages:",
                          attributes={"title": "Packages"})
    listContainer_div = newTag('div', content=[list_heading, fakelist])

    body = newTag('body', content=[heading, allModLink_div, listContainer_div])

    fileBaseName = "packages-frame"
    printout(body,
             prefix,
             title=title,
             output_file=fileBaseName,
             jscript=["js/common.js", "js/resetModuleFrame.js"])
    return fileBaseName + '.html'
Example #3
0
def document_all_modules(packages, ast_dir, output_dir, sym_lookup_table):

    # init
    modules_lists = {'__ALL__': []}
    modules_description = {}
    privates_referenced = {}

    # scan packages
    src_root = path.normpath(path.commonprefix(packages.keys()))
    for d, p in packages.iteritems():
        # d: dir hosting a PACKAGE file, p: basically the eval()uation of that PACKAGE file
        rel_path = path.relpath(d, src_root)
        modules_lists[rel_path] = []

        # scan PACKAGE-owned module files (the 'files' key is contributed by the scan_packages() function)
        for f in p['files']:
            mod_name = f.rsplit(".", 1)[0]
            ast_file = path.join(ast_dir, mod_name + ".ast")
            if (path.isfile(ast_file)):
                print("Reading ast: " + ast_file)
                ast = utils.read_ast(ast_file)
                if (ast['tag'] == 'module'):
                    if (utils.verbose()):
                        print '>>>> Module: %s [%s]' % (mod_name, rel_path)

                    # lists of modules per PACKAGE, needed by the landing page
                    modules_lists[rel_path].append(mod_name)
                    modules_lists['__ALL__'].append(mod_name)
                    modules_description[mod_name] = ast['descr'][0] if ast[
                        'descr'] else missing_description  # Only 1st \brief is retained here

                    # dump the current module HTML documentation
                    body, my_privates_referenced = render_module(
                        ast, rel_path, ast_dir, output_dir, sym_lookup_table)
                    printout(body,
                             output_dir,
                             mod_name=mod_name,
                             jscript=[
                                 'packages_modules.json', 'js/common.js',
                                 'js/updateURL.js', 'js/highlightArgument.js',
                                 jquery_url
                             ],
                             custom_script=jquery_function % mod_name)
                    if my_privates_referenced:
                        privates_referenced[
                            mod_name.upper()] = my_privates_referenced

    return modules_lists, modules_description, privates_referenced
Example #4
0
def print_disambiguationPage(symbols_db, modules_description, prefix):

    title = "Disambiguation Page"
    heading = newTag('h2', content=title)
    subhead = newTag(
        'h4',
        content=
        "This disambiguation page lists modules that share the same name for a public symbol"
    )
    body_parts = [heading, subhead]

    todo_list = sorted(s for s in symbols_db if len(symbols_db[s]) > 1)
    for s in todo_list:
        symbol = s.lower()
        owner_modules = symbols_db[s]
        items = []
        for m in owner_modules:
            module = m.lower()
            link = newTag('a',
                          content=module,
                          attributes={
                              "href": filename(module, hashtag=symbol),
                              "title": modules_description[module]
                          })
            items.append(newTag('li', content=link))
        sname = newTag('span',
                       content=symbol,
                       id=symbol,
                       attributes={"class": "symname"})
        p = newTag('p',
                   content=[
                       sname, " symbol found in " + str(len(owner_modules)) +
                       " modules:"
                   ])
        l = newTag('ul',
                   content=items,
                   attributes={
                       "class": "horizontal",
                       "style": 'padding-top: 0;'
                   })
        body_parts.extend([p, l])

    body = newTag('body', content=body_parts)
    fileBaseName = "disambiguation"
    printout(body, prefix, title=title, output_file=fileBaseName)
Example #5
0
def print_allModules(prefix,
                     modules_list,
                     modules_description,
                     pkgdir=None,
                     packages=None):

    if pkgdir:
        pkgname = 'ROOT' if pkgdir == '.' else pkgdir
        title = " ".join([pkgname, "package"])
        pre = ""
        pkg = newTag('span', content=pkgname, attributes={"class": 'pkgname'})
        post = " modules:"
        heading_content = [pre, pkg, post]
        encoded_pkgname = encode_package_name(pkgdir)
        assert (packages)
        print_packageOverview(prefix, pkgname, encoded_pkgname,
                              packages[pkgdir]['description'], modules_list,
                              modules_description)
    else:
        title = "All Modules:"
        heading_content = title
        encoded_pkgname = "pkg__allmodules"

    heading = newTag('h2', content=heading_content, newlines=False)

    mod_items = []
    for module in sorted(modules_list):
        link = newTag('a',
                      content=module,
                      id=module + "__inPackageFrame__" + encoded_pkgname,
                      attributes={
                          "href": module + ".html",
                          "target": 'moduleFrame',
                          "title": modules_description[module]
                      })
        mod_items.append(newTag('li', content=link))
    mod_list = newTag('ul',
                      content=mod_items,
                      attributes={"class": 'modules_in_package'})
    body = newTag('body', content=[heading, mod_list])

    fileBaseName = encoded_pkgname + "-frame"
    printout(body, prefix, title=title, output_file=fileBaseName)
    return fileBaseName + '.html'
Example #6
0
def commit_banner_dump_indices(banner, indices, prefix):

    # loop over buttons (indices)
    for i, index_id in enumerate(indices.l2sort):
        activate_item_inplace(i, banner)
        my_body = indices.bodies[i]
        my_body.addAttribute("class", "landing_page_content")
        title = getattr(indices, index_id)
        body = newTag('body',
                      content=[banner, my_body],
                      attributes={
                          "class": "landing_page",
                          "onload": "javascript:setContentSize()",
                          "onresize": "javascript:setContentSize()"
                      })
        printout(body,
                 prefix,
                 title=title,
                 output_file=index_id,
                 jscript=["js/showhide.js", "js/setContentSize.js"],
                 html_class="landing_page")
Example #7
0
def print_landingPage(prefix, src_tree, packages, modules_lists,
                      modules_description, sym_lookup_table):

    allModulesFile = print_allModules(prefix, modules_lists['__ALL__'],
                                      modules_description)
    pkgModulesFiles = print_packageFrame(prefix, modules_lists,
                                         modules_description, packages)
    packageListFile = print_packageListFrame(prefix, allModulesFile, src_tree,
                                             packages)
    overviewFile = print_overview(prefix, src_tree, packages, modules_lists,
                                  modules_description, sym_lookup_table)

    title = 'CP2K API Documentation'

    packageListFrame = newTag('frame',
                              id="packageListFrame",
                              attributes={
                                  "src": packageListFile,
                                  "name": "packageListFrame",
                                  "title": "All Packages"
                              })
    packageFrame = newTag('frame',
                          id="packageFrame",
                          attributes={
                              "src": allModulesFile,
                              "name": "packageFrame",
                              "title": "All Modules"
                          })
    moduleFrame = newTag('frame',
                         id="moduleFrame",
                         attributes={
                             "src": overviewFile,
                             "name": "moduleFrame",
                             "title": "Module descriptions"
                         })

    noscript = newTag('noscript',
                      content=newTag(
                          'div',
                          content="JavaScript is disabled on your browser."))
    heading = newTag('h2', content="Frame Alert")
    paragrph = newTag(
        'p',
        content=
        "This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client."
    )
    noframes = newTag('noframes', content=[noscript, heading, paragrph])

    inner_frameset = newTag('frameset',
                            content=[packageListFrame, packageFrame],
                            attributes={
                                "rows": "50%,50%",
                                "title": "Left frames",
                                "onload": "top.loadFrames()"
                            })
    outer_frameset = newTag('frameset',
                            content=[inner_frameset, moduleFrame, noframes],
                            attributes={
                                "cols": "20%,80%",
                                "title": "Documentation frame",
                                "onload": "top.loadFrames()"
                            })

    printout(outer_frameset,
             prefix,
             title=title,
             output_file="index",
             jscript=[
                 "modules_publics.json", "privates_referenced.json",
                 "js/searchURL.js"
             ])