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

[Update] Support Page Sections & Sphinx Domains #19

Merged
merged 43 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e24214d
Update the extension to support page sections and sphinx domains
dojutsu-user Jun 29, 2019
8b56cee
fix tests
dojutsu-user Jun 29, 2019
3cdedc7
set count to zero
dojutsu-user Jun 29, 2019
a477e9c
set margin
dojutsu-user Jun 29, 2019
eecb619
update docs
dojutsu-user Jun 30, 2019
03f1808
change debounce time
dojutsu-user Jun 30, 2019
2173fc4
update debounce time
dojutsu-user Jun 30, 2019
66d8861
add min js file
dojutsu-user Jul 1, 2019
31f142f
use templating langugage
dojutsu-user Jul 2, 2019
abf809c
add missing bracket
dojutsu-user Jul 2, 2019
c115c52
show sorted results
dojutsu-user Jul 2, 2019
24c84f5
add comments
dojutsu-user Jul 2, 2019
156a8b9
Fix test
dojutsu-user Jul 2, 2019
d533cfc
show more data for domain objects
dojutsu-user Jul 3, 2019
73f3b4b
remove external templating language
dojutsu-user Jul 3, 2019
2d9763b
fix horizontal scroll bar
dojutsu-user Jul 3, 2019
1e39d47
show subprojecs with font reduced
dojutsu-user Jul 4, 2019
e4796a7
fix clashing css class
dojutsu-user Jul 4, 2019
6e869e2
use more .template
dojutsu-user Jul 4, 2019
a789e81
ui improvements and make extension compatible with sphinx <= 1.8
dojutsu-user Jul 4, 2019
604204b
edit tox.ini
dojutsu-user Jul 4, 2019
4a48c8a
Merge branch 'master' into update-extension-with-sections
dojutsu-user Jul 5, 2019
7ed4096
remove sphinx17 from tox
dojutsu-user Jul 5, 2019
84fc171
ignore RemovedInSphinx40Warning in pytest.ini
dojutsu-user Jul 5, 2019
5119812
add test
dojutsu-user Jul 8, 2019
85d082d
use sphinx 18 syntax
dojutsu-user Jul 8, 2019
8dce55e
don't use minified file
dojutsu-user Jul 8, 2019
c735b75
remove html structure comments and from the docs
dojutsu-user Jul 9, 2019
047a438
show max 3 results from page sections
dojutsu-user Jul 9, 2019
d8c9d46
improvements
dojutsu-user Jul 9, 2019
40fef13
use helper functions
dojutsu-user Jul 9, 2019
ab1dbbb
use 100 as constant
dojutsu-user Jul 10, 2019
2957f9a
use minified files
dojutsu-user Jul 10, 2019
7c1dfcf
update minified files
dojutsu-user Jul 10, 2019
dbddbd4
add checkbox for searching in current section
dojutsu-user Jul 10, 2019
bf7dfec
remove checkbox for now
dojutsu-user Jul 10, 2019
ed8764e
clean some code
dojutsu-user Jul 10, 2019
75a0cd9
fix tests
dojutsu-user Jul 10, 2019
46a383b
Merge branch 'master' into update-extension-with-sections
dojutsu-user Jul 11, 2019
2746b35
update minified files
dojutsu-user Jul 11, 2019
b164cb2
provide setting for choosing between minified and unminified files
dojutsu-user Jul 12, 2019
ffa8bc3
follow sphinx convention
dojutsu-user Jul 12, 2019
a79e44d
update docs
dojutsu-user Jul 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
prune common
include LICENSE
include sphinx_search/_static/js/rtd_sphinx_search.js
include sphinx_search/_static/js/rtd_sphinx_search.min.js
include sphinx_search/_static/css/rtd_sphinx_search.css
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we should include these as well as the minified ones. People generally like to be able to debug against non-minified source.

include sphinx_search/_static/css/rtd_sphinx_search.min.css
9 changes: 3 additions & 6 deletions sphinx_search/_static/css/rtd_sphinx_search.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,7 @@
cursor: pointer;
}

/* Helper class */

.display-block {
display: block;
animation: fade-in 0.4s;
}
/* Title of each search result */

.search__result__title {
/* Display and box model */
Expand Down Expand Up @@ -214,6 +209,8 @@
text-align: left;
}

/* Highlighting of matched results */

.search__outer em {
font-style: normal;
}
Expand Down
2 changes: 1 addition & 1 deletion sphinx_search/_static/css/rtd_sphinx_search.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 25 additions & 40 deletions sphinx_search/_static/js/rtd_sphinx_search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const MAX_SUGGESTIONS = 50;
const MAX_SECTION_RESULTS = 3;
const MAX_SUBSTRING_LIMIT = 100;

let TOTAL_PAGE_RESULTS = 0;
let SEARCH_QUERY = "";

Expand Down Expand Up @@ -136,7 +138,7 @@ const get_section_html = (sectionData, page_link) => {
}

let section_content = [
sectionData._source.content.substring(0, 100) + " ..."
sectionData._source.content.substring(0, MAX_SUBSTRING_LIMIT) + " ..."
];

if (getHighlightListData(highlight, "sections.content")) {
Expand Down Expand Up @@ -449,7 +451,7 @@ const removeResults = () => {
const getErrorDiv = err_msg => {
let err_div = createDomNode("div", {
class: "search__result__box",
style: "color: black; min-width: 300px"
style: "color: black; min-width: 300px; font-weight: 700"
});
err_div.innerHTML = err_msg;
return err_div;
Expand All @@ -471,7 +473,7 @@ const fetchAndGenerateResults = (search_url, projectName) => {
// the user.
removeResults();
let search_loding = createDomNode("div", { class: "search__result__box" });
search_loding.innerHTML = "Searching ....";
search_loding.innerHTML = "<strong>Searching ....</strong>";
search_outer.appendChild(search_loding);

let ajaxFunc = () => {
Expand Down Expand Up @@ -528,41 +530,24 @@ const fetchAndGenerateResults = (search_url, projectName) => {
* This html structure will serve as the boilerplate
* to show our search results.
*
* @return {Object} object containing the nodes with classes "search__outer__wrapper", "search__outer__input", "search__outer" and "search__cross"
* @return {String} initial html structure
*/
const generateAndReturnInitialHtml = () => {
let search_outer_wrapper = createDomNode("div", {
class: "search__outer__wrapper search__backdrop"
});

let search_outer = createDomNode("div", { class: "search__outer" });

let cross_icon = createDomNode("div", {
class: "search__cross",
title: "Close"
});
cross_icon.innerHTML =
"<?xml version='1.0' encoding='UTF-8'?><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'><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'/></svg>";
search_outer.appendChild(cross_icon);

let search_outer_input = createDomNode("input", {
class: "search__outer__input",
placeholder: "Search ..."
});

// for material ui design input field
let horizontal_bar = createDomNode("span", { class: "bar" });

search_outer.appendChild(search_outer_input);
search_outer.appendChild(horizontal_bar);
search_outer_wrapper.appendChild(search_outer);
let initialHtml =
'<div class="search__outer__wrapper search__backdrop"> \
<div class="search__outer"> \
<div class="search__cross" title="Close"> \
<!--?xml version="1.0" encoding="UTF-8"?--> \
<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"> \
<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"></polygon> \
</svg> \
</div> \
<input class="search__outer__input" placeholder="Search ..."> \
<span class="bar"></span> \
</div> \
</div>';

return {
search_outer_wrapper,
search_outer_input,
search_outer,
cross_icon
};
return initialHtml;
};

/**
Expand Down Expand Up @@ -615,12 +600,12 @@ window.addEventListener("DOMContentLoaded", evt => {
const language = READTHEDOCS_DATA.language || "en";
const api_host = READTHEDOCS_DATA.api_host;

const initialHtml = generateAndReturnInitialHtml();
let search_outer_wrapper = initialHtml.search_outer_wrapper;
let search_outer_input = initialHtml.search_outer_input;
let cross_icon = initialHtml.cross_icon;
let initialHtml = generateAndReturnInitialHtml();
document.body.innerHTML += initialHtml;

document.body.appendChild(search_outer_wrapper);
let search_outer_wrapper = document.querySelector('.search__outer__wrapper');
let search_outer_input = document.querySelector('.search__outer__input');
let cross_icon = document.querySelector('.search__cross');

// this denotes the search suggestion which is currently selected
// via tha ArrowUp/ArrowDown keys.
Expand Down
Loading