mkdocs-literate-nav
mkdocs-literate-nav copied to clipboard
Sub-dir configuration ignored when flattening the nav
Let's say we have such a structure:
- project/
- file.md
- SUMMARY.md
- docs/
- SUMMARY.md
- some-file.md
- dir/
- another-file.md
In project/SUMMARY.md
we have:
- *.md
- docs/*
In project/docs/SUMMARY.md
we have:
- *.md
In result I would expect to get such nav:
- project/
- file.md
- some-file.md
But what I get is:
- project/
- file.md
- SUMMARY.md
- some-file.md
- dir/
- another-file.md
I guess it's because we have two SUMMARY.md
files in the same dir and only the first one is read. But I would expect SUMMARY.md
are read from the deepest dirs first and only the result structure of the defined filter is merged to the higher ones.
Thanks for the report. Indeed I can exactly reproduce this in a test:
tests/nav/whatever.yml
files:
SUMMARY.md: |
- *.md
- docs/*
file.md:
docs/SUMMARY.md: |
- *.md
docs/some-file.md:
docs/dir/another-file.md:
output:
- null: file.md
- null: docs/SUMMARY.md
- null: docs/some-file.md
- Dir:
- null: docs/dir/another-file.md
pytest -sv --update-goldens
And indeed it seems like your expectation for this makes more sense.
No, wait...
I guess it's because we have two SUMMARY.md files in the same dir and only the first one is read.
That is not correct. Wildcards can't actually pull in a nav file.
- *.md
- docs/*
This nav is equivalent to
- *.md
- docs/*.md
- docs/*/
Which is
- file.md
- docs/some-file.md
- docs/dir/
Which then gets expanded as
- file.md
- docs/some-file.md
-
Dir:
- docs/dir/another-file.md
@oprypin Okay, so than we have 3 scenarios here:
- the above one with
docs/*
- we pull in all.md
files and all subdirs,docs/SUMMARY.md
is treated just as a normal.md
file, not the nav one - the one with
docs/*.md
- we pull in all.md
files,docs/SUMMARY.md
is treated just as a normal.md
file, not the nav one - the one with
docs/
- we pull in files and subdirs specified indocs/SUMMARY.md
, which is treated as a nav file, but we need to explicitly specify the section name, e.g.- [Docs](docs/)
The last behaviour is exactly what I want to achieve, but then we just encounter the issue I mentioned in #5. And as you commented there - even if it was the part of the initial philosophy not to omit titles, wildcards change that assumption significantly. And tbh - it's much more convenient, so if we allow such syntax in a nav file: - docs/
and auto-generate title then - we would solve both issues easily.
One more note to the above comment - I mentioned The last behaviour is exactly what I want to achieve - of course that's not actually true, because there's no flattening in that variant. Sorry, it was late 😉
In result neither option provides what I need - I can either flatten the structure but with no way to control the sub-nav or... I can control the sub-nav with no way to flatten the structure.