Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit dff4877

Browse files
authored
Merge pull request #19 from readthedocs/update-extension-with-sections
[Update] Support Page Sections & Sphinx Domains
2 parents 85a57b0 + a79e44d commit dff4877

15 files changed

+604
-468
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
prune common
22
include LICENSE
3+
include sphinx_search/_static/js/rtd_sphinx_search.js
34
include sphinx_search/_static/js/rtd_sphinx_search.min.js
5+
include sphinx_search/_static/css/rtd_sphinx_search.css
46
include sphinx_search/_static/css/rtd_sphinx_search.min.css

docs/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,9 @@
176176

177177
# A list of files that should not be packed into the epub file.
178178
epub_exclude_files = ['search.html']
179+
180+
# -- Setup for 'confval' used in docs/configuration.rst ----------------------
181+
182+
def setup(app):
183+
app.add_object_type('confval', 'confval',
184+
'pair: %s; configuration value')

docs/configuration.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Configuration
2+
=============
3+
4+
The following settings are available.
5+
You can customize these configuration options in your ``conf.py`` file:
6+
7+
.. confval:: rtd_sphinx_search_file_type
8+
9+
Description: Type of files to be included in the html.
10+
11+
Possible values:
12+
13+
- ``minified``: Include the minified and uglified CSS and JS files.
14+
- ``un-minified``: Include the original CSS and JS files.
15+
16+
Default: ``'minified'``
17+
18+
Type: ``string``

docs/custom-design.rst

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,12 @@ Custom Design
44
If you want to change the styles of the search UI,
55
you can do so by `adding your custom stylesheet`_ to your documentation.
66

7-
Basic structure of the HTML which is generated for the full-page search UI
7+
Basic structure of the HTML which is generated for the search UI
88
is given below for the reference:
99

1010
.. code-block:: html
1111

12-
<div class="search__outer__wrapper search__backdrop display-block">
13-
<div class="search__outer">
14-
15-
<!-- Cross icon on top right corner -->
16-
<div class="search__cross" title="Close">
17-
<!--?xml version='1.0' encoding='UTF-8'?-->
18-
<svg class="search__cross__img" width="15px" height="15px" enable-background="new 0 0 612 612" version="1.1" viewBox="0 0 612 612" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
19-
<polygon points="612 36.004 576.52 0.603 306 270.61 35.478 0.603 0 36.004 270.52 306.01 0 576 35.478 611.4 306 341.41 576.52 611.4 612 576 341.46 306.01">
20-
</polygon>
21-
</svg>
22-
</div>
23-
24-
<input class="search__outer__input" placeholder="Search ...">
25-
<span class="bar"></span> <!-- This is for underline effect on input field -->
26-
27-
<div class="search__result__box">
28-
29-
<!-- Results -->
30-
<div class="search__result__single" id="hit__1">
31-
<div class="search__result__single" id="hit__2">
32-
33-
<!-- Sample result structure -->
34-
<div class="search__result__single" id="hit__3">
35-
<a href="https://link-to-the.result">
36-
<div class="content">
37-
<h2 class="search__result__title">Title of the <em>Result</em></h2>
38-
<br>
39-
<small class="search__result__path">path/to/result (from <strong>subproject-slug</strong>)</small>
40-
<p class="search__result__content">... Sample <em>Result</em> Text ...</p>
41-
</div>
42-
</a>
43-
</div>
44-
45-
<div class="search__result__single" id="hit__4">
46-
<div class="search__result__single" id="hit__5">
47-
</div>
48-
</div>
49-
</div>
12+
<!-- Coming Soon -->
5013

5114

5215
.. _adding your custom stylesheet: https://docs.readthedocs.io/page/guides/adding-custom-css.html

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The CSS is also autoprefixed to extend the support to most of the browsers.
3939
:caption: Table of Contents
4040

4141
installation
42+
configuration
4243
custom-design
4344
development
4445
testing

gulpfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var autoprefixer = require("gulp-autoprefixer"),
1111

1212
gulp.task("styles", function() {
1313
return gulp
14-
.src("sphinx_search/_static/css/*.css")
14+
.src("sphinx_search/_static/css/rtd_sphinx_search.css")
1515
.pipe(autoprefixer())
1616
.pipe(csso())
1717
.pipe(rename({ extname: ".min.css" }))
@@ -20,15 +20,15 @@ gulp.task("styles", function() {
2020

2121
gulp.task("scripts", function() {
2222
return gulp
23-
.src("sphinx_search/_static/js/*.js")
23+
.src("sphinx_search/_static/js/rtd_sphinx_search.js")
2424
.pipe(babel({ presets: ["@babel/env"] }))
2525
.pipe(uglify())
2626
.pipe(rename({ extname: ".min.js" }))
2727
.pipe(gulp.dest("sphinx_search/_static/js"));
2828
});
2929

3030
gulp.task("clean", function() {
31-
return del(["sphinx_search/**/*.min.*"]);
31+
return del(["sphinx_search/**/rtd_sphinx_search.min.*"]);
3232
});
3333

3434
gulp.task("default", ["clean"], function() {

sphinx_search/_static/css/rtd_sphinx_search.css

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
.search__outer::-webkit-scrollbar {
6363
width: 7px;
64+
height: 7px;
6465
background-color: #fcfcfc;
6566
}
6667

@@ -149,16 +150,19 @@
149150
/* Search result */
150151

151152
.search__result__single {
152-
padding: 10px;
153+
margin-top: 10px;
154+
padding: 0px 10px;
153155
border-bottom: 1px solid #e6e6e6;
154156
}
155157

156158
.search__result__box .active {
157159
background-color: rgb(245, 245, 245);
158160
}
159161

160-
.search__result__single:hover {
161-
background-color: rgb(245, 245, 245);
162+
.outer_div_page_results {
163+
margin: 5px 0px;
164+
overflow: auto;
165+
padding: 3px 5px;
162166
}
163167

164168
.search__result__single a {
@@ -172,30 +176,37 @@
172176
/* Display and box model */
173177
display: inline-block;
174178
font-weight: 500;
175-
margin-bottom: 0;
179+
margin-bottom: 15px;
176180
margin-top: 0;
177-
font-size: 14px;
181+
font-size: 15px;
178182

179183
/* Other */
180184
color: #6ea0ec;
181185
border-bottom: 1px solid #6ea0ec;
182186
}
183187

184-
/* Path of each search result */
185-
186-
.search__result__path {
187-
color: #b3b3b3;
188+
.search__result__subheading {
189+
color: black;
190+
font-weight: 700;
191+
float: left;
192+
width: 20%;
193+
font-size: 15px;
194+
margin-right: 10px;
195+
overflow-x: hidden;
188196
}
189197

190-
/* Content of each search result */
191-
192198
.search__result__content {
199+
margin: 0;
193200
text-decoration: none;
194201
color: black;
195-
font-size: 14px;
202+
font-size: 15px;
196203
display: block;
197-
margin-top: 3px;
198204
margin-bottom: 5px;
205+
margin-bottom: 0;
206+
line-height: inherit;
207+
float: right;
208+
width: calc(80% - 15px);
209+
text-align: left;
199210
}
200211

201212
/* Highlighting of matched results */
@@ -206,7 +217,7 @@
206217

207218
.search__outer .search__result__title em {
208219
background-color: #e5f6ff;
209-
padding-bottom: 4px;
220+
padding-bottom: 3px;
210221
border-bottom-color: black;
211222
}
212223

@@ -215,6 +226,38 @@
215226
border-bottom: 1px solid black;
216227
}
217228

229+
.search__result__subheading em {
230+
border-bottom: 1px solid black;
231+
}
232+
233+
.outer_div_page_results:hover {
234+
background-color: rgb(245, 245, 245);
235+
}
236+
237+
.br-for-hits {
238+
display: block;
239+
content: "";
240+
margin-top: 10px;
241+
}
242+
243+
.rtd_ui_search_subtitle {
244+
all: unset;
245+
color: inherit;
246+
font-size: 85%;
247+
}
248+
249+
@media (max-width: 630px) {
250+
.search__result__subheading {
251+
float: none;
252+
width: 90%;
253+
}
254+
255+
.search__result__content {
256+
float: none;
257+
width: 90%;
258+
}
259+
}
260+
218261
@keyframes fade-in {
219262
from {
220263
opacity: 0;

sphinx_search/_static/css/rtd_sphinx_search.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)