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

Update sphinx-tabs to its latest version #117

Merged
merged 4 commits into from
May 6, 2021
Merged

Conversation

humitos
Copy link
Member

@humitos humitos commented Apr 16, 2021

Use two different selectors for sphinx-tabs<2 and >=2:

  • sphinx_tabs/tabs.js
  • _static/tabs.js

If the first one is used, the old code that adds a script tag is used. If the second one (sphinx-tabs>=2) is found, we call a small chunk of code to enable the tabs.

Closes #104

@humitos humitos marked this pull request as draft April 16, 2021 13:19
@humitos humitos marked this pull request as ready for review April 16, 2021 13:31
@humitos humitos changed the title Update sphinx-tabs to its latest version Update sphinx-tabs to its latest version Apr 16, 2021
If `sphinx_tabs/tabs.js` is not found and `_static/tabs.js` is found, we trigger
the function to render the tab manually.
@astrojuanlu

This comment has been minimized.

@astrojuanlu
Copy link
Contributor

(Sorry, this comment was supposed to go to #118)

@humitos humitos requested a review from a team May 5, 2021 08:52
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 reasonable -- wishing for tests here at some point, since this feels hard to review and validate.

// Once the script has been executed, we remove it from the DOM
script.parentNode.removeChild(script);
}
var src = $('script[src$="_static/tabs.js"]');
Copy link
Member

Choose a reason for hiding this comment

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

Should probably use a different variable for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed them to older_tab_src and newer_tab_src.

@humitos
Copy link
Member Author

humitos commented May 6, 2021

wishing for tests here at some point, since this feels hard to review and validate.

I'd like to have a small test suite for JS code too. I'll ask @agjohnson or @davidfischer probably to point myself in the right direction for a nice pattern and/or to some resources to learn from.

@humitos humitos merged commit 10daace into master May 6, 2021
@humitos humitos deleted the humitos/update-sphinx-tabs branch May 6, 2021 08:21
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.

Comptability with sphinx-tabs==2.x
3 participants