oprypin / mkdocs-literate-nav

MkDocs plugin to specify the navigation in Markdown instead of YAML
https://oprypin.github.io/mkdocs-literate-nav
MIT License
73 stars 8 forks source link

Sub-dir configuration ignored when flattening the nav #6

Open jaklan opened 2 years ago

jaklan commented 2 years ago

Let's say we have such a structure:

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:

But what I get is:

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.

oprypin commented 2 years ago

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.

oprypin commented 2 years ago

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

Which then gets expanded as

jaklan commented 2 years ago

@oprypin Okay, so than we have 3 scenarios here: 1) 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 2) 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 3) the one with docs/ - we pull in files and subdirs specified in docs/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.

jaklan commented 2 years ago

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.