-
Notifications
You must be signed in to change notification settings - Fork 38
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
Minimal API to enable/disable built-in plugins #229
Comments
Case study: Mistune v2markdown = mistune.create_markdown(plugins=['strikethrough'])
renderer = mistune.HTMLRenderer()
markdown = mistune.Markdown(renderer, plugins=[plugin_strikethrough])
markdown = mistune.create_markdown(plugins=[DirectiveToc(...)]) The string version uses plugins from a hand-written dict of "built-in" plugins. On the second Case study: Flask extensionsdb = SQLAlchemy(app, ...)
db = SQLAlchemy(...)
db.init_app(app) Unlike Mistune:
Case study: make_reader_from_config()reader = make_reader_from_config(..., plugins=[
'reader._plugins.regex_mark_as_read:regex_mark_as_read',
reader._plugins.ua_fallback.init,
]) Like Mistune, it takes either a string or a callable; unlike Mistune, the string is an import path, not a name. It should be possible to change a make_reader() call to make_reader_from_config() without changing anything else. If we use plugin names in make_reader(), we risk shadowing other packages; put another way, we need to be able to distinguish between plugin names and import paths from the start. Possible ways to deal with this:
It seems we have a trade-off between:
Update: A one-user focus group concluded import paths everywhere is better: reader = make_reader('db.sqlite', plugins=[
'reader.plugins.ua_fallback',
'thirdparty', # implicit callable
'thirdparty:init', # explicit callable also OK
]) This is more intuitive (users just have to learn one thing), and we don't have to explain why and how things are different. Update #2: |
To do:
|
With #226, it's become obvious that some plugins should be enabled by default.
There's also reader._config.make_reader_from_config(); ideally, make_reader() should tend toward it.
Important: This is not to make public hooks etc. (#80); the only promise we make is: this is how you enable/disable built-in plugins, and these are the built-in plugins.
Additionally, it would probably nice to allow callable-style plugins (a la Mistune v2); here, the promise we make is: given this list of callables, we'll call them with the instantiated reader before returning it.
Candidates for the status of built-in:
The text was updated successfully, but these errors were encountered: