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

80 focus lost in navbar #96

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

aniketsalve22
Copy link
Collaborator

Added custom JS for rtd theme and books theme in order to maintain the last navigation state highlighted in navbar when doxygen files are opened

Aniket Salve(XC-DX/EPG2) added 4 commits March 8, 2023 15:58
* renamed file
* updated conf.py to load corresponding navbar js
* Added comments

Signed-off-by: Aniket Salve(XC-DX/EPG2) <[email protected]>
…if doxygen files are opened

* Updated rtd theme options

Signed-off-by: Aniket Salve(XC-DX/EPG2) <[email protected]>
Signed-off-by: Aniket Salve(XC-DX/EPG2) <[email protected]>
@aniketsalve22 aniketsalve22 linked an issue Mar 20, 2023 that may be closed by this pull request
Aniket Salve(XC-DX/EPG2) added 2 commits March 30, 2023 12:01
@aniketsalve22 aniketsalve22 self-assigned this Mar 30, 2023
Signed-off-by: Aniket Salve(XC-DX/EPG2) <[email protected]>
sphinx_extensions/doxysphinx_theme/__init__.py Outdated Show resolved Hide resolved
sphinx_extensions/doxysphinx_theme/__init__.py Outdated Show resolved Hide resolved
Comment on lines 38 to 43
if config.html_theme == "sphinx_book_theme":
app.add_js_file("js/customize-navbar-book.js")

elif config.html_theme == "sphinx_rtd_theme":
app.add_js_file("js/customize-navbar-rtd.js")
config.html_theme_options["collapse_navigation"] = False
Copy link
Contributor

@Maetveis Maetveis Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for being nosey here, but could there be some kind of explicit option to get these files?

For ROCm documentation our theme is a slightly modified version of the Sphinx Book Theme (custom headers and footers), and I'm certain the js file for that theme would work for us as well, so it would be nice if we could enable this fix somehow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning to provide these files as part of an extension which will be part of Doxysphinx. So hopefully you won't need to add anything manually.

Copy link
Contributor

@Maetveis Maetveis Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant is the current logic wouldn't work for us because config.html_theme wouldn't be sphinx_rtd_theme, so it would be good to have another way to enable this.

Copy link
Contributor

@mb-emag mb-emag Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Maetveis So you have an own version of the sphinx book theme with a different name, e.g. "sphinx-book-theme-custom" right? In that case as you said his extension won't do anything for you.

But you could still use the jsfile as it's in the doxysphinx-theme package directory.
Maybe a little bit cumbersome to reference though, however here's a rough sketch of the idea (untested!):

#<conf.py>
from pathlib import Path
from importlib.resources import files
# ...
patch_js_path = Path(files("doxysphinx_theme")) / "_static/js/customize-navbar-book.js"
html_theme_options = {
  'extra_scripts': [str(patch_js_path)]
}

But this might be only working in python 3.11+.

Copy link
Contributor

@Maetveis Maetveis Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's exactly what we have.

I think I'll be able to make something like that work, the only slight issue with it is that I need to "know" implementation details of doxysphinx, I guess that is a price for having "forked" a theme.

I'll try this out and maybe do a PR if I come up with a way to have less coupling. Thank you for the help.

Signed-off-by: Aniket Salve(XC-DX/EPG2) <[email protected]>
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

Successfully merging this pull request may close these issues.

Focus lost in navbar
3 participants