Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend hierarchy calculation for deeply nested pages #250

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
- Project prepared to be installed with `pip install`, so it can be reused in
the repository https://github.com/canonical/gatekeeper-repo-test

## [v0.9.1] - 2024-06-28

### Fixed
a-velasco marked this conversation as resolved.
Show resolved Hide resolved

- Support for navigation table with hierarchy jumps of more than 1 level

## [v0.9.0] - 2024-04-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion src-docs/index.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Classify the type of a reference.

---

<a href="../src/gatekeeper/index.py#L413"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/gatekeeper/index.py#L414"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_contents`

Expand Down
1 change: 1 addition & 0 deletions src/gatekeeper/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/test_index_contents_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
]


Expand Down
Loading