Skip to content

Commit

Permalink
MAINT: Change the index-uid compactible with search-index (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Revathyvenugopal162 authored Jul 27, 2023
1 parent 4c8a980 commit 6c10338
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 29 deletions.
3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ansys_logo_black,
ansys_logo_white,
ansys_logo_white_cropped,
convert_version_to_pymeilisearch,
generate_404,
get_version_match,
latex,
Expand Down Expand Up @@ -60,7 +61,7 @@
"use_meilisearch": {
"api_key": os.getenv("MEILISEARCH_API_KEY", ""),
"index_uids": {
f"ansys-sphinx-theme-v{get_version_match(__version__)}": "ansys-sphinx-theme",
f"ansys-sphinx-theme-v{convert_version_to_pymeilisearch(__version__)}": "ansys-sphinx-theme", # noqa: E501
},
},
}
Expand Down
21 changes: 21 additions & 0 deletions src/ansys_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ def get_version_match(semver: str) -> str:
return ".".join([major, minor])


def convert_version_to_pymeilisearch(semver: str) -> str:
"""Convert a semantic version number to pymeilisearch-compatible format.
This function evaluates the given semantic version number and returns a
version number that is compatible with `pymeilisearch`, where dots are
replaced with hyphens.
Parameters
----------
semver : str
Semantic version number in the form of a string.
Returns
-------
str
pymeilisearch-compatible version number.
"""
version = get_version_match(semver).replace(".", "-")
return version


def setup_default_html_theme_options(app):
"""Set up the default configuration for the HTML options.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
@import "https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.css";
@import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css";

div [data-ds-theme] .searchbox {
div[data-ds-theme] .searchbox {
overflow-y: scroll;
margin: auto;
display: block;
width: 600px;
}

.dsb-suggestions {
width: 580px;
}

.docs-searchbar-suggestion--category-header {
Expand All @@ -18,11 +12,67 @@ div [data-ds-theme] .searchbox {
text-align: left;
}

.docs-searchbar-suggestion--subcategory-column-text {
color: var(--pst-color-text-base);
/* Styles for screens with a width of 576px or less */
@media screen and (max-width: 576px) {
div[data-ds-theme] .searchbox {
width: 100%;
max-width: 100%;
}

.dsb-suggestions {
width: 100%;
max-width: 480px;
}

.meilisearch-autocomplete .dsb-dropdown-menu [class^="dsb-dataset-"] {
max-width: 580px;
min-width: 430px;
width: 450px;
}

.bd-search input {
width: 270px !important;
}

.index-select {
width: 180px;
}

.meilisearch-autocomplete .docs-searchbar-suggestion {
width: 450px;
}
}

div [data-ds-theme] .searchbox input {
/* Styles for screens with a width of 1200px or less */
@media screen and (min-width: 1200px) {
div[data-ds-theme] .searchbox {
max-width: 800px;
}

.dsb-suggestions {
width: 100%;
max-width: 580px;
}

.meilisearch-autocomplete .dsb-dropdown-menu {
max-width: 870px;
min-width: 580px;
width: 850px;
}

.bd-search input {
width: 600px !important;
}
.index-select {
width: 250px;
}

.meilisearch-autocomplete .docs-searchbar-suggestion {
width: 735px;
}
}

div[data-ds-theme] .searchbox input {
height: 32px;
border-radius: 8px;
font-size: 18px;
Expand All @@ -34,6 +84,10 @@ div [data-ds-theme] .searchbox input {
display: none;
}

.docs-searchbar-footer {
display: none;
}

[class*="docs-searchbar-suggestion"] {
text-decoration: none;
}
Expand All @@ -54,7 +108,6 @@ div [data-ds-theme] .searchbox input {
}

#search-bar-input {
width: 550px;
background-color: var(--pst-color-background);
border: 1px solid var(--pst-color-border);
border-radius: 0.25rem;
Expand All @@ -66,7 +119,7 @@ div [data-ds-theme] .searchbox input {

.meilisearch-autocomplete::before {
content: "\f002";
font-family: "Font Awesome 6 Free"; /* The Font Awesome font family */
font-family: "Font Awesome 6 Free";
position: absolute;
left: 8px;
top: 50%;
Expand All @@ -85,7 +138,6 @@ div [data-ds-theme] .searchbox input {
font-family: "Open Sans", sans-serif;
box-shadow: 0px 0px 20px var(--pst-color-border);
padding: 0 10px 0px 10px;
width: 250px;
margin-left: 5px;
}

Expand All @@ -94,19 +146,15 @@ div [data-ds-theme] .searchbox input {
border: 1px solid #d9d9d9;
background: var(--pst-color-background);
border-radius: 4px;
max-width: 800px;
min-width: 500px;
padding: 0 8px 8px;
width: 805px;
}
.meilisearch-autocomplete .dsb-dropdown-menu {
height: 500px !important; /* Set a fixed height to trigger the scrollbar */
overflow-y: auto !important; /* Enable the vertical scrollbar */
max-height: 600px !important;
overflow-y: auto !important;
border: 1px solid #ccc;
}

.meilisearch-autocomplete .docs-searchbar-suggestion {
width: 735px;
background: var(--pst-color-background);
}

Expand All @@ -124,11 +172,6 @@ div [data-ds-theme] .searchbox input {

.meilisearch-autocomplete .docs-searchbar-suggestion--content {
display: block;
width: 100% !important;
}

.meilisearch-autocomplete .dsb-dropdown-menu {
max-width: 800px;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--title {
Expand All @@ -139,10 +182,6 @@ div [data-ds-theme] .searchbox input {
width: 100%;
}

.meilisearch-autocomplete .docs-searchbar-suggestion--text {
width: 100%;
}

/* Styling the scrollbar */
.meilisearch-autocomplete .dsb-dropdown-menu::-webkit-scrollbar {
width: 0.5rem;
Expand Down

0 comments on commit 6c10338

Please sign in to comment.