Skip to content

Commit 6c10338

Browse files
MAINT: Change the index-uid compactible with search-index (#260)
1 parent 4c8a980 commit 6c10338

File tree

3 files changed

+90
-29
lines changed

3 files changed

+90
-29
lines changed

doc/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
ansys_logo_black,
1414
ansys_logo_white,
1515
ansys_logo_white_cropped,
16+
convert_version_to_pymeilisearch,
1617
generate_404,
1718
get_version_match,
1819
latex,
@@ -60,7 +61,7 @@
6061
"use_meilisearch": {
6162
"api_key": os.getenv("MEILISEARCH_API_KEY", ""),
6263
"index_uids": {
63-
f"ansys-sphinx-theme-v{get_version_match(__version__)}": "ansys-sphinx-theme",
64+
f"ansys-sphinx-theme-v{convert_version_to_pymeilisearch(__version__)}": "ansys-sphinx-theme", # noqa: E501
6465
},
6566
},
6667
}

src/ansys_sphinx_theme/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ def get_version_match(semver: str) -> str:
6363
return ".".join([major, minor])
6464

6565

66+
def convert_version_to_pymeilisearch(semver: str) -> str:
67+
"""Convert a semantic version number to pymeilisearch-compatible format.
68+
69+
This function evaluates the given semantic version number and returns a
70+
version number that is compatible with `pymeilisearch`, where dots are
71+
replaced with hyphens.
72+
73+
Parameters
74+
----------
75+
semver : str
76+
Semantic version number in the form of a string.
77+
78+
Returns
79+
-------
80+
str
81+
pymeilisearch-compatible version number.
82+
"""
83+
version = get_version_match(semver).replace(".", "-")
84+
return version
85+
86+
6687
def setup_default_html_theme_options(app):
6788
"""Set up the default configuration for the HTML options.
6889

src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/meilisearch.css

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
@import "https://cdn.jsdelivr.net/npm/docs-searchbar.js@latest/dist/cdn/docs-searchbar.min.css";
22
@import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css";
33

4-
div [data-ds-theme] .searchbox {
4+
div[data-ds-theme] .searchbox {
55
overflow-y: scroll;
66
margin: auto;
7-
display: block;
8-
width: 600px;
9-
}
10-
11-
.dsb-suggestions {
12-
width: 580px;
137
}
148

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

21-
.docs-searchbar-suggestion--subcategory-column-text {
22-
color: var(--pst-color-text-base);
15+
/* Styles for screens with a width of 576px or less */
16+
@media screen and (max-width: 576px) {
17+
div[data-ds-theme] .searchbox {
18+
width: 100%;
19+
max-width: 100%;
20+
}
21+
22+
.dsb-suggestions {
23+
width: 100%;
24+
max-width: 480px;
25+
}
26+
27+
.meilisearch-autocomplete .dsb-dropdown-menu [class^="dsb-dataset-"] {
28+
max-width: 580px;
29+
min-width: 430px;
30+
width: 450px;
31+
}
32+
33+
.bd-search input {
34+
width: 270px !important;
35+
}
36+
37+
.index-select {
38+
width: 180px;
39+
}
40+
41+
.meilisearch-autocomplete .docs-searchbar-suggestion {
42+
width: 450px;
43+
}
2344
}
2445

25-
div [data-ds-theme] .searchbox input {
46+
/* Styles for screens with a width of 1200px or less */
47+
@media screen and (min-width: 1200px) {
48+
div[data-ds-theme] .searchbox {
49+
max-width: 800px;
50+
}
51+
52+
.dsb-suggestions {
53+
width: 100%;
54+
max-width: 580px;
55+
}
56+
57+
.meilisearch-autocomplete .dsb-dropdown-menu {
58+
max-width: 870px;
59+
min-width: 580px;
60+
width: 850px;
61+
}
62+
63+
.bd-search input {
64+
width: 600px !important;
65+
}
66+
.index-select {
67+
width: 250px;
68+
}
69+
70+
.meilisearch-autocomplete .docs-searchbar-suggestion {
71+
width: 735px;
72+
}
73+
}
74+
75+
div[data-ds-theme] .searchbox input {
2676
height: 32px;
2777
border-radius: 8px;
2878
font-size: 18px;
@@ -34,6 +84,10 @@ div [data-ds-theme] .searchbox input {
3484
display: none;
3585
}
3686

87+
.docs-searchbar-footer {
88+
display: none;
89+
}
90+
3791
[class*="docs-searchbar-suggestion"] {
3892
text-decoration: none;
3993
}
@@ -54,7 +108,6 @@ div [data-ds-theme] .searchbox input {
54108
}
55109

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

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

@@ -94,19 +146,15 @@ div [data-ds-theme] .searchbox input {
94146
border: 1px solid #d9d9d9;
95147
background: var(--pst-color-background);
96148
border-radius: 4px;
97-
max-width: 800px;
98-
min-width: 500px;
99149
padding: 0 8px 8px;
100-
width: 805px;
101150
}
102151
.meilisearch-autocomplete .dsb-dropdown-menu {
103-
height: 500px !important; /* Set a fixed height to trigger the scrollbar */
104-
overflow-y: auto !important; /* Enable the vertical scrollbar */
152+
max-height: 600px !important;
153+
overflow-y: auto !important;
105154
border: 1px solid #ccc;
106155
}
107156

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

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

125173
.meilisearch-autocomplete .docs-searchbar-suggestion--content {
126174
display: block;
127-
width: 100% !important;
128-
}
129-
130-
.meilisearch-autocomplete .dsb-dropdown-menu {
131-
max-width: 800px;
132175
}
133176

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

142-
.meilisearch-autocomplete .docs-searchbar-suggestion--text {
143-
width: 100%;
144-
}
145-
146185
/* Styling the scrollbar */
147186
.meilisearch-autocomplete .dsb-dropdown-menu::-webkit-scrollbar {
148187
width: 0.5rem;

0 commit comments

Comments
 (0)