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

Support searchtools override regardless of Sphinx version #26

Merged
merged 3 commits into from
May 10, 2017

Conversation

agjohnson
Copy link
Contributor

This takes the underlying searchtools.js_t out of the Sphinx distribution
path, patches it, and then fills the context and parses it as a templated
javascript file. This allows us to remove the script initialization on all
versions of this file.

The initialization block on searchtools.js_t has not changed in 10 years, so
this method should be safe. If the block changes in the future, tests will grab
this as we add new versions of Sphinx to our testing.

This reorganizes some repetitive code and cleans up a few other pieces as well:

File copying is linked to the standard copy_static_files that is run from
the builder. Running from an event on build finished was producing files without
the template context. This is because build-finished is always triggered, but
the static files are not always copied (and therefore did not have the same
template context?)

Fixes #25
Refs readthedocs/readthedocs.org#2708

This takes the underlying searchtools.js_t out of the Sphinx distribution
path, patches it, and then fills the context and parses it as a templated
javascript file. This allows us to remove the script initialization on all
versions of this file.

The initialization block on searchtools.js_t has not changed in 10 years, so
this method should be safe. If the block changes in the future, tests will grab
this as we add new versions of Sphinx to our testing.

This reorganizes some repetitive code and cleans up a few other pieces as well:

File copying is linked to the standard copy_static_files that is run from
the builder. Running from an event on build finished was producing files without
the template context. This is because build-finished is always triggered, but
the static files are not always copied (and therefore did not have the same
template context?)

Fixes #25
Refs readthedocs/readthedocs.org#2708
@agjohnson agjohnson force-pushed the fix-search-sphinx-15 branch from 14f7f5f to 0d89eb5 Compare May 3, 2017 18:18
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I don't fully understand the regex/init parts, so that should probably be documented somewhere in the code or docs, not just in the PR text.


static_override_files = [
'readthedocs-dynamic-include.js_t',
'readthedocs-data.js_t',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These aren't actually overrides -- it seems we aren't overriding any included JS anymore except for searchtools. Not sure its worth renaming, but feels like old verbage.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, Sphinx builders already have copy_static_files and a copy_extra_files, so these are overrides in that they'll clobber anything set up by copy_static_files. I'll think about this a bit more

yield app
finally:
shutil.rmtree('_build')
os.chdir('../..')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should just package this up as a package. We have it scattered like 10 places around all our projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a sphinx-testing which is this -- some of the utility test functions broken out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye -- are we doing something different than that, or just not worth adding the dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had time to play around with sphinx-testing, i've only known of its existence. It would probably make sense to become acquainted with it and standardize on it. Sphinx core, and to a subset sphinx-testing, have some better patterns for testing doctress/etc.

@agjohnson
Copy link
Contributor Author

Okay, renamed some of this with a2355c4 and extended testing support to Sphinx 1.6 beta releases

@agjohnson agjohnson merged commit 6d593c7 into master May 10, 2017
@agjohnson agjohnson deleted the fix-search-sphinx-15 branch May 10, 2017 00:35
ghost pushed a commit to airbnb/streamalert that referenced this pull request May 12, 2017
Search is broken against on ReadTheDocs.

Supposedly, this is now addressed via readthedocs/readthedocs-sphinx-ext#26

Removing version pinning to give it a try
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