Ejemplo n.º 1
0
def test_sets_multiple_tags(node_string, expected_stop, expected_include,
                            expected_id):
    node = NavigationTreeNode(node_string)
    assert node.options['stop'] == expected_stop
    assert node.options['id'] == expected_id
    if expected_include is not None:
        assert node.options['include'] == expected_include
Ejemplo n.º 2
0
    def _forest_to_root_names(self, forest):
        """Return the root names of all the trees in forest"""

        root_nodes = self._forest_to_root_nodes(forest)

        root_names = []
        for node in root_nodes:
            node_name, _ = NavigationTreeNode.split_node_name_and_tags(node)
            root_names.append(node_name)

        return root_names
Ejemplo n.º 3
0
    def _format_contents(self, path, children_nodes):
        """"""
        contents = []
        for node in children_nodes:
            child_node = NavigationTreeNode(node)
            if not child_node.options['stop']:
                path = path.replace(self.site_root, '')
                link = os.path.join(path, child_node.name)
                item = self._format_markdown_linked_item(child_node.name, link)
            else:
                item = child_node.name

            contents.append(item)

        return contents
Ejemplo n.º 4
0
    def _get_root_node_and_children_trees(tree):
        """"""
        if isinstance(tree, dict):
            # tree here is a one-item dictionary representing a 'non-leaf directory'
            # (having children):
            #   - the 'key' is a string (root name followed by optional arguments)
            #   - the 'value' is a list of root's children trees
            root_node, root_children_trees = list(tree.items())[0]
        else:
            # tree here is a string representing a 'leaf directory'
            # (having no children):
            #   - root name followed by optional arguments
            root_node = tree
            root_children_trees = []

        node = NavigationTreeNode(root_node)

        return node, root_children_trees
Ejemplo n.º 5
0
def get_id(node_name):
    return NavigationTreeNode(node_name).options['id']