From b30b2e02b8517a320c4afb13f2853c97c4820a0c Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sun, 29 Jan 2023 23:07:12 +0530 Subject: [PATCH 1/9] - added keyboard shortcut for search box - Added .vscode to .gitignore --- .gitignore | 1 + assets/html/js/shortcut.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 assets/html/js/shortcut.js diff --git a/.gitignore b/.gitignore index 2e1de3f888..661d544912 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ docs/dev/ docs/build/ docs/build-pdf/ docs/site/ +.vscode \ No newline at end of file diff --git a/assets/html/js/shortcut.js b/assets/html/js/shortcut.js new file mode 100644 index 0000000000..26709c5dd2 --- /dev/null +++ b/assets/html/js/shortcut.js @@ -0,0 +1,21 @@ +// libraries: jquery +// arguments: $ + +let searchbox = $("#documenter-search-query"); +let sidebar = $(".docs-sidebar"); + +$(document).keydown(function (event) { + if ((event.ctrlKey || event.metaKey) && event.key === "/") { + if (!sidebar.hasClass("visible")) { + sidebar.addClass("visible"); + } + searchbox.focus(); + return false; + } else if (event.key === "Escape") { + if (sidebar.hasClass("visible")) { + sidebar.removeClass("visible"); + } + searchbox.blur(); + return false; + } +}); From ec10ac08dc34a9b20a5b26fc51538e1fa29a418f Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 4 Feb 2023 19:49:40 +0530 Subject: [PATCH 2/9] - Removed Jquery dependency - Changed placeholder to indicate the shortcut use - Added the change in `CHANGELOG.md` - Made the suggested edits in `.gitignore` --- .gitignore | 3 ++- CHANGELOG.md | 2 ++ assets/html/js/shortcut.js | 17 +++++++---------- src/html/HTMLWriter.jl | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 661d544912..f65ee6c1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ docs/dev/ docs/build/ docs/build-pdf/ docs/site/ -.vscode \ No newline at end of file + +.vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index fdbef4e951..0aa963b370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ * ![Enhancement][badge-enhancement] Search engine and social media link previews are now supported, with Documenter generating the relevant HTML `meta` tags. ([#1321][github-1321], [#1991][github-1991]) * ![Enhancement][badge-enhancement] `deploydocs` now supports custom tag prefixes; see section "Deploying from a monorepo" in the docs. ([#1291][github-1291], [#1792][github-1792], [#1993][github-1993]) * ![Enhancement][badge-enhancement] The `target` keyword of `deploydocs` is now required to point to a subdirectory of `root` (usually the directory where `make.jl` is located). ([#2019][github-2019]) +* ![Enhancement][badge-enhancement] Added keyboard shortcuts for search box (To focus into search box use `ctrl + /` or `cmd + /`, `Esc` to focus out of it). ([#2027][github-2027]) * ![Bugfix][badge-bugfix] Documenter now generates the correct source URLs for docstrings from other packages when the `repo` argument to `makedocs` is set (note: the source links to such docstrings only work if the external package is cloned from GitHub and added as a dev-dependency). However, this change **breaks** the case where the `repo` argument is used to override the main package/repository URL, assuming the repository is cloned from GitHub. ([#1808][github-1808]) * ![Bugfix][badge-bugfix] Documenter no longer uses the `TRAVIS_REPO_SLUG` environment variable to determine the Git remote of non-main repositories (when inferring it from the Git repository configuration has failed), which could previously lead to bad source links. ([#1881][github-1881]) * ![Bugfix][badge-bugfix] Line endings in Markdown source files are now normalized to `LF` before parsing, to work around [a bug in the Julia Markdown parser][julia-29344] where parsing is sensitive to line endings, and can therefore cause platform-dependent behavior. ([#1906][github-1906]) @@ -1192,6 +1193,7 @@ [github-2012]: https://github.com/JuliaDocs/Documenter.jl/pull/2012 [github-2018]: https://github.com/JuliaDocs/Documenter.jl/pull/2018 [github-2019]: https://github.com/JuliaDocs/Documenter.jl/pull/2019 +[github-2027]: https://github.com/JuliaDocs/Documenter.jl/pull/2027 [julia-29344]: https://github.com/JuliaLang/julia/issues/29344 diff --git a/assets/html/js/shortcut.js b/assets/html/js/shortcut.js index 26709c5dd2..ea7b6feb74 100644 --- a/assets/html/js/shortcut.js +++ b/assets/html/js/shortcut.js @@ -1,19 +1,16 @@ -// libraries: jquery -// arguments: $ +let searchbox = document.querySelector("#documenter-search-query"); +let sidebar = document.querySelector(".docs-sidebar"); -let searchbox = $("#documenter-search-query"); -let sidebar = $(".docs-sidebar"); - -$(document).keydown(function (event) { +document.addEventListener("keydown", (event) => { if ((event.ctrlKey || event.metaKey) && event.key === "/") { - if (!sidebar.hasClass("visible")) { - sidebar.addClass("visible"); + if (!sidebar.classList.contains("visible")) { + sidebar.classList.add("visible"); } searchbox.focus(); return false; } else if (event.key === "Escape") { - if (sidebar.hasClass("visible")) { - sidebar.removeClass("visible"); + if (sidebar.classList.contains("visible")) { + sidebar.classList.remove("visible"); } searchbox.blur(); return false; diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 905c0d7381..c187c131a0 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1058,7 +1058,7 @@ function render_sidebar(ctx, navnode) "#documenter-search-query.docs-search-query", :name => "q", :type => "text", - :placeholder => "Search docs", + :placeholder => "Search Docs (Press 'ctrl + /')", ], ) ) From 7c101ea3199c54740aede5a86196da37fdebccd3 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 4 Feb 2023 19:52:51 +0530 Subject: [PATCH 3/9] - Removed Jquery dependency - Changed placeholder to indicate the shortcut use - Added the change in `CHANGELOG.md` - Made the suggested edits in `.gitignore` --- .gitignore | 3 ++- CHANGELOG.md | 2 ++ assets/html/js/shortcut.js | 17 +++++++---------- src/html/HTMLWriter.jl | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 661d544912..f65ee6c1b0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ docs/dev/ docs/build/ docs/build-pdf/ docs/site/ -.vscode \ No newline at end of file + +.vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index fdbef4e951..0aa963b370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ * ![Enhancement][badge-enhancement] Search engine and social media link previews are now supported, with Documenter generating the relevant HTML `meta` tags. ([#1321][github-1321], [#1991][github-1991]) * ![Enhancement][badge-enhancement] `deploydocs` now supports custom tag prefixes; see section "Deploying from a monorepo" in the docs. ([#1291][github-1291], [#1792][github-1792], [#1993][github-1993]) * ![Enhancement][badge-enhancement] The `target` keyword of `deploydocs` is now required to point to a subdirectory of `root` (usually the directory where `make.jl` is located). ([#2019][github-2019]) +* ![Enhancement][badge-enhancement] Added keyboard shortcuts for search box (To focus into search box use `ctrl + /` or `cmd + /`, `Esc` to focus out of it). ([#2027][github-2027]) * ![Bugfix][badge-bugfix] Documenter now generates the correct source URLs for docstrings from other packages when the `repo` argument to `makedocs` is set (note: the source links to such docstrings only work if the external package is cloned from GitHub and added as a dev-dependency). However, this change **breaks** the case where the `repo` argument is used to override the main package/repository URL, assuming the repository is cloned from GitHub. ([#1808][github-1808]) * ![Bugfix][badge-bugfix] Documenter no longer uses the `TRAVIS_REPO_SLUG` environment variable to determine the Git remote of non-main repositories (when inferring it from the Git repository configuration has failed), which could previously lead to bad source links. ([#1881][github-1881]) * ![Bugfix][badge-bugfix] Line endings in Markdown source files are now normalized to `LF` before parsing, to work around [a bug in the Julia Markdown parser][julia-29344] where parsing is sensitive to line endings, and can therefore cause platform-dependent behavior. ([#1906][github-1906]) @@ -1192,6 +1193,7 @@ [github-2012]: https://github.com/JuliaDocs/Documenter.jl/pull/2012 [github-2018]: https://github.com/JuliaDocs/Documenter.jl/pull/2018 [github-2019]: https://github.com/JuliaDocs/Documenter.jl/pull/2019 +[github-2027]: https://github.com/JuliaDocs/Documenter.jl/pull/2027 [julia-29344]: https://github.com/JuliaLang/julia/issues/29344 diff --git a/assets/html/js/shortcut.js b/assets/html/js/shortcut.js index 26709c5dd2..ea7b6feb74 100644 --- a/assets/html/js/shortcut.js +++ b/assets/html/js/shortcut.js @@ -1,19 +1,16 @@ -// libraries: jquery -// arguments: $ +let searchbox = document.querySelector("#documenter-search-query"); +let sidebar = document.querySelector(".docs-sidebar"); -let searchbox = $("#documenter-search-query"); -let sidebar = $(".docs-sidebar"); - -$(document).keydown(function (event) { +document.addEventListener("keydown", (event) => { if ((event.ctrlKey || event.metaKey) && event.key === "/") { - if (!sidebar.hasClass("visible")) { - sidebar.addClass("visible"); + if (!sidebar.classList.contains("visible")) { + sidebar.classList.add("visible"); } searchbox.focus(); return false; } else if (event.key === "Escape") { - if (sidebar.hasClass("visible")) { - sidebar.removeClass("visible"); + if (sidebar.classList.contains("visible")) { + sidebar.classList.remove("visible"); } searchbox.blur(); return false; diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 905c0d7381..c187c131a0 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1058,7 +1058,7 @@ function render_sidebar(ctx, navnode) "#documenter-search-query.docs-search-query", :name => "q", :type => "text", - :placeholder => "Search docs", + :placeholder => "Search Docs (Press 'ctrl + /')", ], ) ) From 0e078757af0b60a59b623d6855752ec0152a4702 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 6 Feb 2023 12:29:49 +1300 Subject: [PATCH 4/9] Update src/html/HTMLWriter.jl --- src/html/HTMLWriter.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index c187c131a0..7b0ba17a03 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1058,7 +1058,7 @@ function render_sidebar(ctx, navnode) "#documenter-search-query.docs-search-query", :name => "q", :type => "text", - :placeholder => "Search Docs (Press 'ctrl + /')", + :placeholder => "Search docs (Press 'ctrl + /')", ], ) ) From 95a9c860fa031df61c884d521576ed7f4fca7d7d Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 6 Feb 2023 12:29:55 +1300 Subject: [PATCH 5/9] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa963b370..9703c86914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ * ![Enhancement][badge-enhancement] Search engine and social media link previews are now supported, with Documenter generating the relevant HTML `meta` tags. ([#1321][github-1321], [#1991][github-1991]) * ![Enhancement][badge-enhancement] `deploydocs` now supports custom tag prefixes; see section "Deploying from a monorepo" in the docs. ([#1291][github-1291], [#1792][github-1792], [#1993][github-1993]) * ![Enhancement][badge-enhancement] The `target` keyword of `deploydocs` is now required to point to a subdirectory of `root` (usually the directory where `make.jl` is located). ([#2019][github-2019]) -* ![Enhancement][badge-enhancement] Added keyboard shortcuts for search box (To focus into search box use `ctrl + /` or `cmd + /`, `Esc` to focus out of it). ([#2027][github-2027]) +* ![Enhancement][badge-enhancement] Added keyboard shortcuts for search box (`ctrl + /` or `cmd + /` to focus into the search box, `Esc` to focus out of it). ([#1536][github-1536], [#2027][github-2027]) * ![Bugfix][badge-bugfix] Documenter now generates the correct source URLs for docstrings from other packages when the `repo` argument to `makedocs` is set (note: the source links to such docstrings only work if the external package is cloned from GitHub and added as a dev-dependency). However, this change **breaks** the case where the `repo` argument is used to override the main package/repository URL, assuming the repository is cloned from GitHub. ([#1808][github-1808]) * ![Bugfix][badge-bugfix] Documenter no longer uses the `TRAVIS_REPO_SLUG` environment variable to determine the Git remote of non-main repositories (when inferring it from the Git repository configuration has failed), which could previously lead to bad source links. ([#1881][github-1881]) * ![Bugfix][badge-bugfix] Line endings in Markdown source files are now normalized to `LF` before parsing, to work around [a bug in the Julia Markdown parser][julia-29344] where parsing is sensitive to line endings, and can therefore cause platform-dependent behavior. ([#1906][github-1906]) From 32875ac8506f99c1acef7a46e438d5de2b6fb772 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 6 Feb 2023 12:30:38 +1300 Subject: [PATCH 6/9] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9703c86914..57b616088b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1036,6 +1036,7 @@ [github-1531]: https://github.com/JuliaDocs/Documenter.jl/issues/1531 [github-1533]: https://github.com/JuliaDocs/Documenter.jl/pull/1533 [github-1534]: https://github.com/JuliaDocs/Documenter.jl/issues/1534 +[github-1536]: https://github.com/JuliaDocs/Documenter.jl/issues/1536 [github-1537]: https://github.com/JuliaDocs/Documenter.jl/issues/1537 [github-1538]: https://github.com/JuliaDocs/Documenter.jl/pull/1538 [github-1540]: https://github.com/JuliaDocs/Documenter.jl/pull/1540 From af0433dd73c16e1ac2db8e18402ceba52735f000 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 6 Feb 2023 13:52:16 +1300 Subject: [PATCH 7/9] Update src/html/HTMLWriter.jl --- src/html/HTMLWriter.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 7b0ba17a03..0b620ab83d 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1058,7 +1058,7 @@ function render_sidebar(ctx, navnode) "#documenter-search-query.docs-search-query", :name => "q", :type => "text", - :placeholder => "Search docs (Press 'ctrl + /')", + :placeholder => "Search docs (ctrl + /)", ], ) ) From c56c1c3abb8e4883a9ef22961dc511d2788d9960 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Sun, 12 Feb 2023 16:35:19 +1300 Subject: [PATCH 8/9] Update .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4bee3e4287..653ccabec7 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ docs/dev/ docs/build/ docs/build-pdf/ docs/site/ -docs/src/release-notes.md \ No newline at end of file +docs/src/release-notes.md From 5149391f97649845408e38312ba2f18b41a66ddc Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 12 Feb 2023 14:30:35 +0100 Subject: [PATCH 9/9] Apply suggestions from code review --- CHANGELOG.md | 2 +- src/html/HTMLWriter.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd2df47bd..52253e7f2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * The `target` keyword of `deploydocs` is now required to point to a subdirectory of `root` (usually the directory where `make.jl` is located). (#2019) -* Added keyboard shortcuts for search box (`ctrl + /` or `cmd + /` to focus into the search box, `Esc` to focus out of it). (#1536), (#2027) +* Added keyboard shortcuts for search box (`Ctrl + /` or `Cmd + /` to focus into the search box, `Esc` to focus out of it). (#1536), (#2027) ### Fixed diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 0b620ab83d..adffa020f2 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1058,7 +1058,7 @@ function render_sidebar(ctx, navnode) "#documenter-search-query.docs-search-query", :name => "q", :type => "text", - :placeholder => "Search docs (ctrl + /)", + :placeholder => "Search docs (Ctrl + /)", ], ) )