diff --git a/CHANGELOG.md b/CHANGELOG.md index ae876ef8..4151bca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Project prepared to be installed with `pip install`, so it can be reused in the repository https://github.com/canonical/gatekeeper-repo-test +- Added support for navigation table with hierarchy jumps of more than 1 level ## [v0.9.0] - 2024-04-04 diff --git a/src-docs/index.py.md b/src-docs/index.py.md index 54059347..083a0e6d 100644 --- a/src-docs/index.py.md +++ b/src-docs/index.py.md @@ -123,7 +123,7 @@ Classify the type of a reference. --- - + ## function `get_contents` diff --git a/src/gatekeeper/index.py b/src/gatekeeper/index.py index 5dbf1485..087aaf15 100644 --- a/src/gatekeeper/index.py +++ b/src/gatekeeper/index.py @@ -370,6 +370,7 @@ def _calculate_contents_hierarchy( hierarchy = hierarchy - 1 parent = parents.pop() aggregate_dir = Path(parent.reference_value).parent + continue _check_contents_item( item=item, diff --git a/tests/unit/test_index_contents_hierarchy.py b/tests/unit/test_index_contents_hierarchy.py index 6368fdde..c4aba6ec 100644 --- a/tests/unit/test_index_contents_hierarchy.py +++ b/tests/unit/test_index_contents_hierarchy.py @@ -266,6 +266,50 @@ def _test__calculate_contents_hierarchy_invalid_parameters(): ("not immediately within", "directory", value_1, repr(item)), id="directory in wrong directory", ), + pytest.param( + ( + item_1 := factories.IndexParsedListItemFactory( + whitespace_count=0, reference_value=(value_1 := "dir1") + ), + item_2 := factories.IndexParsedListItemFactory( + whitespace_count=1, reference_value=(value_2 := f"{value_1}/dir2") + ), + item_3 := factories.IndexParsedListItemFactory( + whitespace_count=2, reference_value=(value_3 := f"{value_2}/file3.md") + ), + item_4 := factories.IndexParsedListItemFactory( + whitespace_count=0, reference_value=(value_4 := "dir4") + ), + ), + ("dir", "dir", "file", "dir"), + ( + factories.IndexContentsListItemFactory( + hierarchy=1, + reference_title=item_1.reference_title, + reference_value=value_1, + rank=item_1.rank, + ), + factories.IndexContentsListItemFactory( + hierarchy=2, + reference_title=item_2.reference_title, + reference_value=value_2, + rank=item_2.rank, + ), + factories.IndexContentsListItemFactory( + hierarchy=3, + reference_title=item_3.reference_title, + reference_value=value_3, + rank=item_3.rank, + ), + factories.IndexContentsListItemFactory( + hierarchy=1, + reference_title=item_4.reference_title, + reference_value=value_4, + rank=item_4.rank, + ), + ), + id="dir following an item nested more than once", + ) ]