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.

oprypin added 4 commits 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):
        crystal = 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.
Fix
@pawamoy
pawamoy approved these changes Dec 8, 2020
Copy link
Member

@pawamoy pawamoy left a comment

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
13 checks passed
13 checks passed
quality
Details
tests (ubuntu-latest, 3.6)
Details
tests (ubuntu-latest, 3.7)
Details
tests (ubuntu-latest, 3.8)
Details
tests (ubuntu-latest, 3.9)
Details
tests (macos-latest, 3.6)
Details
tests (macos-latest, 3.7)
Details
tests (macos-latest, 3.8)
Details
tests (macos-latest, 3.9)
Details
tests (windows-latest, 3.6)
Details
tests (windows-latest, 3.7)
Details
tests (windows-latest, 3.8)
Details
tests (windows-latest, 3.9)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants