-
Notifications
You must be signed in to change notification settings - Fork 74
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
Fix TypeError when nav is generated automatically #62
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 your contribution @gferon, I've added a comment just to understand the use case a bit more!
@@ -28,6 +28,7 @@ def __init__(self): | |||
def on_config(self, config): | |||
# If no 'nav' defined, we don't need to run. | |||
if not config.get('nav'): | |||
self.originalDocsDir = config['docs_dir'] |
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.
I'm interested in knowing more about the use case for this. The way I understand it is that the !import
statements needs to be configured in the 'nav'. So if you do not have a nav, its almost like we don't want to do anything and bubble some feedback up to the user that a nav is required to use this plugin?
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.
We use Backstage, which makes our mkdocs
depend on mkdocs-tech-core
.
Some pages were added to our documentation without properly editing the navigation. After reading the documentation of mkdocs
, I discovered that if you omit nav
, (quoting the doc) it will contain an alphanumerically sorted, nested list of all the Markdown files found within the docs_dir
and its sub-directories, which is ideal for us.
Upon removing nav
, running mkdocs serve
failed, which made me submit this fix 😄
EDIT: maybe it would be more clear if I added a test?
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.
@gferon Understand, it makes sense to me! Thanks for giving a bit more context. If you can add a test that would be great!
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.
Hi @gferon, just for follow-up, want to add tests? Thanks in advance 🙂
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 reminding me! I had a quick look, and I'm actually not sure how I could easily add a bats
test because the bug only affects mkdocs serve
and per my understanding, most tests verify that docs can be built using mkdocs build
.
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.
Do you think we can implement some unittests? just to test the on_confg? I found some examples for the search plugin https://github.com/mkdocs/mkdocs/blob/master/mkdocs/tests/search_tests.py#L208.
I found this PR because I ran into this exact use case! Anything I can do to help with this? |
I'll close this PR since it looks like it'll get taken care of with #69 |
if
nav
is not specified inmkdocs.yml
, the entireon_config
function body is skipped buton_serve
relies onself.originalDocsDir
.