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

refactor: Split out the handler cache, expose it through the plugin #191

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

oprypin
Copy link
Member

@oprypin oprypin commented Dec 7, 2020

This makes handlers_cache no longer be global but instead be confined to the Plugin. There will be only one instance of the plugin so it doesn't matter anyway. But actually this is also more correct, because what if someone tried to instantiate multiple handlers with different configs? It would work incorrectly previously.

But my main goal for this is to expose MkdocstringsPlugin.get_handler(name). Then someone can use this inside a mkdocs hook:

def on_files(self, files: Files, config: Config):
    docs = config['plugins']['mkdocstrings'].get_handler('python').collector

So this is basically a prerequisite for issue #179: one could query the collector to know which files to generate.

This makes `handlers_cache` no longer be global but instead be confined to the Plugin. There will be only one instance of the plugin so it doesn't matter anyway. But actually this is also more correct, because what if someone tried to instantiate multiple handlers with different configs? It would work incorrectly previously.

But my main goal for this is to expose `MkdocstringsPlugin.get_handler(name)`. Then someone can use this inside a mkdocs hook:

    def on_files(self, files: Files, config: Config):
        crystal = config['plugins']['mkdocstrings'].get_handler('python').collector

So this is basically a prerequisite for issue mkdocstrings#179: one could query the collector to know which files to generate.
Copy link
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.

Looking good 🚀! Can't wait to see what you do next 🤤 Thanks a lot!

@pawamoy pawamoy merged commit 6453026 into mkdocstrings:master Dec 8, 2020
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.

None yet

2 participants