Skip to content

feat: add plugin enabled config option#504

Merged
pawamoy merged 2 commits intomkdocstrings:masterfrom
StefanBRas:disable_plugin_flag
Jan 8, 2023
Merged

feat: add plugin enabled config option#504
pawamoy merged 2 commits intomkdocstrings:masterfrom
StefanBRas:disable_plugin_flag

Conversation

@StefanBRas
Copy link
Copy Markdown
Contributor

@StefanBRas StefanBRas commented Jan 5, 2023

Fixes #478.

For the docs entry I guessed that it will be released in version 0.20, this might have to be adjusted.

I considered adding a test but I couldn't see some obvious way to extend the test suite.

Copy link
Copy Markdown
Member

@oprypin oprypin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of the config, done like timvink/mkdocs-print-site-plugin@315c2e0

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Jan 5, 2023

Thanks for the link @oprypin. What's the benefit of having the config value as well?
UPDATE: ah, maybe that users can choose the env var name?

@StefanBRas
Copy link
Copy Markdown
Contributor Author

If we use the config, it's also possible to change it while hot reloading without restarting the process (but then we're back to forgetting to revert the change and accidentally committing it)

I think the test fails are unrelated to my change by the way, they're also failing on master for me.

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Jan 5, 2023

Yep, seems like there's some maintenance to do. I'll fix CI tomorrow.

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Jan 6, 2023

OK I checked the docs again and I see a clear benefit to having a configuration option: it allows users to enable/disable the plugin depending on multiple environment variables. It draws the path to a convention thanks to which you can disable all plugins at once, or just specific ones:

plugins:
- plugin_a:
    enabled: !ENV [MKDOCS_ENABLE_PLUGINS, MKDOCS_ENABLE_PLUGINA, true]
- plugin_b:
    enabled: !ENV [MKDOCS_ENABLE_PLUGINS, MKDOCS_ENABLE_PLUGINB, true]

With this config, users can disable both plugins with MKDOCS_ENABLE_PLUGINS=no or disable just the plugin B with MKDOCS_ENABLE_PLUGINB=no.

This would allow even more grouping of plugins.

Of course all plugins should provide the same enabled or disabled options, as I don't think it's possible to say "not ENV_VAR".

So, @StefanBRas, could you bring the change following what was done in the link @oprypin mentioned? Sorry for the late change of direction.

@StefanBRas
Copy link
Copy Markdown
Contributor Author

Sure, I'll do it over the weekend. Should it be an "enabled" option instead of "disabled" to be in line with others plugins then?

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Jan 6, 2023

Yes! Thanks a lot :)

@StefanBRas StefanBRas changed the title feat: add plugin disable flag feat: add plugin enabled config option Jan 7, 2023
@StefanBRas StefanBRas requested a review from pawamoy January 7, 2023 14:02
Copy link
Copy Markdown
Member

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few doc-related changes 🙂

@StefanBRas StefanBRas requested a review from pawamoy January 7, 2023 15:17
Copy link
Copy Markdown
Member

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a test 🙂

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

Successfully merging this pull request may close these issues.

Add option to disable plugin in mkdocs.yml

3 participants