-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add option html_sourcelink_suffix #2454
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
Conversation
I've added some documentation and tests. Right after that, however, I've seen that there might be a problem in sphinx/themes/basic/static/searchtools.js_t, where Any ideas how to fix this? |
I tried This PR breaks the search preview, any suggestions for how to fix this? |
Can somebody please help me with this? |
Okay, I'll take a look (maybe this weekend). |
In tk0miya@4e7e34b, I passed the original filename including extension into HTML search script. Note:
|
This PR looks good to me than #2399. |
@@ -350,9 +353,10 @@ def prune(self, filenames): | |||
for wordnames in itervalues(self._title_mapping): | |||
wordnames.intersection_update(filenames) | |||
|
|||
def feed(self, filename, title, doctree): | |||
def feed(self, docname, filename, title, doctree): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd read the error logs on Travis CI roughly. It seems some TypeError
s come from this new argument docname
.
...
File "/home/travis/build/sphinx-doc/sphinx/tests/test_search.py", line 42, in test_wordcollector
ix.feed('filename', 'title', doc)
TypeError: feed() takes exactly 5 arguments (4 given)
...
File "/home/travis/build/sphinx-doc/sphinx/sphinx/builders/websupport.py", line 79, in write_doc_serialized
self.index_page(docname, doctree, title)
File "/home/travis/build/sphinx-doc/sphinx/sphinx/builders/html.py", line 730, in index_page
self.indexer.feed(pagename, filename, title, doctree)
TypeError: feed() takes exactly 4 arguments (5 given)
And it might have caused the more errors on websupport module.
Could you check this first?
* Not tested carefully * Always adds .txt to source filename even if html_sourcelink_txt is False
I've added a missing argument in Strangely, two of them are
But @tk0miya extended this to 5 arguments. Is it possible that this somehow uses the old version? I have no clue what the other errors are about ... Any help? |
I found another implementations of
BTW, the files under sphinx/websupport/search are used for search-adapters for websupport. So we have to do following actions:
|
In addition, please check your environment before testing. please use |
Thanks for the hint with I've made the suggested changes in d27386c. I'm not really sure if everything is correct, but at least the tests are passing now. |
@tk0miya Is it OK now? |
Sorry for late response. I don't have enough time now. I'll take a look in this weekend (maybe). |
OK, thanks, take your time, there is no hurry. |
@@ -256,7 +256,7 @@ var Search = { | |||
displayNextItem(); | |||
}); | |||
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { | |||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt', | |||
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + '.txt', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line always appends .txt
. This should be replaced with html_source_suffix
.
In addition, this script fails searching if source_suffix
is .txt
. searchtools.js expects foo.txt.txt
, but sphinx generates foo.txt
because of source_suffix
equals to html_source_suffix
. I think special treatment for .txt
is not needed. Certainly .txt.txt
is ugly, but it is simple to know the path to the original file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a trivial matter, source_suffix = ['.rst', '.txt']
causes the filename conflict. Both foo.rst
and foo.txt
are copied into foo.rst.txt
and get conflicted. I know this is a spiteful example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hints, but I'm kinda lost.
How can I test this JavaScript search stuff locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always uses python -m SimpleHTTPServer 8080
command. It invokes HTTP Server locally at 8080 port. so you can access the directory through http://localhost:8080/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I added a commit that only adds .txt
if it isn't already there: 71e1aaf.
What's left to do is to change '.txt'
to the value of html_sourcelink_suffix
from conf.py
.
How do I get this from inside the JavaScript function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I tried something: 71dd8bf.
It seems to work, but I don't know if that's the right way to do it ...
Thank you for update. I confirmed this works fine. I will merge this if no objection. |
With Sphinx 1.5, this is needed by searchtools.js to display the source snippets (see sphinx-doc/sphinx#2454). With earlier Sphinx versions, this is a no-op because the undefined variable will evaluate to an empty string.
With Sphinx 1.5, this is needed by searchtools.js to display the source snippets (see sphinx-doc/sphinx#2454). With earlier Sphinx versions, this is a no-op because the undefined variable will evaluate to an empty string.
Since version 1.5.0, Sphinx is adding the source file extension to the source files it includes in the output folder. For example, when your source file extension is `rst` (specified in the config variable `source_suffix` as `[.rst]`, your index file appears in the output's source folder as `index.rst.txt`. If you use a Sphinx version lower than 1.5.0, it appears as `index.txt`. Here's the link to the PR that introduces the breaking change: sphinx-doc/sphinx#2454. The solution adjust the file name/suffix based on the Sphinx version: * If you use Sphinx >=1.5, the file name will be filename + source_file_ending + ".txt". * If you use Sphinx < 1.5, the file name will be filename + ".txt". The changes also add aconfig option that allows forcing a fallback to 2). This will help folks who use this extension for a long time and whose templates evolved accordingly.
Sphinx 1.5 introduced a problem explained in sphinx-doc/sphinx#2454 that breaks the site search box. This patch (together with a conf.py patch in the zephyr repo repairs things). Jira: INF-136 Signed-off-by: David B. Kinder <[email protected]>
Sphinx 1.5 introduced a problem explained in sphinx-doc/sphinx#2454 that breaks the site search box. This patch (together with a conf.py patch in the zephyr repo repairs things). Jira: INF-136 Signed-off-by: David B. Kinder <[email protected]>
Sphinx 1.5 introduced changes that broke the sphinx-supplied search (as explained in sphinx-doc/sphinx#2454) This patch, along with a patch in the docs-theme zephyrproject-rtos/docs-theme#10 repairs things. Jira: INF-136 Signed-off-by: David B. Kinder <[email protected]>
Updates the bundled searchtools.js to the version shipped with sphinx 1.6.5. The search looked for files called `name.txt`, but in sphinx 1.5 the filename generation changed, so the files are called `name.rst.txt` (because we use `.rst` as extension in `crate/crate`) See aslo: sphinx-doc/sphinx#2454
Updates the bundled searchtools.js to the version shipped with sphinx 1.6.5. The search looked for files called `name.txt`, but in sphinx 1.5 the filename generation changed, so the files are called `name.rst.txt` (because we use `.rst` as extension in `crate/crate`) See aslo: sphinx-doc/sphinx#2454
Updates the bundled `searchtools.js` to the version shipped with sphinx 1.6.5. The search looked for files called `name.txt`, but in sphinx 1.5 the filename generation changed, so the files are called `name.rst.txt` (because we use `.rst` as extension in `crate/crate`) See also: sphinx-doc/sphinx#2454
This is a slight variation of #2399.
This changes the current behavior because it keeps the original file extension on source links and it adds
.txt
on top of that (except if the extension is already.txt
).I will add documentation and tests soon.