Allow linking to a specific tab in the documentation
authorHarmon <Harmon758@gmail.com>
Mon, 1 Nov 2021 16:14:25 +0000 (11:14 -0500)
committerHarmon <Harmon758@gmail.com>
Mon, 1 Nov 2021 16:14:25 +0000 (11:14 -0500)
docs/_static/expand_tabs.js [new file with mode: 0644]
docs/conf.py

diff --git a/docs/_static/expand_tabs.js b/docs/_static/expand_tabs.js
new file mode 100644 (file)
index 0000000..e68f693
--- /dev/null
@@ -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
index fa7f64405a4b69f04c80201ddd5ed5d81d0a48d5..d19e16c523138a36a05f13761f55af71d6313232 100644 (file)
@@ -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.