lukasgeiter / mkdocs-awesome-pages-plugin

An MkDocs plugin that simplifies configuring page titles and their order
MIT License
452 stars 35 forks source link

Possible regression in 2.9.2: `hide: true` not working in `.pages` #96

Closed short-fall closed 5 months ago

short-fall commented 5 months ago

Hi! The hide-functionality does not seem to be working in our project after having upgraded to version 2.9.2. Maybe someone can reproduce the issue? Or did I miss something?

Environment:

Folder structure:

| docs/
    |— hidden/
        |— .pages
        |— index.md
    |— index.md
| mkdocs_awesome_pages_test/
    |— __init__.py
| mkdocs.yml
| poetry.lock
| pyproject.toml

Steps to reproduce:

Expected behaviour: Subfolder containing .pages-file should not be listed in page navigation.

Actual behaviour: Subfolder containing .pages-file is listed in navigation.

Some screenshots * `pyproject.toml` ![pyprojecttoml](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin/assets/156917644/fd3879ba-41cc-40e3-bb11-c34d9d91f70c) * `mkdocs.yml` ![mkdocsyml](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin/assets/156917644/26e570ba-02f9-45f8-ac70-70beb676517c) * `.pages` in subfolder ![pages](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin/assets/156917644/60d487fa-ac02-4a17-ad7a-7ab957a740f6) * Navigation of local testserver showing the supposedly hidden folder ![nav](https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin/assets/156917644/13e9461d-7c80-4ecb-9ada-72059680e339)
lukasgeiter commented 5 months ago

It looks like you haven't enabled the plugin in mkdocs.yml. Installation instructions

short-fall commented 5 months ago

Sorry that was a stupid mistake! I'm now working on trying to replicate the issue with a correct mkdocs.yml...

What I can tell so far is that the when I dump nav.items using pprint in the on_nav-hook in our mkdocs-project I get different results for plugin version 2.9.1 and 2.9.2 (versions for Python, mkdocs and other plugins unchanged). The entries that appear in version 2.9.2 are folders containing .pages-files with hide: true.

I will try to reproduce it and report back!

mkdocs-awesome-pages-plugin 2.9.1:

[Page(title='Startseite', url='/'),
 Page(title='Software Engineering', url='/software-engineering/'),
 Section(title='News'),
 Section(title='Produkte'),
 Page(title='Über uns', url='/about/'),
 Page(title='Stellenangebote', url='/stellenangebote/'),
 Page(title='News', url='/news/')]

mkdocs-awesome-pages-plugin 2.9.2:

[Page(title='Startseite', url='/'),
 Page(title='Software Engineering', url='/software-engineering/'),
 Section(title='Contact'),
 Section(title='Legal'),
 Section(title='News'),
 Section(title='Produkte'),
 Page(title='Über uns', url='/about/'),
 Page(title='Stellenangebote', url='/stellenangebote/'),
 Page(title='News', url='/news/')]
short-fall commented 5 months ago

Found the issue. We are removing files from the Files-collection in the on_files-hook using a regex that targets filenames beginning with a dot . or underscore _, preventing filenames with this pattern from being included in the build (we are using this to prepare content like news releases in advance without deploying them right away). Up until version 2.9.2 this workflow caused no issues. But with the usage of the Files-collection by mkdocs-awesome-pages-plugin in PR 79 our alteration of the Files-collection effectively removes all .pages-files for the plugin since plugin hooks are executed before custom hooks. Adapting the regex in our on_files-hook resolves this issue. Sorry again for providing a faulty example and thanks for your time!