Skip to content

The Plugin API. - #1223

Merged
waylan merged 2 commits into
mkdocs:1.0.devfrom
waylan:plugin1.0
May 17, 2017
Merged

waylan merged 2 commits into
mkdocs:1.0.devfrom
waylan:plugin1.0

Conversation

@waylan

@waylan waylan commented May 9, 2017

Copy link
Copy Markdown
Contributor

See the included documentation for a full explaination of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their mkdocs.yml file:

plugins:
    - legacy_search

Fixes #206

@waylan waylan added this to the 1.0.0 milestone May 9, 2017
@waylan waylan mentioned this pull request May 9, 2017
@d0ugal

d0ugal commented May 9, 2017

Copy link
Copy Markdown
Contributor

I've only skimmed it quickly - overall it looks good, I really like the direction.
One question, why legacy_search rather than just search? Is there a plan for a new search plugin?

@waylan

waylan commented May 9, 2017

Copy link
Copy Markdown
Contributor Author

Is there a plan for a new search plugin?

Yes. Half of the remaining open tickets are regarding search. It would be easier to start over. If users really want the old plugin, then they can fall back to it. However, if it makes sense after we have the new plugin, we can always get ride of legacy_search before release.

@waylan
waylan force-pushed the plugin1.0 branch 3 times, most recently from a11b061 to ae66eac Compare May 9, 2017 18:24
See the included documentation for a full explaination of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes mkdocs#206
@waylan

waylan commented May 9, 2017 •

Copy link
Copy Markdown
Contributor Author

While working through some failing tests, The linkchecker tests made me realize that there is something missing from the API. In those tests we run through the integration tests and then run the linkchecker on the built sites. Because those sites are built without the Search Plugin, the search assets are not included in the build, causing the build to fail. I could just include the plugin in each config file, but that doesn't address that issue that the template still includes script tags pointing to the search assets regardless of whether the plugin is activated.

In other words, we need a way for plugins to load scripts. We can't use extra_scripts because they assume a base URL of the docs_dir rather than a template dir. It's easy enough to add an attribute to the BasePlugin class for extra_libs and/or extra_scripts, but do we want to limit that to plugins only or open that up for themes to use as well?

@waylan

waylan commented May 10, 2017

Copy link
Copy Markdown
Contributor Author

So extra-javascript works fine as a way for a plugin to add scripts. I forgot the files are copied independent of entries in the setting so it doesn't matter where the file originated. As long as the value is a valid path from the server root of the built site to an actual script, it works fine.

The real problem is that the legacy search script depends on require.js so rather than a straightforward script tag pointing to search.js we need a custom script tag which won't get generated from an entry in extra_javascript. I'll need to hack a workaround until we can refactor the plugin.

waylan added a commit to waylan/mkdocs that referenced this pull request May 10, 2017
This is a hack which will get removed when the search plugin gets
refactored. At that time we can remove the special case in the templates
and do everything through the (no comments out) code in the plugin.

Addresses issue raised in comments in mkdocs#1223.
@waylan

waylan commented May 10, 2017

Copy link
Copy Markdown
Contributor Author

Well the workaround was surprisingly easy. And it serves as a demonstration of how a theme could conditionally support a plugin (based on whether it is installed or not). I included the (commented out) code that uses extra_javascript as a reminder (and demonstration) of how to address the issue in most situations.

This passes all tests now and is ready to merge. However, I'll let it sit for a few days to give others a chance to provide feedback.

@waylan

waylan commented May 11, 2017

Copy link
Copy Markdown
Contributor Author

Just pushed a better fix which ever so slightly refactors search.js so it works with the plugin API.

@waylan
waylan merged commit 73b6165 into mkdocs:1.0.dev May 17, 2017
@waylan
waylan deleted the plugin1.0 branch May 17, 2017 19:28
@d0ugal

d0ugal commented May 17, 2017

Copy link
Copy Markdown
Contributor

Woop! Great job.

This was referenced Jun 22, 2017
waylan added a commit to waylan/mkdocs that referenced this pull request Sep 28, 2017
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes mkdocs#206
waylan added a commit to waylan/mkdocs that referenced this pull request Sep 28, 2017
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes mkdocs#206
waylan added a commit to waylan/mkdocs that referenced this pull request Sep 28, 2017
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes mkdocs#206
waylan added a commit to waylan/mkdocs that referenced this pull request Sep 28, 2017
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes mkdocs#206
waylan added a commit that referenced this pull request Oct 1, 2017
See the included documentation for a full explanation of the API.

Search has been removed and wrapped in a plugin (named "legacy_search").
The search feature was ported as-is. None of the open issues with search
have been addressed. Presumably, a new search plugin will be built from
the ground up which addresses those issues.

Note that there is no 'default' plugins. That means that users get no
search unless they enable it in the config by adding the following to
their `mkdocs.yml` file:

    plugins:
        - legacy_search

Fixes #206
@waylan waylan mentioned this pull request Oct 5, 2017
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.

2 participants