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

How to hide the "Edit this page" button for the API Docs? #1254

Closed
AhmedBasem20 opened this issue Mar 21, 2023 · 2 comments
Closed

How to hide the "Edit this page" button for the API Docs? #1254

AhmedBasem20 opened this issue Mar 21, 2023 · 2 comments

Comments

@AhmedBasem20
Copy link

AhmedBasem20 commented Mar 21, 2023

The 'Edit this page' button is not functioning for the API docs pages as it redirects to a non-existent Github URL. This is because these pages are dynamically generated and do not reside in the repository. I simply want to hide that button on those specific pages. To accomplish this, I have attempted to use a short JavaScript snippet in my _static/custom.js file. However, the snippet doesn't seem to work as expected. Here's the code I'm currently using:

var githubPath = document.querySelector("div.tocsection.editthispage a").href;
var dirNames = githubPath.split('/');
if (dirNames.includes('apidoc') == true ) {
    var tocSection = document.querySelector("div.tocsection.editthispage");
    tocSection.style.display = "none";
      }

I would appreciate any assistance in resolving this issue.

@drammock
Copy link
Collaborator

The 'Edit this page' button is not functioning for the API docs pages as it redirects to a non-existent Github URL

already reported in #1237 (which will be fixed by #1246).

This is because these pages are dynamically generated and do not reside in the repository.

not exactly. It's because the commits for those pages aren't at the tip of a branch in the git history, and GitHub only allows the edit interface at branch tips. (try switching edit to blob in the URL and you'll see the pages exist on GitHub).

I simply want to hide that button on those specific pages. To accomplish this, I have attempted to use a short JavaScript snippet

I'll leave this issue open in case someone has time to help with the Javascript (I'm swamped at the moment, sorry). Would you be OK if the links just worked and pointed to an edit interface of the page on current main instead? If so I'll mark this to be closed by #1246

@AhmedBasem20
Copy link
Author

Thanks @drammock.
My case was a little different (my bad. I didn't give enough details, sorry). The API docs pages I'm referring to are generated from a Python script in conf.py. So those pages do not reside in the repository, that's why the edit button is not needed there.
I'll close this because the Javascript code worked for me. It wasn't working because I forgot to add the path in conf.py.

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

No branches or pull requests

2 participants