Skip to content

Commit 0ef1123

Browse files
committed
Solution for issue pandas-dev#39859: Added documentation source link to each page
1 parent bdff214 commit 0ef1123

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

doc/_templates/sidebar-nav-bs.html

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1-
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
2-
<div class="bd-toc-item active">
3-
{% if pagename.startswith("reference") %}
4-
{{ generate_nav_html("sidebar", maxdepth=4, collapse=True, includehidden=True, titles_only=True) }}
5-
{% else %}
6-
{{ generate_nav_html("sidebar", maxdepth=4, collapse=False, includehidden=True, titles_only=True) }}
7-
{% endif %}
8-
</div>
9-
</nav>
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
</head>
8+
<body>
9+
10+
<script type="text/javascript">
11+
/* This method gets the current href of the source doc link, appends the
12+
* path of the github source doc page after "source/" and replaces the .html
13+
* extension with .rst. This combined new href will take the user to the
14+
* source documentation on Github where they can edit the docs.
15+
*/
16+
function get_and_set_href() {
17+
let url = window.location.href;
18+
let link = document.getElementById("source_doc_link");
19+
let curr_href = link.getAttribute('href');
20+
21+
// Parses through the url to get the docs path
22+
let path = url.substring(url.lastIndexOf("source/") + 7, url.lastIndexOf(".html"))
23+
let extension = ".rst"
24+
25+
link.setAttribute('href', curr_href + path + extension)
26+
}
27+
</script>
28+
29+
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
30+
<div class="bd-toc-item active">
31+
{% if pagename.startswith("reference") %}
32+
{{ generate_nav_html("sidebar", maxdepth=4, collapse=True, includehidden=True, titles_only=True) }}
33+
{% else %}
34+
{{ generate_nav_html("sidebar", maxdepth=4, collapse=False, includehidden=True, titles_only=True) }}
35+
{% endif %}
36+
<div>
37+
<a id="source_doc_link" class="d-flex align-items-center"
38+
style="padding-left:15px;" onclick="get_and_set_href()"
39+
href="https://github.com/pandas-dev/pandas/tree/master/doc/source/">
40+
Source Documentation</a>
41+
</div>
42+
</div>
43+
</nav>
44+
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)