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)
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)