示例#1
0
def process_need_nodes(app, doctree, fromdocname):
    """
    Event handler to add title meta data (status, tags, links, ...) information to the Need node.

    :param app:
    :param doctree:
    :param fromdocname:
    :return:
    """
    if not app.config.needs_include_needs:
        for node in doctree.traverse(Need):
            node.parent.remove(node)
        return

    env = app.builder.env

    # If no needs were defined, we do not need to do anything
    if not hasattr(env, "needs_all_needs"):
        return

    needs = env.needs_all_needs

    # Call dynamic functions and replace related note data with their return values
    resolve_dynamic_values(env)

    # Create back links of common links and extra links
    for links in env.config.needs_extra_links:
        create_back_links(env, links['option'])

    for node_need in doctree.traverse(Need):
        need_id = node_need.attributes["ids"][0]
        need_data = needs[need_id]

        find_and_replace_node_content(node_need, env, need_data)

        node_headline = construct_headline(need_data, app)
        node_meta = construct_meta(need_data, env)

        # Collapse check
        if need_data["collapse"] and "HTML" in app.builder.name.upper():
            # HEADER
            node_need_toogle_container = nodes.container(classes=['toggle'])
            node_need_toogle_head_container = nodes.container(
                classes=['header'])
            node_need_toogle_head_container += node_headline.children

            node_need_toogle_container.append(node_need_toogle_head_container)

            # Only add node_meta(line_block), if it has lines in it
            # Otherwise the pdf/latex build will claim about an empty line_block.
            if node_meta.children:
                node_need_toogle_container.append(node_meta)

            node_need.insert(0, node_need_toogle_container)
        else:
            node_meta.insert(0, node_headline)
            node_need.insert(0, node_meta)
示例#2
0
def process_need_nodes(app, doctree, fromdocname):
    """
    Event handler to add title meta data (status, tags, links, ...) information to the Need node.

    :param app:
    :param doctree:
    :param fromdocname:
    :return:
    """
    if not app.config.needs_include_needs:
        for node in doctree.traverse(Need):
            node.parent.remove(node)
        return

    env = app.builder.env

    # If no needs were defined, we do not need to do anything
    if not hasattr(env, "needs_all_needs"):
        return

    needs = env.needs_all_needs

    #print (needs)

    # Call dynamic functions and replace related note data with their return values
    resolve_dynamic_values(env)

    # Create back links of common links and extra links
    for links in env.config.needs_extra_links:
        create_back_links(env, links['option'])

    for node_need in doctree.traverse(Need):
        #print("node_need ", node_need)
        #print("node_need.attributes['ids'] ", node_need.attributes["ids"])

        need_id = node_need.attributes["ids"][0]
        need_data = needs[need_id]

        find_and_replace_node_content(node_need, env, need_data)
        for index, attribute in enumerate(node_need.attributes['classes']):
            node_need.attributes['classes'][index] = check_and_get_content(
                attribute, need_data, env)

        layout = need_data['layout']
        if layout is None or len(layout) == 0:
            layout = getattr(app.config, 'needs_default_layout', 'clean')

        build_need(layout, node_need, app)
示例#3
0
def print_need_nodes(app, doctree, fromdocname):
    """
    Finally creates the need-node in the docurils node-tree.

    :param app:
    :param doctree:
    :param fromdocname:
    :return:
    """
    env = app.builder.env
    needs = env.needs_all_needs

    for node_need in doctree.traverse(Need):
        need_id = node_need.attributes["ids"][0]
        need_data = needs[need_id]

        find_and_replace_node_content(node_need, env, need_data)
        for index, attribute in enumerate(node_need.attributes["classes"]):
            node_need.attributes["classes"][index] = check_and_get_content(
                attribute, need_data, env)

        layout = need_data["layout"] or app.config.needs_default_layout

        build_need(layout, node_need, app, fromdocname=fromdocname)