Skip to content

ENH: Solution for issue #39859 | Added documentation source link to each page #44783

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions doc/_templates/sidebar-nav-bs.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item active">
{% if pagename.startswith("reference") %}
{{ generate_nav_html("sidebar", maxdepth=4, collapse=True, includehidden=True, titles_only=True) }}
{% else %}
{{ generate_nav_html("sidebar", maxdepth=4, collapse=False, includehidden=True, titles_only=True) }}
{% endif %}
</div>
</nav>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<script type="text/javascript">
/* This method gets the current href of the source doc link, appends the
* path of the github source doc page after "source/" and replaces the .html
* extension with .rst. This combined new href will take the user to the
* source documentation on Github where they can edit the docs.
*/
function get_and_set_href() {
let url = window.location.href;
let link = document.getElementById("source_doc_link");
let curr_href = link.getAttribute('href');

// Parses through the url to get the docs path
let path = url.substring(url.lastIndexOf("source/") + 7, url.lastIndexOf(".html"))
let extension = ".rst"

link.setAttribute('href', curr_href + path + extension)
}
</script>

<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<div class="bd-toc-item active">
{% if pagename.startswith("reference") %}
{{ generate_nav_html("sidebar", maxdepth=4, collapse=True, includehidden=True, titles_only=True) }}
{% else %}
{{ generate_nav_html("sidebar", maxdepth=4, collapse=False, includehidden=True, titles_only=True) }}
{% endif %}
<div>
<a id="source_doc_link" class="d-flex align-items-center"
style="padding-left:15px;" onclick="get_and_set_href()"
href="https://github.com/pandas-dev/pandas/tree/master/doc/source/">
Source Documentation</a>
</div>
</div>
</nav>

</body>
</html>