From 51ad2dd6aef23968ae16313fb8f5f5f4836a7ee8 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Wed, 24 May 2023 15:48:16 +0200 Subject: [PATCH 01/10] DOC: clear the searchbar --- .../components/search-field.html | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html index 4919c931e..6b09ddece 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html @@ -44,15 +44,32 @@ debug: true, // Set debug to true if you want to inspect the dropdown }); + // Listen for changes in the dropdown selector and update the index uid and suggestion accordingly document .getElementById("indexUidSelector") .addEventListener("change", function () { theSearchBar.indexUid = this.value; - theSearchBar.inputSelector = "#search-bar-input"; + theSearchBar.suggestionIndexUid = this.value; + theSearchBar.autocomplete.autocomplete.setVal(""); + }); + + // Listen for changes in the search bar input and update the suggestion accordingly + document + .getElementById("search-bar-input") + .addEventListener("change", function () { + theSearchBar.suggestionIndexUid = + document.getElementById("indexUidSelector").value; }); // Set the focus on the search bar input - document.getElementById("search-bar-input").focus(); + document.getElementById("searchbar").focus(); + + // Set the focus on the dropdown selector + document + .getElementById("searchbar") + .addEventListener("indexUidSelector", function () { + theSearchBar.autocomplete.autocomplete.close(); + }); {% else %} From 5ed24154c24aa13156c93503c090bb2099f3a5d1 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Thu, 25 May 2023 14:53:57 +0200 Subject: [PATCH 02/10] MAINT: added the method to get docs by scraping --- doc/source/conf.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 3e30d6750..0b2a7050b 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -47,6 +47,13 @@ "doc_path": "doc/source", } +version_match = get_version_match(__version__) + +if "dev" in version_match: + index_uid = "ansys-sphinx-theme-dev-sphinx-docs" +else: + index_uid = "ansys-sphinx-theme-sphinx-docs" # will change with instant scraping + # specify the location of your github repo html_theme_options = { "github_url": "https://github.com/ansys/ansys-sphinx-theme", @@ -62,13 +69,12 @@ ], "switcher": { "json_url": f"https://{cname}/versions.json", - "version_match": get_version_match(__version__), + "version_match": f"{version_match}", }, "use_meilisearch": { "api_key": os.getenv("MEILISEARCH_API_KEY", ""), "index_uids": { - "ansys-internal-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme", - "pyansys-pyaedt-sphinx-docs": "PyAEDT", + f"{index_uid}": "ansys-sphinx-theme", }, }, } From 7e191055a8f25cb2bc2fb59038b2f8bc28d809f4 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Thu, 25 May 2023 16:17:35 +0200 Subject: [PATCH 03/10] DOC: added the inline comment --- doc/source/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 0b2a7050b..2aabeca45 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -52,7 +52,9 @@ if "dev" in version_match: index_uid = "ansys-sphinx-theme-dev-sphinx-docs" else: - index_uid = "ansys-sphinx-theme-sphinx-docs" # will change with instant scraping + # will change with instant scraping + # changes to index_uid = "ansys-sphinx-theme-{version-match}-sphinx-docs" + index_uid = "ansys-sphinx-theme-sphinx-docs" # specify the location of your github repo html_theme_options = { From c8efa87a0298b82fee5d54b595f90305ddfbca95 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Thu, 25 May 2023 17:30:09 +0200 Subject: [PATCH 04/10] FIX: improve the code --- doc/source/conf.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 2aabeca45..7c5006ad4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -47,14 +47,13 @@ "doc_path": "doc/source", } + version_match = get_version_match(__version__) -if "dev" in version_match: - index_uid = "ansys-sphinx-theme-dev-sphinx-docs" -else: - # will change with instant scraping - # changes to index_uid = "ansys-sphinx-theme-{version-match}-sphinx-docs" - index_uid = "ansys-sphinx-theme-sphinx-docs" +# will change with instant scraping +# changes to index_uid = "ansys-sphinx-theme-{version-match}-sphinx-docs" + +index_uid = "ansys-sphinx-theme-{}-sphinx-docs".format(version_match).replace(".", "-") # specify the location of your github repo html_theme_options = { From 331a167e695559488bcd4eaf2af28e5ed04cfe6f Mon Sep 17 00:00:00 2001 From: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com> Date: Thu, 25 May 2023 17:36:22 +0200 Subject: [PATCH 05/10] Update doc/source/conf.py --- doc/source/conf.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 7c5006ad4..c9d8f0598 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -50,9 +50,6 @@ version_match = get_version_match(__version__) -# will change with instant scraping -# changes to index_uid = "ansys-sphinx-theme-{version-match}-sphinx-docs" - index_uid = "ansys-sphinx-theme-{}-sphinx-docs".format(version_match).replace(".", "-") # specify the location of your github repo From 471ab05e98d4d2f9674c03a92382592c78285bb9 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Fri, 16 Jun 2023 15:41:28 +0200 Subject: [PATCH 06/10] MAINT: rename the index uid --- doc/source/conf.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index c9d8f0598..2b9bb4dba 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -48,10 +48,6 @@ } -version_match = get_version_match(__version__) - -index_uid = "ansys-sphinx-theme-{}-sphinx-docs".format(version_match).replace(".", "-") - # specify the location of your github repo html_theme_options = { "github_url": "https://github.com/ansys/ansys-sphinx-theme", @@ -67,12 +63,12 @@ ], "switcher": { "json_url": f"https://{cname}/versions.json", - "version_match": f"{version_match}", + "version_match": get_version_match(__version__), }, "use_meilisearch": { "api_key": os.getenv("MEILISEARCH_API_KEY", ""), "index_uids": { - f"{index_uid}": "ansys-sphinx-theme", + f"ansys-sphinx-theme-{get_version_match(__version__)}": "ansys-sphinx-theme", }, }, } From 1d6dfe86bca3cd87495d2b057f18f1d47f3b0a4e Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Wed, 19 Jul 2023 08:14:56 +0200 Subject: [PATCH 07/10] Fix: add the limit to search --- .pre-commit-config.yaml | 7 +++++ doc/source/getting_started/index.rst | 2 +- doc/source/user_guide/404_page.rst | 2 +- doc/source/user_guide/css.rst | 4 +-- doc/source/user_guide/options.rst | 30 +++++++++---------- doc/source/user_guide/pdf.rst | 12 ++++---- .../components/search-field.html | 3 ++ .../static/css/meilisearch.css | 14 ++++++--- 8 files changed, 44 insertions(+), 30 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b1176c283..db14d9907 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,3 +43,10 @@ repos: rev: 0.21.0 hooks: - id: check-github-workflows + + +- repo: https://github.com/adamchainz/blacken-docs + rev: 1.15.0 + hooks: + - id: blacken-docs + additional_dependencies: [black==23.7.0] diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst index 22187f45a..db976bbe0 100644 --- a/doc/source/getting_started/index.rst +++ b/doc/source/getting_started/index.rst @@ -22,7 +22,7 @@ Modify the ``conf.py`` file --------------------------- To use this theme, modify your Sphinx ``conf.py`` file:: - html_theme ='ansys_sphinx_theme' + html_theme = "ansys_sphinx_theme" Consider using the ``conf.py`` for this repository: diff --git a/doc/source/user_guide/404_page.rst b/doc/source/user_guide/404_page.rst index 169c67896..6ba9ddca9 100644 --- a/doc/source/user_guide/404_page.rst +++ b/doc/source/user_guide/404_page.rst @@ -43,7 +43,7 @@ Use the default 404 page To use the default 404 page, you can use the ``generate_404`` function in the ``ansys_sphinx_theme`` module to create and use a custom cover page: -.. code-block:: python +.. code-block:: pycon from ansys_sphinx_theme import generate_404 diff --git a/doc/source/user_guide/css.rst b/doc/source/user_guide/css.rst index 5537155ba..3e9704b1e 100644 --- a/doc/source/user_guide/css.rst +++ b/doc/source/user_guide/css.rst @@ -32,6 +32,6 @@ Next, in your ``conf.py`` file, add the following: .. code:: python - html_static_path = ['_static'] - html_css_files = ['css/custom.css'] + html_static_path = ["_static"] + html_css_files = ["css/custom.css"] diff --git a/doc/source/user_guide/options.rst b/doc/source/user_guide/options.rst index bf0c44f23..6a97cbf43 100644 --- a/doc/source/user_guide/options.rst +++ b/doc/source/user_guide/options.rst @@ -39,14 +39,14 @@ to the same value as the title for the main ``index.rst`` page: .. code:: python - html_short_title = html_title = 'Ansys Sphinx Theme' + html_short_title = html_title = "Ansys Sphinx Theme" If you want to title for the main ``index.rst`` file to show the package version, include ``|version|`` in the title: .. code:: python - html_short_title = html_title = 'Ansys Sphinx Theme |version|' + html_short_title = html_title = "Ansys Sphinx Theme |version|" Customize icons --------------- @@ -72,7 +72,7 @@ the ``icon``, and the ``type``. This example adds an icon for sending an email: -.. code-block:: python +.. code-block:: pycon html_theme_options = { "icon_links": [ @@ -86,7 +86,7 @@ Hide icons To hide icons so that they do not show in the navigation bar, add their names to the ``hidden_icons`` list: -.. code-block:: python +.. code-block:: pycon html_theme_options = { "hidden_icons": ["GitHub"], @@ -96,7 +96,7 @@ to the ``hidden_icons`` list: If you want to hide all icons, use the ``show_icons`` boolean variable: -.. code-block:: python +.. code-block:: pycon html_theme_options = { "show_icons": False, @@ -137,15 +137,15 @@ Here is an example configuration for using MeiliSearch in the ``conf.py`` file: .. code-block:: python - import os + import os use_meilisearch = { "host": os.getenv("MEILISEARCH_HOST_NAME", ""), "api_key": os.getenv("MEILISEARCH_API_KEY", ""), "index_uids": { "index-uid of current project": "index name to be displayed", - "another-index-uid": "index name to be displayed" - } + "another-index-uid": "index name to be displayed", + }, } Here is the example configuration of using MeiliSearch in @@ -153,15 +153,15 @@ Here is the example configuration of using MeiliSearch in .. code-block:: python - import os - + import os + html_theme_options = { - "use_meilisearch": { - "index_uids": { - "ansys-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme", - "pyansys-docs-all-public": "PyAnsys", + "use_meilisearch": { + "index_uids": { + "ansys-ansys-sphinx-theme-sphinx-docs": "ansys-sphinx-theme", + "pyansys-docs-all-public": "PyAnsys", + }, }, - }, } With these options set, your Sphinx project can use MeiliSearch diff --git a/doc/source/user_guide/pdf.rst b/doc/source/user_guide/pdf.rst index 8b0c899e7..1eae688e2 100644 --- a/doc/source/user_guide/pdf.rst +++ b/doc/source/user_guide/pdf.rst @@ -11,7 +11,7 @@ page. However, you can use the ``generate_preamble`` function in the You use this function to generate the value for the ``preamble`` key in the ``latex_elements`` variable declared in the ``conf.py`` file: -.. code-block:: python +.. code-block:: pycon latex_elements = { "preamble": ansys_sphinx_theme.latex.generate_preamble( @@ -27,13 +27,11 @@ import them and then add them to the ``latex_additional_files`` dictionary: .. code-block:: python from ansys_sphinx_theme import ( - ansys_logo_white, - ansys_logo_white_cropped, - watermark, + ansys_logo_white, + ansys_logo_white_cropped, + watermark, ) .. code-block:: python - latex_additional_files = [ - watermark, ansys_logo_white, ansys_logo_white_cropped - ] + latex_additional_files = [watermark, ansys_logo_white, ansys_logo_white_cropped] diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html index 6b09ddece..bf203f3e4 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html @@ -42,6 +42,9 @@ inputSelector: "#search-bar-input", enableDarkMode: "auto", debug: true, // Set debug to true if you want to inspect the dropdown + meilisearchOptions: { + limit: 10, + }, }); // Listen for changes in the dropdown selector and update the index uid and suggestion accordingly diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/meilisearch.css b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/meilisearch.css index 90479413b..7306b203c 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/meilisearch.css +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/meilisearch.css @@ -14,11 +14,11 @@ div [data-ds-theme] .searchbox { .docs-searchbar-suggestion--category-header { background-color: var(--pst-color-border); border-radius: 7px; - text-align: center; + text-align: left; } .docs-searchbar-suggestion--subcategory-column-text { - color: (var(--pst-color-text-base)); + color: var(--pst-color-text-base); } div [data-ds-theme] .searchbox input { @@ -93,7 +93,7 @@ div [data-ds-theme] .searchbox input { border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; - overflow: auto; + overflow: scroll; padding: 0 8px 8px; width: 805px; } @@ -109,5 +109,11 @@ div [data-ds-theme] .searchbox input { } .meilisearch-autocomplete .docs-searchbar-suggestion--subcategory-column { - width: 30%; + width: None; + text-align: left; +} +.meilisearch-autocomplete + .docs-searchbar-suggestion + .docs-searchbar-suggestion--subcategory-column { + display: none; } From be2ab955fb7bc25ebc6a2a269e2a348ac7559ded Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Wed, 19 Jul 2023 11:48:56 +0200 Subject: [PATCH 08/10] Fix: add the highlight for index --- .../components/search-field.html | 1 + .../static/css/meilisearch.css | 48 +++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html index bf203f3e4..e21d98d9f 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-field.html @@ -33,6 +33,7 @@ theme_use_meilisearch.host %} {% endif %}