From b30b2e02b8517a320c4afb13f2853c97c4820a0c Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sun, 29 Jan 2023 23:07:12 +0530 Subject: [PATCH 01/18] - 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 02/18] - 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 03/18] - 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 04/18] 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 05/18] 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 06/18] 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 07/18] 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 08/18] 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 09/18] 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 + /)", ], ) ) From 3cf8450e66156a0a3e10f65cffabbe4ded004c4f Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sun, 12 Mar 2023 23:27:02 +0530 Subject: [PATCH 10/18] - Adding padding to menu's element on-hover --- assets/html/scss/documenter/layout/_sidebar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/html/scss/documenter/layout/_sidebar.scss b/assets/html/scss/documenter/layout/_sidebar.scss index 056d9abc80..8fc5c4fca0 100644 --- a/assets/html/scss/documenter/layout/_sidebar.scss +++ b/assets/html/scss/documenter/layout/_sidebar.scss @@ -205,7 +205,7 @@ .tocitem { width: 100%; - padding: 0; + padding: 0.3rem; &::before { content: "⚬"; From 68c3a1c0f2823c3cd53aab8e91777353f7bfdc23 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 18 Mar 2023 15:23:23 +0530 Subject: [PATCH 11/18] - Issue #1393 - Adding collapse/expand funcitonality to individual article blocks - Adding collapse/expand all functionality --- assets/html/js/collapse.js | 39 +++++++++++++++++++ .../documenter/components/_docstring.scss | 4 ++ assets/html/scss/documenter/layout/_main.scss | 3 ++ src/html/HTMLWriter.jl | 7 ++++ 4 files changed, 53 insertions(+) create mode 100644 assets/html/js/collapse.js diff --git a/assets/html/js/collapse.js b/assets/html/js/collapse.js new file mode 100644 index 0000000000..ed92ed5bc5 --- /dev/null +++ b/assets/html/js/collapse.js @@ -0,0 +1,39 @@ +// libraries: jquery +// arguments: $ + +var is_expanded = true; + +$(document).on("click", ".docstring header", function () { + if ($(this).siblings("section").is(":visible")) { + $(this) + .find(".docstring-article-toggle-button") + .removeClass("fa-chevron-up") + .addClass("fa-chevron-down"); + $(this).find(".docstring-article-toggle-button").prop("title", "Expand article"); + } else { + $(this) + .find(".docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-up"); + $(this).find(".docstring-article-toggle-button").prop("title", "Collapse article"); + } + $(this).siblings("section").slideToggle(); +}); + +$(document).on("click", ".docs-article-toggle-button", function () { + if (is_expanded) { + $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); + $(".docstring-article-toggle-button").removeClass("fa-chevron-up").addClass("fa-chevron-down"); + $(this).prop("title", "Expand all Articles"); + $(".docstring-article-toggle-button").prop("title", "Expand article"); + $(".docstring section").slideUp(); + is_expanded = false; + } else { + $(this).prop("title", "Collapse all Articles"); + $(".docstring-article-toggle-button").prop("title", "Collapse article"); + $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); + $(".docstring-article-toggle-button").removeClass("fa-chevron-down").addClass("fa-chevron-up"); + $(".docstring section").slideDown(); + is_expanded = true; + } +}); diff --git a/assets/html/scss/documenter/components/_docstring.scss b/assets/html/scss/documenter/components/_docstring.scss index 719d60fb7a..32e56dd940 100644 --- a/assets/html/scss/documenter/components/_docstring.scss +++ b/assets/html/scss/documenter/components/_docstring.scss @@ -21,6 +21,10 @@ background-color: transparent; } + .docstring-article-toggle-button { + padding: 0.2rem 0.2rem 0.2rem 0; + } + .docstring-binding { margin-right: 0.3em; } diff --git a/assets/html/scss/documenter/layout/_main.scss b/assets/html/scss/documenter/layout/_main.scss index 365e1611af..8443667508 100644 --- a/assets/html/scss/documenter/layout/_main.scss +++ b/assets/html/scss/documenter/layout/_main.scss @@ -69,6 +69,9 @@ .docs-navbar-link { margin: auto 0.5rem auto 0.5rem; } + .docs-article-toggle-button { + padding: 0.2rem; + } @include touch { .docs-navbar-link { margin: auto 0.75rem auto 0.75rem; diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 6de0429b79..5789aec3fa 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1212,6 +1212,12 @@ function render_navbar(ctx, navnode, edit_page_link::Bool) ) end + # Collapse/Expand All articles toggle + push!(navbar_right.nodes, a[ + "#documenter-article-toggle-button.docs-article-toggle-button.fas.fa-chevron-up", + :href=>"javascript:;", :title=>"Collapse all Articles", + ]) + # Settings cog push!(navbar_right.nodes, a[ "#documenter-settings-button.docs-settings-button.docs-navbar-link.fas.fa-cog", @@ -1622,6 +1628,7 @@ function domify(dctx::DCtx, mdast_node::Node, node::Documenter.DocsNode) article[".docstring"]( header( + a[".docstring-article-toggle-button.fas.fa-chevron-up", :href=>"javascript:;", :title=>"Collapse article"], a[".docstring-binding", :id=>node.anchor.id, :href=>"#$(node.anchor.id)"](code("$(node.object.binding)")), " — ", # — span[".docstring-category"]("$(Documenter.doccat(node.object))") From 37087e3b01c3dd2f95143a6eade552e9f5967d9a Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 18 Mar 2023 16:11:04 +0530 Subject: [PATCH 12/18] - Removed lingering code from PR #2065 --- assets/html/scss/documenter/layout/_sidebar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/html/scss/documenter/layout/_sidebar.scss b/assets/html/scss/documenter/layout/_sidebar.scss index 935faec426..cae02cffd1 100644 --- a/assets/html/scss/documenter/layout/_sidebar.scss +++ b/assets/html/scss/documenter/layout/_sidebar.scss @@ -207,7 +207,7 @@ .tocitem { width: 100%; - padding: 0.3rem; + padding: 0; &::before { content: "⚬"; From 1123a9e64446fa946e5cee50320006cb79c38472 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 18 Mar 2023 16:24:30 +0530 Subject: [PATCH 13/18] - Fixed navbar icon gap - Complied scss into css --- assets/html/scss/documenter/layout/_main.scss | 5 ++--- assets/html/themes/documenter-dark.css | 6 +++++- assets/html/themes/documenter-light.css | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/assets/html/scss/documenter/layout/_main.scss b/assets/html/scss/documenter/layout/_main.scss index 8443667508..c1c28648de 100644 --- a/assets/html/scss/documenter/layout/_main.scss +++ b/assets/html/scss/documenter/layout/_main.scss @@ -59,6 +59,8 @@ display: inline-block; } white-space: nowrap; + gap: 1rem; + align-items: center; .docs-label { padding: 0; margin-left: 0.3em; @@ -69,9 +71,6 @@ .docs-navbar-link { margin: auto 0.5rem auto 0.5rem; } - .docs-article-toggle-button { - padding: 0.2rem; - } @include touch { .docs-navbar-link { margin: auto 0.75rem auto 0.75rem; diff --git a/assets/html/themes/documenter-dark.css b/assets/html/themes/documenter-dark.css index d37acf0748..287e890490 100644 --- a/assets/html/themes/documenter-dark.css +++ b/assets/html/themes/documenter-dark.css @@ -8119,6 +8119,8 @@ html.theme--documenter-dark { border-bottom: 1px solid #5e6d6f; } html.theme--documenter-dark .docstring > header code { background-color: transparent; } + html.theme--documenter-dark .docstring > header .docstring-article-toggle-button { + padding: 0.2rem 0.2rem 0.2rem 0; } html.theme--documenter-dark .docstring > header .docstring-binding { margin-right: 0.3em; } html.theme--documenter-dark .docstring > header .docstring-category { @@ -8235,7 +8237,9 @@ html.theme--documenter-dark { flex-grow: 1; } html.theme--documenter-dark #documenter .docs-main header.docs-navbar .docs-right { display: flex; - white-space: nowrap; } + white-space: nowrap; + gap: 1rem; + align-items: center; } html.theme--documenter-dark #documenter .docs-main header.docs-navbar .docs-right .docs-icon, html.theme--documenter-dark #documenter .docs-main header.docs-navbar .docs-right .docs-label, html.theme--documenter-dark #documenter .docs-main header.docs-navbar .docs-right .docs-sidebar-button { display: inline-block; } html.theme--documenter-dark #documenter .docs-main header.docs-navbar .docs-right .docs-label { diff --git a/assets/html/themes/documenter-light.css b/assets/html/themes/documenter-light.css index 78650ea5a9..4ece91d4e9 100644 --- a/assets/html/themes/documenter-light.css +++ b/assets/html/themes/documenter-light.css @@ -8062,6 +8062,8 @@ pre { border-bottom: 1px solid #dbdbdb; } .docstring > header code { background-color: transparent; } + .docstring > header .docstring-article-toggle-button { + padding: 0.2rem 0.2rem 0.2rem 0; } .docstring > header .docstring-binding { margin-right: 0.3em; } .docstring > header .docstring-category { @@ -8202,7 +8204,9 @@ li.no-marker { flex-grow: 1; } #documenter .docs-main header.docs-navbar .docs-right { display: flex; - white-space: nowrap; } + white-space: nowrap; + gap: 1rem; + align-items: center; } #documenter .docs-main header.docs-navbar .docs-right .docs-icon, #documenter .docs-main header.docs-navbar .docs-right .docs-label, #documenter .docs-main header.docs-navbar .docs-right .docs-sidebar-button { display: inline-block; } #documenter .docs-main header.docs-navbar .docs-right .docs-label { From bcfcf5adcbb1993eb6eda12516a2c0dcf67adc94 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 18 Mar 2023 17:23:30 +0530 Subject: [PATCH 14/18] - Updated `fas` => `fa-solid` due to font awesome version bump --- src/html/HTMLWriter.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index ce30c564f5..ee4d4b78df 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1214,7 +1214,7 @@ function render_navbar(ctx, navnode, edit_page_link::Bool) # Collapse/Expand All articles toggle push!(navbar_right.nodes, a[ - "#documenter-article-toggle-button.docs-article-toggle-button.fas.fa-chevron-up", + "#documenter-article-toggle-button.docs-article-toggle-button.fa-solid.fa-chevron-up", :href=>"javascript:;", :title=>"Collapse all Articles", ]) @@ -1628,7 +1628,7 @@ function domify(dctx::DCtx, mdast_node::Node, node::Documenter.DocsNode) article[".docstring"]( header( - a[".docstring-article-toggle-button.fas.fa-chevron-up", :href=>"javascript:;", :title=>"Collapse article"], + a[".docstring-article-toggle-button.fa-solid.fa-chevron-up", :href=>"javascript:;", :title=>"Collapse article"], a[".docstring-binding", :id=>node.anchor.id, :href=>"#$(node.anchor.id)"](code("$(node.object.binding)")), " — ", # — span[".docstring-category"]("$(Documenter.doccat(node.object))") From 4c2516d1603da85c03147687ca8dad924473dea5 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sun, 9 Apr 2023 17:06:40 +0530 Subject: [PATCH 15/18] - Shifted toggle button at last position in navbar - Added `>` as a indication instead of `^` for articles - Changes in `collpase.js` - Changed cursor to pointer when hovering over articles --- assets/html/js/collapse.js | 48 ++++++++++++------- .../documenter/components/_docstring.scss | 1 + assets/html/themes/documenter-dark.css | 1 + assets/html/themes/documenter-light.css | 1 + src/html/HTMLWriter.jl | 14 +++--- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/assets/html/js/collapse.js b/assets/html/js/collapse.js index ed92ed5bc5..cb6ebb367f 100644 --- a/assets/html/js/collapse.js +++ b/assets/html/js/collapse.js @@ -1,39 +1,55 @@ // libraries: jquery // arguments: $ -var is_expanded = true; +var isExpanded = true; $(document).on("click", ".docstring header", function () { + let articleToggleTitle = "Expand article"; + if ($(this).siblings("section").is(":visible")) { $(this) .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-up") - .addClass("fa-chevron-down"); - $(this).find(".docstring-article-toggle-button").prop("title", "Expand article"); + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); } else { $(this) .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-up"); - $(this).find(".docstring-article-toggle-button").prop("title", "Collapse article"); + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); + + articleToggleTitle = "Collapse article"; } + + $(this).find(".docstring-article-toggle-button").prop("title", articleToggleTitle); $(this).siblings("section").slideToggle(); }); $(document).on("click", ".docs-article-toggle-button", function () { - if (is_expanded) { + let articleToggleTitle = "Expand article"; + let navArticleToggleTitle = "Expand all Articles"; + + if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(".docstring-article-toggle-button").removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(this).prop("title", "Expand all Articles"); - $(".docstring-article-toggle-button").prop("title", "Expand article"); + $(".docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); + + isExpanded = false; + $(".docstring section").slideUp(); - is_expanded = false; } else { - $(this).prop("title", "Collapse all Articles"); - $(".docstring-article-toggle-button").prop("title", "Collapse article"); $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $(".docstring-article-toggle-button").removeClass("fa-chevron-down").addClass("fa-chevron-up"); + $(".docstring-article-toggle-button") + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); + + isExpanded = true; + articleToggleTitle = "Collapse article"; + navArticleToggleTitle = "Collapse all Articles"; + $(".docstring section").slideDown(); - is_expanded = true; } + + $(this).prop("title", navArticleToggleTitle); + $(".docstring-article-toggle-button").prop("title", articleToggleTitle); }); diff --git a/assets/html/scss/documenter/components/_docstring.scss b/assets/html/scss/documenter/components/_docstring.scss index 32e56dd940..8ef1d986c4 100644 --- a/assets/html/scss/documenter/components/_docstring.scss +++ b/assets/html/scss/documenter/components/_docstring.scss @@ -7,6 +7,7 @@ max-width: 100%; > header { + cursor: pointer; display: flex; flex-grow: 1; align-items: stretch; diff --git a/assets/html/themes/documenter-dark.css b/assets/html/themes/documenter-dark.css index 628a9baff9..60553c979d 100644 --- a/assets/html/themes/documenter-dark.css +++ b/assets/html/themes/documenter-dark.css @@ -8109,6 +8109,7 @@ html.theme--documenter-dark { box-shadow: none; max-width: 100%; } html.theme--documenter-dark .docstring > header { + cursor: pointer; display: flex; flex-grow: 1; align-items: stretch; diff --git a/assets/html/themes/documenter-light.css b/assets/html/themes/documenter-light.css index fcd46a7f7d..dececec89b 100644 --- a/assets/html/themes/documenter-light.css +++ b/assets/html/themes/documenter-light.css @@ -8052,6 +8052,7 @@ pre { box-shadow: 2px 2px 3px rgba(10, 10, 10, 0.1); max-width: 100%; } .docstring > header { + cursor: pointer; display: flex; flex-grow: 1; align-items: stretch; diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index fda0899923..d5687759e5 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1219,18 +1219,18 @@ function render_navbar(ctx, navnode, edit_page_link::Bool) ) end - # Collapse/Expand All articles toggle - push!(navbar_right.nodes, a[ - "#documenter-article-toggle-button.docs-article-toggle-button.fa-solid.fa-chevron-up", - :href=>"javascript:;", :title=>"Collapse all Articles", - ]) - # Settings cog push!(navbar_right.nodes, a[ "#documenter-settings-button.docs-settings-button.docs-navbar-link.fa-solid.fa-gear", :href => "#", :title => "Settings", ]) + # Collapse/Expand All articles toggle + push!(navbar_right.nodes, a[ + "#documenter-article-toggle-button.docs-article-toggle-button.fa-solid.fa-chevron-up", + :href=>"javascript:;", :title=>"Collapse all Articles", + ]) + # Construct the main
node that should be the first element in div.docs-main header[".docs-navbar"](navbar_left, breadcrumb, navbar_right) end @@ -1629,7 +1629,7 @@ function domify(dctx::DCtx, mdast_node::Node, node::Documenter.DocsNode) article[".docstring"]( header( - a[".docstring-article-toggle-button.fa-solid.fa-chevron-up", :href=>"javascript:;", :title=>"Collapse article"], + a[".docstring-article-toggle-button.fa-solid.fa-chevron-down", :href=>"javascript:;", :title=>"Collapse article"], a[".docstring-binding", :id=>node.anchor.id, :href=>"#$(node.anchor.id)"](code("$(node.object.binding)")), " — ", # — span[".docstring-category"]("$(Documenter.doccat(node.object))") From d6e311404c02a9fc62188c1c4fa0afd9381c5452 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 15 Apr 2023 20:07:31 +0530 Subject: [PATCH 16/18] - Add a CHANGELOG entry for this feature addition - Updated title strings as per the feedback --- CHANGELOG.md | 2 ++ assets/html/js/collapse.js | 12 ++++++------ .../html/scss/documenter/components/_docstring.scss | 1 + assets/html/themes/documenter-dark.css | 1 + assets/html/themes/documenter-light.css | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c1d8cd22..6109f43ed8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Move the mobile layout sidebar toggle (hamburger) from the right side to the left side. (#1312, #2076) +* Added the ability to expand/collapse individual as well as all docstrings. (#1393) + ### Fixed * 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) diff --git a/assets/html/js/collapse.js b/assets/html/js/collapse.js index cb6ebb367f..c7918f83e8 100644 --- a/assets/html/js/collapse.js +++ b/assets/html/js/collapse.js @@ -4,7 +4,7 @@ var isExpanded = true; $(document).on("click", ".docstring header", function () { - let articleToggleTitle = "Expand article"; + let articleToggleTitle = "Expand docstring"; if ($(this).siblings("section").is(":visible")) { $(this) @@ -17,7 +17,7 @@ $(document).on("click", ".docstring header", function () { .removeClass("fa-chevron-right") .addClass("fa-chevron-down"); - articleToggleTitle = "Collapse article"; + articleToggleTitle = "Collapse docstring"; } $(this).find(".docstring-article-toggle-button").prop("title", articleToggleTitle); @@ -25,8 +25,8 @@ $(document).on("click", ".docstring header", function () { }); $(document).on("click", ".docs-article-toggle-button", function () { - let articleToggleTitle = "Expand article"; - let navArticleToggleTitle = "Expand all Articles"; + let articleToggleTitle = "Expand docstring"; + let navArticleToggleTitle = "Expand all docstrings"; if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); @@ -44,8 +44,8 @@ $(document).on("click", ".docs-article-toggle-button", function () { .addClass("fa-chevron-down"); isExpanded = true; - articleToggleTitle = "Collapse article"; - navArticleToggleTitle = "Collapse all Articles"; + articleToggleTitle = "Collapse docstring"; + navArticleToggleTitle = "Collapse all docstrings"; $(".docstring section").slideDown(); } diff --git a/assets/html/scss/documenter/components/_docstring.scss b/assets/html/scss/documenter/components/_docstring.scss index 8ef1d986c4..88c53c1a4c 100644 --- a/assets/html/scss/documenter/components/_docstring.scss +++ b/assets/html/scss/documenter/components/_docstring.scss @@ -23,6 +23,7 @@ } .docstring-article-toggle-button { + min-width: 1.1rem; padding: 0.2rem 0.2rem 0.2rem 0; } diff --git a/assets/html/themes/documenter-dark.css b/assets/html/themes/documenter-dark.css index 60553c979d..92d95f2ea6 100644 --- a/assets/html/themes/documenter-dark.css +++ b/assets/html/themes/documenter-dark.css @@ -8121,6 +8121,7 @@ html.theme--documenter-dark { html.theme--documenter-dark .docstring > header code { background-color: transparent; } html.theme--documenter-dark .docstring > header .docstring-article-toggle-button { + min-width: 1.1rem; padding: 0.2rem 0.2rem 0.2rem 0; } html.theme--documenter-dark .docstring > header .docstring-binding { margin-right: 0.3em; } diff --git a/assets/html/themes/documenter-light.css b/assets/html/themes/documenter-light.css index dececec89b..b99ae2a3e8 100644 --- a/assets/html/themes/documenter-light.css +++ b/assets/html/themes/documenter-light.css @@ -8064,6 +8064,7 @@ pre { .docstring > header code { background-color: transparent; } .docstring > header .docstring-article-toggle-button { + min-width: 1.1rem; padding: 0.2rem 0.2rem 0.2rem 0; } .docstring > header .docstring-binding { margin-right: 0.3em; } From cad2602f31361d03962212dd29907469693fdaa1 Mon Sep 17 00:00:00 2001 From: Hetarth Shah Date: Sat, 15 Apr 2023 20:11:35 +0530 Subject: [PATCH 17/18] - Minor title updates in generated toggle button --- src/html/HTMLWriter.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index d5687759e5..de7d7b1c8e 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -1228,7 +1228,7 @@ function render_navbar(ctx, navnode, edit_page_link::Bool) # Collapse/Expand All articles toggle push!(navbar_right.nodes, a[ "#documenter-article-toggle-button.docs-article-toggle-button.fa-solid.fa-chevron-up", - :href=>"javascript:;", :title=>"Collapse all Articles", + :href=>"javascript:;", :title=>"Collapse all docstrings", ]) # Construct the main
node that should be the first element in div.docs-main @@ -1629,7 +1629,7 @@ function domify(dctx::DCtx, mdast_node::Node, node::Documenter.DocsNode) article[".docstring"]( header( - a[".docstring-article-toggle-button.fa-solid.fa-chevron-down", :href=>"javascript:;", :title=>"Collapse article"], + a[".docstring-article-toggle-button.fa-solid.fa-chevron-down", :href=>"javascript:;", :title=>"Collapse docstring"], a[".docstring-binding", :id=>node.anchor.id, :href=>"#$(node.anchor.id)"](code("$(node.object.binding)")), " — ", # — span[".docstring-category"]("$(Documenter.doccat(node.object))") From c352fb6e5445e6308a85852fcbc2cbe10eb10996 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Sun, 16 Apr 2023 12:10:22 +1200 Subject: [PATCH 18/18] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6109f43ed8..2e398c35e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Move the mobile layout sidebar toggle (hamburger) from the right side to the left side. (#1312, #2076) -* Added the ability to expand/collapse individual as well as all docstrings. (#1393) +* Added the ability to expand/collapse individual as well as all docstrings. (#1393, #2078) ### Fixed