Skip to content

Commit 2b40608

Browse files
committed
version 3.18.5
1 parent b34c806 commit 2b40608

File tree

7 files changed

+230
-146
lines changed

7 files changed

+230
-146
lines changed

docs/api-docs/slack_sdk/socket_mode/builtin/internals.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ <h1 class="title">Module <code>slack_sdk.socket_mode.builtin.internals</code></h
2626
<summary>
2727
<span>Expand source code</span>
2828
</summary>
29-
<pre><code class="python">import hashlib
29+
<pre><code class="python">import errno
30+
import hashlib
3031
import itertools
3132
import os
3233
import random
@@ -231,10 +232,21 @@ <h1 class="title">Module <code>slack_sdk.socket_mode.builtin.internals</code></h
231232
def receive(specific_buffer_size: Optional[int] = None):
232233
size = specific_buffer_size if specific_buffer_size is not None else receive_buffer_size
233234
with sock_receive_lock:
234-
received_bytes = sock.recv(size)
235-
if all_message_trace_enabled:
236-
logger.debug(f&#34;Received bytes: {received_bytes}&#34;)
237-
return received_bytes
235+
try:
236+
received_bytes = sock.recv(size)
237+
if all_message_trace_enabled:
238+
if len(received_bytes) &gt; 0:
239+
logger.debug(f&#34;Received bytes: {received_bytes}&#34;)
240+
return received_bytes
241+
except OSError as e:
242+
# For Linux/macOS, errno.EBADF is the expected error for bad connections.
243+
# The errno.ENOTSOCK can be sent when running on Windows OS.
244+
if e.errno in (errno.EBADF, errno.ENOTSOCK):
245+
# Note that bad connections can be detected by monitoring threads
246+
# the Socket Mode client automatically reconnects to a new endpoint later.
247+
logger.debug(&#34;The connection seems to be already closed.&#34;)
248+
return bytes()
249+
raise e
238250

239251
return _fetch_messages(
240252
messages=[],

docs/api-docs/slack_sdk/version.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="title">Module <code>slack_sdk.version</code></h1>
2828
<span>Expand source code</span>
2929
</summary>
3030
<pre><code class="python">&#34;&#34;&#34;Check the latest version at https://pypi.org/project/slack-sdk/&#34;&#34;&#34;
31-
__version__ = &#34;3.18.4&#34;</code></pre>
31+
__version__ = &#34;3.18.5&#34;</code></pre>
3232
</details>
3333
</section>
3434
<section>

docs/assets/doctools.js

Lines changed: 11 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
*/
1111
"use strict";
1212

13+
const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
14+
"TEXTAREA",
15+
"INPUT",
16+
"SELECT",
17+
"BUTTON",
18+
]);
19+
1320
const _ready = (callback) => {
1421
if (document.readyState !== "loading") {
1522
callback();
@@ -18,73 +25,11 @@ const _ready = (callback) => {
1825
}
1926
};
2027

21-
/**
22-
* highlight a given string on a node by wrapping it in
23-
* span elements with the given class name.
24-
*/
25-
const _highlight = (node, addItems, text, className) => {
26-
if (node.nodeType === Node.TEXT_NODE) {
27-
const val = node.nodeValue;
28-
const parent = node.parentNode;
29-
const pos = val.toLowerCase().indexOf(text);
30-
if (
31-
pos >= 0 &&
32-
!parent.classList.contains(className) &&
33-
!parent.classList.contains("nohighlight")
34-
) {
35-
let span;
36-
37-
const closestNode = parent.closest("body, svg, foreignObject");
38-
const isInSVG = closestNode && closestNode.matches("svg");
39-
if (isInSVG) {
40-
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
41-
} else {
42-
span = document.createElement("span");
43-
span.classList.add(className);
44-
}
45-
46-
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
47-
parent.insertBefore(
48-
span,
49-
parent.insertBefore(
50-
document.createTextNode(val.substr(pos + text.length)),
51-
node.nextSibling
52-
)
53-
);
54-
node.nodeValue = val.substr(0, pos);
55-
56-
if (isInSVG) {
57-
const rect = document.createElementNS(
58-
"http://www.w3.org/2000/svg",
59-
"rect"
60-
);
61-
const bbox = parent.getBBox();
62-
rect.x.baseVal.value = bbox.x;
63-
rect.y.baseVal.value = bbox.y;
64-
rect.width.baseVal.value = bbox.width;
65-
rect.height.baseVal.value = bbox.height;
66-
rect.setAttribute("class", className);
67-
addItems.push({ parent: parent, target: rect });
68-
}
69-
}
70-
} else if (node.matches && !node.matches("button, select, textarea")) {
71-
node.childNodes.forEach((el) => _highlight(el, addItems, text, className));
72-
}
73-
};
74-
const _highlightText = (thisNode, text, className) => {
75-
let addItems = [];
76-
_highlight(thisNode, addItems, text, className);
77-
addItems.forEach((obj) =>
78-
obj.parent.insertAdjacentElement("beforebegin", obj.target)
79-
);
80-
};
81-
8228
/**
8329
* Small JavaScript module for the documentation.
8430
*/
8531
const Documentation = {
8632
init: () => {
87-
Documentation.highlightSearchWords();
8833
Documentation.initDomainIndexTable();
8934
Documentation.initOnKeyListeners();
9035
},
@@ -126,51 +71,6 @@ const Documentation = {
12671
Documentation.LOCALE = catalog.locale;
12772
},
12873

129-
/**
130-
* highlight the search words provided in the url in the text
131-
*/
132-
highlightSearchWords: () => {
133-
const highlight =
134-
new URLSearchParams(window.location.search).get("highlight") || "";
135-
const terms = highlight.toLowerCase().split(/\s+/).filter(x => x);
136-
if (terms.length === 0) return; // nothing to do
137-
138-
// There should never be more than one element matching "div.body"
139-
const divBody = document.querySelectorAll("div.body");
140-
const body = divBody.length ? divBody[0] : document.querySelector("body");
141-
window.setTimeout(() => {
142-
terms.forEach((term) => _highlightText(body, term, "highlighted"));
143-
}, 10);
144-
145-
const searchBox = document.getElementById("searchbox");
146-
if (searchBox === null) return;
147-
searchBox.appendChild(
148-
document
149-
.createRange()
150-
.createContextualFragment(
151-
'<p class="highlight-link">' +
152-
'<a href="javascript:Documentation.hideSearchWords()">' +
153-
Documentation.gettext("Hide Search Matches") +
154-
"</a></p>"
155-
)
156-
);
157-
},
158-
159-
/**
160-
* helper function to hide the search marks again
161-
*/
162-
hideSearchWords: () => {
163-
document
164-
.querySelectorAll("#searchbox .highlight-link")
165-
.forEach((el) => el.remove());
166-
document
167-
.querySelectorAll("span.highlighted")
168-
.forEach((el) => el.classList.remove("highlighted"));
169-
const url = new URL(window.location);
170-
url.searchParams.delete("highlight");
171-
window.history.replaceState({}, "", url);
172-
},
173-
17474
/**
17575
* helper function to focus on search bar
17676
*/
@@ -210,15 +110,11 @@ const Documentation = {
210110
)
211111
return;
212112

213-
const blacklistedElements = new Set([
214-
"TEXTAREA",
215-
"INPUT",
216-
"SELECT",
217-
"BUTTON",
218-
]);
219113
document.addEventListener("keydown", (event) => {
220-
if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements
221-
if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys
114+
// bail for input elements
115+
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
116+
// bail with special keys
117+
if (event.altKey || event.ctrlKey || event.metaKey) return;
222118

223119
if (!event.shiftKey) {
224120
switch (event.key) {
@@ -240,10 +136,6 @@ const Documentation = {
240136
event.preventDefault();
241137
}
242138
break;
243-
case "Escape":
244-
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
245-
Documentation.hideSearchWords();
246-
event.preventDefault();
247139
}
248140
}
249141

docs/assets/searchtools.js

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ const _removeChildren = (element) => {
5757
const _escapeRegExp = (string) =>
5858
string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
5959

60-
const _displayItem = (item, highlightTerms, searchTerms) => {
60+
const _displayItem = (item, searchTerms) => {
6161
const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
6262
const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT;
6363
const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
6464
const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
6565
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
6666

67-
const [docName, title, anchor, descr] = item;
67+
const [docName, title, anchor, descr, score, _filename] = item;
6868

6969
let listItem = document.createElement("li");
7070
let requestUrl;
@@ -82,10 +82,9 @@ const _displayItem = (item, highlightTerms, searchTerms) => {
8282
requestUrl = docUrlRoot + docName + docFileSuffix;
8383
linkUrl = docName + docLinkSuffix;
8484
}
85-
const params = new URLSearchParams();
86-
params.set("highlight", [...highlightTerms].join(" "));
8785
let linkEl = listItem.appendChild(document.createElement("a"));
88-
linkEl.href = linkUrl + "?" + params.toString() + anchor;
86+
linkEl.href = linkUrl + anchor;
87+
linkEl.dataset.score = score;
8988
linkEl.innerHTML = title;
9089
if (descr)
9190
listItem.appendChild(document.createElement("span")).innerHTML =
@@ -96,7 +95,7 @@ const _displayItem = (item, highlightTerms, searchTerms) => {
9695
.then((data) => {
9796
if (data)
9897
listItem.appendChild(
99-
Search.makeSearchSummary(data, searchTerms, highlightTerms)
98+
Search.makeSearchSummary(data, searchTerms)
10099
);
101100
});
102101
Search.output.appendChild(listItem);
@@ -116,15 +115,14 @@ const _finishSearch = (resultCount) => {
116115
const _displayNextItem = (
117116
results,
118117
resultCount,
119-
highlightTerms,
120118
searchTerms
121119
) => {
122120
// results left, load the summary and display it
123121
// this is intended to be dynamic (don't sub resultsCount)
124122
if (results.length) {
125-
_displayItem(results.pop(), highlightTerms, searchTerms);
123+
_displayItem(results.pop(), searchTerms);
126124
setTimeout(
127-
() => _displayNextItem(results, resultCount, highlightTerms, searchTerms),
125+
() => _displayNextItem(results, resultCount, searchTerms),
128126
5
129127
);
130128
}
@@ -237,6 +235,12 @@ const Search = {
237235
* execute search (requires search index to be loaded)
238236
*/
239237
query: (query) => {
238+
const filenames = Search._index.filenames;
239+
const docNames = Search._index.docnames;
240+
const titles = Search._index.titles;
241+
const allTitles = Search._index.alltitles;
242+
const indexEntries = Search._index.indexentries;
243+
240244
// stem the search terms and add them to the correct list
241245
const stemmer = new Stemmer();
242246
const searchTerms = new Set();
@@ -264,6 +268,10 @@ const Search = {
264268
}
265269
});
266270

271+
if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js
272+
localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" "))
273+
}
274+
267275
// console.debug("SEARCH: searching for:");
268276
// console.info("required: ", [...searchTerms]);
269277
// console.info("excluded: ", [...excludedTerms]);
@@ -272,6 +280,40 @@ const Search = {
272280
let results = [];
273281
_removeChildren(document.getElementById("search-progress"));
274282

283+
const queryLower = query.toLowerCase();
284+
for (const [title, foundTitles] of Object.entries(allTitles)) {
285+
if (title.toLowerCase().includes(queryLower) && (queryLower.length >= title.length/2)) {
286+
for (const [file, id] of foundTitles) {
287+
let score = Math.round(100 * queryLower.length / title.length)
288+
results.push([
289+
docNames[file],
290+
titles[file] !== title ? `${titles[file]} > ${title}` : title,
291+
id !== null ? "#" + id : "",
292+
null,
293+
score,
294+
filenames[file],
295+
]);
296+
}
297+
}
298+
}
299+
300+
// search for explicit entries in index directives
301+
for (const [entry, foundEntries] of Object.entries(indexEntries)) {
302+
if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) {
303+
for (const [file, id] of foundEntries) {
304+
let score = Math.round(100 * queryLower.length / entry.length)
305+
results.push([
306+
docNames[file],
307+
titles[file],
308+
id ? "#" + id : "",
309+
null,
310+
score,
311+
filenames[file],
312+
]);
313+
}
314+
}
315+
}
316+
275317
// lookup as object
276318
objectTerms.forEach((term) =>
277319
results.push(...Search.performObjectSearch(term, objectTerms))
@@ -318,7 +360,7 @@ const Search = {
318360
// console.info("search results:", Search.lastresults);
319361

320362
// print the results
321-
_displayNextItem(results, results.length, highlightTerms, searchTerms);
363+
_displayNextItem(results, results.length, searchTerms);
322364
},
323365

324366
/**
@@ -399,8 +441,8 @@ const Search = {
399441
// prepare search
400442
const terms = Search._index.terms;
401443
const titleTerms = Search._index.titleterms;
402-
const docNames = Search._index.docnames;
403444
const filenames = Search._index.filenames;
445+
const docNames = Search._index.docnames;
404446
const titles = Search._index.titles;
405447

406448
const scoreMap = new Map();
@@ -497,11 +539,9 @@ const Search = {
497539
/**
498540
* helper function to return a node containing the
499541
* search summary for a given text. keywords is a list
500-
* of stemmed words, highlightWords is the list of normal, unstemmed
501-
* words. the first one is used to find the occurrence, the
502-
* latter for highlighting it.
542+
* of stemmed words.
503543
*/
504-
makeSearchSummary: (htmlText, keywords, highlightWords) => {
544+
makeSearchSummary: (htmlText, keywords) => {
505545
const text = Search.htmlToText(htmlText);
506546
if (text === "") return null;
507547

@@ -519,10 +559,6 @@ const Search = {
519559
summary.classList.add("context");
520560
summary.textContent = top + text.substr(startWithContext, 240).trim() + tail;
521561

522-
highlightWords.forEach((highlightWord) =>
523-
_highlightText(summary, highlightWord, "highlighted")
524-
);
525-
526562
return summary;
527563
},
528564
};

0 commit comments

Comments
 (0)