From: Harmon Date: Mon, 1 Nov 2021 16:14:25 +0000 (-0500) Subject: Allow linking to a specific tab in the documentation X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8ad30a2a1ca3a88e37ba23f2455fb459c01fa8a2;p=tweepy.git Allow linking to a specific tab in the documentation --- diff --git a/docs/_static/expand_tabs.js b/docs/_static/expand_tabs.js new file mode 100644 index 0000000..e68f693 --- /dev/null +++ b/docs/_static/expand_tabs.js @@ -0,0 +1,19 @@ +// Source: https://github.com/readthedocs/readthedocs.org/blob/f38fe0f48ed4fcfa715f647bbd073356effbb9ee/docs/_static/js/expand_tabs.js + +/* + * Expands a specific tab of sphinx-tabs. + * Usage: + * - docs.readthedocs.io/?tab=Name + * - docs.readthedocs.io/?tab=Name#section + * Where 'Name' is the title of the tab (case sensitive). +*/ +$( document ).ready(function() { + const urlParams = new URLSearchParams(window.location.search); + const tabName = urlParams.get('tab'); + if (tabName !== null) { + const tab = $('button.sphinx-tabs-tab:contains("' + tabName + '")'); + if (tab.length > 0) { + tab.click(); + } + } +}); \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index fa7f644..d19e16c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -150,7 +150,9 @@ html_theme = 'default' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] +html_static_path = ['_static'] + +html_js_files = ['expand_tabs.js'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format.