-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ReadTheDocs search and MkDocs #1088
Comments
Seems reasonable. Our code for that is here. https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/search/utils.py#L15 https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/projects/tasks.py#L408-L417 https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/projects/tasks.py#L656-L657 Not super great logic/code, mostly left over from how we do Sphinx. On Sat, Dec 13, 2014 at 8:05 AM, Dougal Matthews [email protected]
Eric Holscher |
Is this still relevant? |
Yes, I believe this is relevant. We have deprecated it in MkDocs but we won't remove it while RTD still depends on it. |
Fair enough. Sorry, I was mislead but I'm grasping at straws trying to figure out why the search for some MkDocs projects works on RTD but not for others (#2020). |
No problem. I'm not sure how to help you with that issue, I'm not familiar with RTD's search. |
It appears that the form action for the searchbox is being injected with this javascript: https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/core/static-src/core/js/doc-embed/mkdocs.js. It looks like it's just building the wrong query, along the lines of: |
Thanks for the hint. The first doesn't work for me but the second does: |
The easiest work-around for this is overriding the searchbox template like so: aegir-project/documentation@2884f80...3a44eec Note the change in the form's |
The fact that your work-around has the desired affect means that RTD by default replaces the MkDocs RTD theme? The original theme's |
RTD isn't replacing the mkdocs theme, just altering it with some javascript. As per http://www.mkdocs.org/user-guide/custom-themes/#creating-a-custom-theme, I just copied the default mkdocs RTD theme's searchbox.html, and altered the form id, so that the JS would no longer have any effect. |
@ergonlogic the only "problem" with your nifty custom theme approach I found so far is that RTD changes the implementation of the footer fly-out menu it adds. While it normally sits in the lower left corner it is moved to the lower right and becomes detached once you declare a custom theme in function fixSearch() {
var target = document.getElementById('rtd-search-form');
var config = {attributes: true, childList: true};
var observer = new MutationObserver(function(mutations) {
// if it isn't disconnected it'll loop infinitely because the observed element is modified
observer.disconnect();
var form = $('#rtd-search-form');
form.empty();
form.attr('action', 'https://' + window.location.hostname + '/en/' + determineSelectedBranch() + '/search.html');
$('<input>').attr({
type: "text",
name: "q",
placeholder: "Search docs"
}).appendTo(form);
});
// don't run this outside RTD hosting
if (window.location.origin.indexOf('readthedocs') > -1) {
observer.observe(target, config);
}
} |
Thanks you @marcelstoer the work-around you implemented in nodemcu/nodemcu-firmware@7dd89dd is working for me! |
@stsewd Yeah. currently it uses built in search of mkdocs. But it would be better if we could index the content to our elasticsearch index so we can provide better search result to our users. |
@safwanrahman maybe this interest you #4205 |
IIRC, the problem we have with MkDocs is there is no way to generate a context to create the I may be wrong, though. |
@humitos The json file is created with the HTML file by default. But the structure is different. We need to port our code to index the json file into our Elasticsearch. |
We need a way to dump mkdocs HTML unthemed, which is the main problem. It needs to be consistent across themes and builds. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is still valid, but blocked and/or needs a design decision |
This issue is related to #4588 |
This isn't fully closed. We are going to be indexing search data for mkdocs since next week, but not yet overriding the mkdocs search for ours. |
Hopefully this is going live next week, if someone wants to try the server side search for mkdocs projects next week, let us know via email at [email protected]. |
What are the changes MkDocs-based projects have to make to be compliant with what goes live next week? Or maybe, which work-arounds have to/can be removed next week? |
Let me explain this a little more. We used to index search data only for sphinx projects, but now we index search data for mkdocs too (search works here now https://readthedocs.org/projects/mkdocs-clone/search/?q=test&type=file&project=mkdocs-clone&version=latest for example). With the other change (to be released next week), now you can get those results inside the doc pages. It should work with all mkdocs themes that have the |
If someone is curious, this is how it looks
If you want to test this let us know via email at [email protected]. |
* Update requirements.txt for mkdocs changes * Include jquery before other js * fix-search.js doesn't seem to be needed any more, see readthedocs/readthedocs.org#1088
(Sorry for adding this as an issue @ericholscher, but we keep missing each other on IRC. If there is a better place, let me know.)
We added the
mkdocs json
command to MkDocs for RTD's to use in serverside search. Since then I have been working on clientside search support. This means we generate a JSON index in a slightly different format to work with Tipue search and thus we will potentially have two different JSON output formats which is a bit of a pain.The Tipue format looks like this: https://github.com/Tipue/Tipue-Search/blob/master/tipuesearch/tipuesearch_content.js . The key difference is that it is one file containing all pages and the key names are different but otherwise I think it contains pretty much the same data.
So, my question is, can RTD be adapted to use this format so we can drop the specific json command from MkDocs? If so, I'd be happy to make the change in the ReadTheDocs code.
The text was updated successfully, but these errors were encountered: