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

Does mike work with new INHERIT mkdocs config feature? #59

Closed
ghost opened this issue Jun 8, 2021 · 11 comments
Closed

Does mike work with new INHERIT mkdocs config feature? #59

ghost opened this issue Jun 8, 2021 · 11 comments

Comments

@ghost
Copy link

ghost commented Jun 8, 2021

Is mike 1.0.1 compatible with mkdocs 1.2 INHERIT token?

I'm rejigging a set of configs to use the INHERIT feature but when running mike I get error: 'dict' object has no attribute 'insert'.

@jimporter
Copy link
Owner

Looking at the MkDocs docs, the short answer is "no". If you want to use mike, you'll have to avoid INHERIT for now. However, with some fixes, it should be possible to (mostly?) get mike working with INHERIT.

I'm a little skeptical about the INHERIT feature though, since the documentation doesn't bother to explain how plugins get merged across multiple configurations. Specifically, the docs are silent on the order of plugins after merging. Since dicts in Python 3.6+ are ordered, the behavior is predictable at least, but it does matter whether the child config's plugins are put before or after the parent config's: plugins can modify the MkDocs configuration, so running plugins in a different order can result in different output. Because this isn't mentioned in the docs, I can only assume that the order (whatever it is) is unspecified and could change at any time in a point release.

@ghost
Copy link
Author

ghost commented Jun 8, 2021

Good and clear answer, thank you.

I hadn't considered the consequences, only the inflexibility, such was my desperation to try anything to tame multiple nav elements across several files. It's better than nothing but only if using mkdocs directly.

@ghost ghost closed this as completed Jun 8, 2021
@jimporter
Copy link
Owner

I'm going to reopen this to track the fix for mike so that it works (as best as it can, at least) with INHERIT. It should be relatively straightforward to handle this for docs that don't depend on plugin ordering. If plugin ordering does cause issues in some cases, that's probably an MkDocs bug, and I'll let them handle it; that issue isn't specific to mike, and would be likely to crop up elsewhere too.

@jimporter jimporter reopened this Jun 8, 2021
@chris-twiner
Copy link

fyi - I've managed to get some success for both inherit and for !ENV by leveraging mkdocs.utils.yaml_load instead of yaml.load in mkdocs_utils.py within a fork. These two lines (plus one for the import) are the only things I needed to change, but it's entirely possible I've just not hit a use case that doesn't work for yet.

@jimporter
Copy link
Owner

@chris-twiner Looking at the implementation of mkdocs.utils.yaml_load, that seems like a reasonable solution, and I can't think of a situation where it won't work. There might be a still-better way (I'll look into this when I get the chance), but you shouldn't run into any issues with that change.

@jimporter
Copy link
Owner

Ok, INHERIT and !ENV should work now, as well as specifying plugins as a dict. This will go out in v1.1.0, which I'll probably release in a few weeks if nothing major comes up.

@chris-twiner
Copy link

Very cool, many thanks!

@ghost
Copy link
Author

ghost commented Aug 30, 2021

This will go out in v1.1.0, which I'll probably release in a few weeks if nothing major comes up.

Any ETA for 1.1.0?

@jimporter
Copy link
Owner

jimporter commented Aug 30, 2021

Probably this week, since the only remaining thing I want to add is some documentation about working with CI (that's a pretty common issue that gets filed).

@jimporter
Copy link
Owner

Ok, I've just published v1.1.0, so now this should be available to everyone via PyPI.

@ghost
Copy link
Author

ghost commented Sep 2, 2021

It's excellent and pushed to production! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants