-
Notifications
You must be signed in to change notification settings - Fork 13
80 focus lost in navbar #96
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
Open
aniketsalve22
wants to merge
10
commits into
main
Choose a base branch
from
80-focus-lost-in-navbar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7c6f1b2
fix(navbar): Fixed focus lost in navbar for doxygen files
61da9d3
chore(code): updated to session storage from localstorage
17d0016
chore(navbar): Added custom js for rtd theme to keep focus in navbar …
cbf4e9a
chore(code): Updated comments
331d0d3
chore(theme-extension): Added doxysphinx-themes extension
42c9aed
chore(code): Reverted the CSS related file changes
9e1672e
chore(docs): Updated documentation
8d5d822
chore(code): Moved the static css files to extension
d49dccc
chore(code): Added extension to the package
5c8a2eb
chore(code): Re-arranged in repo extension for better packaging
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # ===================================================================================== | ||
| # C O P Y R I G H T | ||
| # ------------------------------------------------------------------------------------- | ||
| # Copyright (c) 2023 by Robert Bosch GmbH. All rights reserved. | ||
| # | ||
| # Author(s): | ||
| # - Aniket Salve, Robert Bosch GmbH | ||
| # ===================================================================================== | ||
|
|
||
| """Doxysphinx themes extension. | ||
|
|
||
| This extensions add custom javascript files depending on theme. | ||
| Currently only supporting Book and RTD theme. | ||
| """ | ||
|
|
||
| import logging | ||
| import pathlib | ||
|
|
||
| from sphinx.application import Sphinx | ||
| from sphinx.config import Config | ||
|
|
||
|
|
||
| def setup(app: Sphinx): | ||
| """Setups up the doxysphinx themes extension.""" | ||
| app.connect("config-inited", doxysphinx_theme_extension) | ||
| return {"parallel_read_safe": True, "parallel_write_safe": True, "version": "0.1.0"} | ||
|
|
||
|
|
||
| def doxysphinx_theme_extension(app: Sphinx, config: Config): | ||
| """Add custom javascript files specific to theme and set theme options. | ||
|
|
||
| :param app: Sphinx app | ||
| :param config: Sphinx config | ||
| """ | ||
| current_file_path = pathlib.Path(__file__).parent.resolve() | ||
|
|
||
| config.html_static_path.append(str(current_file_path) + "/_static/") | ||
|
|
||
| if config.html_theme == "sphinx_book_theme": | ||
| app.add_js_file("js/customize-navbar-book.js") | ||
| app.add_css_file("css/sphinx-book-theme-custom.css") | ||
|
|
||
| elif config.html_theme == "sphinx_rtd_theme": | ||
| app.add_js_file("js/customize-navbar-rtd.js") | ||
| app.add_css_file("css/sphinx-rtd-theme-custom.css") | ||
| if config.html_theme_options["collapse_navigation"]: | ||
| logging.warning("We are forcefully setting 'collapse_navigation' flag to 'False' in RTD theme options") | ||
| config.html_theme_options["collapse_navigation"] = False | ||
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions
75
sphinx_extensions/doxysphinx_theme/_static/js/customize-navbar-book.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
|
|
||
| /** | ||
| ===================================================================================== | ||
| C O P Y R I G H T | ||
| ------------------------------------------------------------------------------------- | ||
| Copyright (c) 2023 by Robert Bosch GmbH. All rights reserved. | ||
|
|
||
| Author(s): | ||
| - Aniket Salve, Robert Bosch Gmbh | ||
| ===================================================================================== | ||
| */ | ||
|
|
||
|
|
||
| /** | ||
| * This function stores and updates the session store with active href | ||
| * If href is not present in nav bar then last state for session storage | ||
| * is shown as active state in navbar | ||
| * | ||
| * The classes are customized for sphinx-book-theme | ||
| */ | ||
| function findCurrentRoute() { | ||
|
|
||
| if (window.sessionStorage.getItem("href") == null) { | ||
| window.sessionStorage.setItem("href", window.location.href); | ||
| } | ||
|
|
||
| if (document.querySelector("li.active")) { | ||
| window.sessionStorage.setItem("href", window.location.href); | ||
| return; | ||
| } else { | ||
| var lastActiveNav = window.sessionStorage.getItem("href"); | ||
| var allTags = document.querySelectorAll("li"); | ||
| for (let i = 0; i < allTags.length; i++) { | ||
| if (allTags[i].getElementsByTagName("a")[0].href == lastActiveNav) { | ||
| allTags[i].getElementsByTagName("a")[0].classList.add("current"); | ||
| allTags[i].classList.add("current"); | ||
| allTags[i].classList.add("active"); | ||
| recursiveParentClassAppend(allTags[i].parentNode, false); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * This function recursively parses the parent nodes | ||
| * Adds current class to UL tags | ||
| * Adds current and active classes to LI tags | ||
| * | ||
| * For all 2nd level and about parent UL nodes, the corresponding | ||
| * input tag is checked so that the navbar is expanded. This is achieved using flag | ||
| * | ||
| * @param {ParentNode | null} element Parent node of last active LI tag | ||
| * @param {Boolean} flag flag to check if input should be checked or not | ||
| */ | ||
| function recursiveParentClassAppend(element, flag) { | ||
| if (element.nodeName == "UL") { | ||
| if (flag && element.getElementsByTagName("input")) { | ||
| element.getElementsByTagName("input")[0].setAttribute("checked", ""); | ||
| } | ||
| element.classList.add("current") | ||
| if (element.parentNode.nodeName == "LI") { | ||
| element.parentNode.classList.add("current"); | ||
| element.parentNode.classList.add("active"); | ||
| recursiveParentClassAppend(element.parentNode.parentNode, true); | ||
| } | ||
| else { | ||
| return; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $(document).ready(function () { | ||
| findCurrentRoute(); | ||
| }); |
76 changes: 76 additions & 0 deletions
76
sphinx_extensions/doxysphinx_theme/_static/js/customize-navbar-rtd.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
|
|
||
| /** | ||
| ===================================================================================== | ||
| C O P Y R I G H T | ||
| ------------------------------------------------------------------------------------- | ||
| Copyright (c) 2023 by Robert Bosch GmbH. All rights reserved. | ||
|
|
||
| Author(s): | ||
| - Aniket Salve, Robert Bosch Gmbh | ||
| ===================================================================================== | ||
| */ | ||
|
|
||
|
|
||
| /** | ||
| * This function stores and updates the session store with active href | ||
| * If href is not present in nav bar then last state for session storage | ||
| * is shown as active state in navbar | ||
| * | ||
| * The classes are customized for sphinx-rtd-theme | ||
| */ | ||
| function findCurrentRoute() { | ||
|
|
||
| if (window.sessionStorage.getItem("href") == null) { | ||
| window.sessionStorage.setItem("href", window.location.href); | ||
| } | ||
|
|
||
| if (document.querySelector("li.current")) { | ||
| window.sessionStorage.setItem("href", window.location.href); | ||
| return; | ||
| } else { | ||
| var lastActiveNav = window.sessionStorage.getItem("href"); | ||
| var allTags = document.querySelectorAll("li"); | ||
| for (let i = 0; i < allTags.length; i++) { | ||
| console.log(allTags[i].getElementsByTagName("a")[0].href); | ||
| if (allTags[i].getElementsByTagName("a")[0].href == lastActiveNav) { | ||
| allTags[i].getElementsByTagName("a")[0].classList.add("current"); | ||
| allTags[i].getElementsByTagName("a")[0].setAttribute("aria-expanded", "true") | ||
| allTags[i].classList.add("current"); | ||
| allTags[i].setAttribute("aria-expanded", "true") | ||
| recursiveParentClassAppend(allTags[i].parentNode, true); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * This function recursively parses the parent nodes | ||
| * Adds current class to UL tags | ||
| * Adds current class to LI tags | ||
| * Adds aria-expanded attribute to UL and LI tags | ||
| * | ||
| * For all 2nd level and about parent UL nodes, the corresponding | ||
| * input tag is checked so that the navbar is expanded. This is achieved using flag | ||
| * | ||
| * @param {ParentNode | null} element Parent node of last active LI tag | ||
| * @param {Boolean} flag flag to check if input should be checked or not | ||
| */ | ||
| function recursiveParentClassAppend(element, flag) { | ||
| if (element.nodeName == "UL") { | ||
| element.classList.add("current") | ||
| element.setAttribute("aria-expanded", "true") | ||
| if (element.parentNode.nodeName == "LI") { | ||
| element.parentNode.classList.add("current"); | ||
| element.parentNode.setAttribute("aria-expanded", "true") | ||
| recursiveParentClassAppend(element.parentNode.parentNode, true); | ||
| } | ||
| else { | ||
| return; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $(document).ready(function () { | ||
| findCurrentRoute(); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.