-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add use-page config option #5
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Overall it is good. But I have sooo many nitpicks.
In addition to the rest, this change should have tests along with it.
And even the existing tests are failing now.
To go along with this line
mkdocs-section-index/tests/test_plugin.py
Line 74 in 6e7b33e
config = dict(nav=golden["input"], use_directory_urls=use_directory_urls) |
plugin.config = {"index_file": golden.get("index_file")}
You will need to run tests. For that you can either run poetry install; .tools/hooks/pre-commit
, or install dependencies directly and run pytest
however you want.
Just saw you comments after my last push, I'm on it :) |
I addressed your comments, but I have the feeling that |
6fa6480
to
bf8d0fd
Compare
Oh wow that's a lot of logic now :( |
Actually I'd even argue that if there is no index.md the first page should not become the section page by default since it then depends on alphabetical order but there might be use cases for that. |
Right-- I was thinking that too, but I forgot after seeing your code because it looked totally reasonable :) Well, if you search for existing usages, people sometimes intentionally use non- I could make this the default only if the nav is not specified manually, but implementing that is dubious and also I think it's super rare that people just leave their nav alphabetically sorted. So this should remain just an option. And sorry but I think we should not keep the logic to reorder the pages. It should still be required to be first. |
) | ||
if nav_src == "derived_nav" and index_file != "default_index_file": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding actual files to the real example and branching all of this logic, I think the test should be separate and new.
If you need to use files from the real example, you can first create a directory for it then copy those files and add more.
shutil.copytree(example_dir / "docs", str(tmpdir))
noindex_dir = (tmpdir / "docs").mkdir("z_noindex")
(noindex_dir / "a.md").write_text("# a")
then change docs_dir=tmp_dir,
Or if you don't need the real example, just don't copy the files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good
Just thougth about the case where a previous plugin might have reordered items such that By the way if a plugin reorders children after this plugin results are most likely wrong. We could also omit a warning maybe if popular plugins which could do that are behind this plugin. |
The warning is there mkdocs-section-index/mkdocs_section_index/plugin.py Lines 53 to 56 in 7a8b4ac
Though it doesn't detect subtle reorderings. But I think it's not unreasonable to expect the plugins to coexist anyway. Currently all mav reordering plugins I know rewrite the whole nav. |
The option allows to use a different page for the section page instead of the first child.
What's the status on this? Because it fixes #6, which is a very annoying issue for me. |
Hmm the status is that I'm a bad human. I didn't follow up on this. |
The option allows to use a different page for the section page instead
of the first child.