Closed pseusys closed 1 year ago
There are at least a couple ways to do this on the user end (i.e., without changing the theme at all). One is to change CSS properties of the elements to display:none
on some pages, using Javascript. Another is to override the theme template and include in your override a conditional that checks against specific filenames. Here's the current template:
So you could copy that file, save it in the _templates
folder of your docs, and add a condition to that long conditional on the first line
{% if sourcename is defined and theme_use_edit_page_button==true and page_source_suffix and pagename not in my_list_of_uneditable_pages %}
Will that work for your use case?
That would've worked, but I receive the following error:
Reason: UndefinedError("'get_edit_provider_and_url' is undefined")
This is my configuration file.
oops, that variable name just changed yesterday in #1177. This is the version before that change which should be compatible with the released version of the theme:
If they are very specific files and not too many, you could always manually add some CSS rules on the page content itself (as raw css and html if using markdown, or with a "raw" directive if using RST)
Thanks a lot! I would prefer using raw
- not to depend on specific (and outdated) theme version!
Hi @drammock
I'm trying to hide the edit button of the auto-generated API docs pages.
I used javascript as you mentioned but the edit button is still there.
Could you guide me on what's maybe gone wrong there?
here is my _static/custom.js
file:
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 wonder, if it's possible to enable
Edit this page
andShow sources
buttons on some pages - and hide them on the other?Maybe using a kind of paths list (like in
exclude_patterns
) or using file metadata?