quarchpy 2.2.8.dev1__py2.py3-none-any.whl → 2.2.9.dev1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. quarchpy/__pycache__/__init__.cpython-311.pyc +0 -0
  2. quarchpy/__pycache__/__init__.cpython-313.pyc +0 -0
  3. quarchpy/__pycache__/_version.cpython-311.pyc +0 -0
  4. quarchpy/__pycache__/_version.cpython-313.pyc +0 -0
  5. quarchpy/__pycache__/connection.cpython-311.pyc +0 -0
  6. quarchpy/__pycache__/connection.cpython-313.pyc +0 -0
  7. quarchpy/_version.py +1 -1
  8. quarchpy/config_files/__pycache__/__init__.cpython-311.pyc +0 -0
  9. quarchpy/config_files/__pycache__/__init__.cpython-313.pyc +0 -0
  10. quarchpy/config_files/__pycache__/quarch_config_parser.cpython-311.pyc +0 -0
  11. quarchpy/config_files/__pycache__/quarch_config_parser.cpython-313.pyc +0 -0
  12. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/com.sun.istack-license.html +59 -0
  13. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/dorkbox-LICENSE.Apachev2 +218 -0
  14. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jSerialComm-LICENSE-APACHE-2.0 +202 -0
  15. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jSerialComm-LICENSE-LGPL-3.0 +165 -0
  16. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jakarta.activation-license.html +59 -0
  17. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jakarta.xml.bind-api-license.html +59 -0
  18. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/javassist-License.html +381 -0
  19. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jmdns-LICENSE.txt +202 -0
  20. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/jna-AL2.0 +177 -0
  21. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/kotlin-stdlib-LICENSE-2.0.txt +202 -0
  22. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/netty-LICENSE.txt +202 -0
  23. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/netty-NOTICE.txt +239 -0
  24. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/slf4j-LICENSE.txt +24 -0
  25. quarchpy/connection_specific/QPS/win-amd64/qis/3rdPartyLicenses/usb4java-LICENSE.md +20 -0
  26. quarchpy/connection_specific/QPS/win-amd64/qis/help.txt +50 -17
  27. quarchpy/connection_specific/QPS/win-amd64/qis/license.txt +1 -0
  28. quarchpy/connection_specific/QPS/win-amd64/qis/qis.jar +0 -0
  29. quarchpy/connection_specific/QPS/win-amd64/qis/qis_lib/CInterface-2.5.jar +0 -0
  30. quarchpy/connection_specific/QPS/win-amd64/qis/qis_lib/QuarchCommon-2.0.jar +0 -0
  31. quarchpy/connection_specific/QPS/win-amd64/qis/qis_lib/TorridonCommon-1.3.jar +0 -0
  32. quarchpy/connection_specific/QPS/win-amd64/qis/qis_lib/usb4java-1.3.1.jar +0 -0
  33. quarchpy/connection_specific/__pycache__/StreamChannels.cpython-311.pyc +0 -0
  34. quarchpy/connection_specific/__pycache__/StreamChannels.cpython-313.pyc +0 -0
  35. quarchpy/connection_specific/__pycache__/__init__.cpython-311.pyc +0 -0
  36. quarchpy/connection_specific/__pycache__/__init__.cpython-313.pyc +0 -0
  37. quarchpy/connection_specific/__pycache__/connection_QIS.cpython-311.pyc +0 -0
  38. quarchpy/connection_specific/__pycache__/connection_QIS.cpython-313.pyc +0 -0
  39. quarchpy/connection_specific/__pycache__/connection_QPS.cpython-311.pyc +0 -0
  40. quarchpy/connection_specific/__pycache__/connection_QPS.cpython-313.pyc +0 -0
  41. quarchpy/connection_specific/__pycache__/connection_ReST.cpython-311.pyc +0 -0
  42. quarchpy/connection_specific/__pycache__/connection_ReST.cpython-313.pyc +0 -0
  43. quarchpy/connection_specific/__pycache__/connection_Serial.cpython-311.pyc +0 -0
  44. quarchpy/connection_specific/__pycache__/connection_Serial.cpython-313.pyc +0 -0
  45. quarchpy/connection_specific/__pycache__/connection_TCP.cpython-311.pyc +0 -0
  46. quarchpy/connection_specific/__pycache__/connection_TCP.cpython-313.pyc +0 -0
  47. quarchpy/connection_specific/__pycache__/connection_USB.cpython-311.pyc +0 -0
  48. quarchpy/connection_specific/__pycache__/connection_USB.cpython-313.pyc +0 -0
  49. quarchpy/connection_specific/__pycache__/mDNS.cpython-311.pyc +0 -0
  50. quarchpy/connection_specific/__pycache__/mDNS.cpython-313.pyc +0 -0
  51. quarchpy/connection_specific/jdk_j21_jres/__pycache__/__init__.cpython-311.pyc +0 -0
  52. quarchpy/connection_specific/jdk_j21_jres/__pycache__/__init__.cpython-313.pyc +0 -0
  53. quarchpy/connection_specific/jdk_j21_jres/__pycache__/fix_permissions.cpython-311.pyc +0 -0
  54. quarchpy/connection_specific/jdk_j21_jres/__pycache__/fix_permissions.cpython-313.pyc +0 -0
  55. quarchpy/connection_specific/serial/__pycache__/__init__.cpython-311.pyc +0 -0
  56. quarchpy/connection_specific/serial/__pycache__/__init__.cpython-313.pyc +0 -0
  57. quarchpy/connection_specific/serial/__pycache__/serialutil.cpython-311.pyc +0 -0
  58. quarchpy/connection_specific/serial/__pycache__/serialutil.cpython-313.pyc +0 -0
  59. quarchpy/connection_specific/serial/__pycache__/serialwin32.cpython-311.pyc +0 -0
  60. quarchpy/connection_specific/serial/__pycache__/serialwin32.cpython-313.pyc +0 -0
  61. quarchpy/connection_specific/serial/__pycache__/win32.cpython-311.pyc +0 -0
  62. quarchpy/connection_specific/serial/__pycache__/win32.cpython-313.pyc +0 -0
  63. quarchpy/connection_specific/serial/tools/__pycache__/__init__.cpython-311.pyc +0 -0
  64. quarchpy/connection_specific/serial/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  65. quarchpy/connection_specific/serial/tools/__pycache__/list_ports.cpython-311.pyc +0 -0
  66. quarchpy/connection_specific/serial/tools/__pycache__/list_ports.cpython-313.pyc +0 -0
  67. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_common.cpython-311.pyc +0 -0
  68. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_common.cpython-313.pyc +0 -0
  69. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_windows.cpython-311.pyc +0 -0
  70. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_windows.cpython-313.pyc +0 -0
  71. quarchpy/connection_specific/usb_libs/__pycache__/libusb1.cpython-311.pyc +0 -0
  72. quarchpy/connection_specific/usb_libs/__pycache__/usb1.cpython-311.pyc +0 -0
  73. quarchpy/connection_specific/usb_libs/usb1.py +2360 -2360
  74. quarchpy/debug/SystemTest.py +9 -2
  75. quarchpy/debug/__pycache__/SystemTest.cpython-311.pyc +0 -0
  76. quarchpy/debug/__pycache__/SystemTest.cpython-313.pyc +0 -0
  77. quarchpy/debug/__pycache__/__init__.cpython-311.pyc +0 -0
  78. quarchpy/debug/__pycache__/__init__.cpython-313.pyc +0 -0
  79. quarchpy/debug/__pycache__/module_debug.cpython-313.pyc +0 -0
  80. quarchpy/debug/__pycache__/simple_terminal.cpython-313.pyc +0 -0
  81. quarchpy/debug/__pycache__/upgrade_quarchpy.cpython-313.pyc +0 -0
  82. quarchpy/debug/__pycache__/versionCompare.cpython-311.pyc +0 -0
  83. quarchpy/debug/__pycache__/versionCompare.cpython-313.pyc +0 -0
  84. quarchpy/device/__pycache__/__init__.cpython-311.pyc +0 -0
  85. quarchpy/device/__pycache__/__init__.cpython-313.pyc +0 -0
  86. quarchpy/device/__pycache__/device.cpython-311.pyc +0 -0
  87. quarchpy/device/__pycache__/device.cpython-313.pyc +0 -0
  88. quarchpy/device/__pycache__/quarchArray.cpython-311.pyc +0 -0
  89. quarchpy/device/__pycache__/quarchArray.cpython-313.pyc +0 -0
  90. quarchpy/device/__pycache__/quarchPPM.cpython-311.pyc +0 -0
  91. quarchpy/device/__pycache__/quarchPPM.cpython-313.pyc +0 -0
  92. quarchpy/device/__pycache__/quarchQPS.cpython-311.pyc +0 -0
  93. quarchpy/device/__pycache__/quarchQPS.cpython-313.pyc +0 -0
  94. quarchpy/device/__pycache__/scanDevices.cpython-311.pyc +0 -0
  95. quarchpy/device/__pycache__/scanDevices.cpython-313.pyc +0 -0
  96. quarchpy/device/quarchQPS.py +96 -67
  97. quarchpy/disk_test/__pycache__/AbsDiskFinder.cpython-311.pyc +0 -0
  98. quarchpy/disk_test/__pycache__/AbsDiskFinder.cpython-313.pyc +0 -0
  99. quarchpy/disk_test/__pycache__/DiskTargetSelection.cpython-311.pyc +0 -0
  100. quarchpy/disk_test/__pycache__/DiskTargetSelection.cpython-313.pyc +0 -0
  101. quarchpy/disk_test/__pycache__/__init__.cpython-311.pyc +0 -0
  102. quarchpy/disk_test/__pycache__/__init__.cpython-313.pyc +0 -0
  103. quarchpy/disk_test/__pycache__/iometerDiskFinder.cpython-311.pyc +0 -0
  104. quarchpy/disk_test/__pycache__/iometerDiskFinder.cpython-313.pyc +0 -0
  105. quarchpy/docs/CHANGES.rst +4 -0
  106. quarchpy/docs/Makefile +20 -20
  107. quarchpy/docs/_build/html/_static/custom.css +1 -1
  108. quarchpy/docs/_build/html/_static/doctools.js +149 -149
  109. quarchpy/docs/_build/html/_static/jquery-3.4.1.js +10598 -10598
  110. quarchpy/docs/_build/html/_static/jquery.js +2 -2
  111. quarchpy/docs/_build/html/_static/searchtools.js +632 -632
  112. quarchpy/docs/_build/html/_static/sphinx_highlight.js +154 -154
  113. quarchpy/docs/_build/html/_static/underscore-1.3.1.js +999 -999
  114. quarchpy/docs/_build/html/_static/underscore.js +5 -5
  115. quarchpy/fio/__pycache__/FIO_interface.cpython-311.pyc +0 -0
  116. quarchpy/fio/__pycache__/FIO_interface.cpython-313.pyc +0 -0
  117. quarchpy/fio/__pycache__/__init__.cpython-311.pyc +0 -0
  118. quarchpy/fio/__pycache__/__init__.cpython-313.pyc +0 -0
  119. quarchpy/iometer/__pycache__/__init__.cpython-311.pyc +0 -0
  120. quarchpy/iometer/__pycache__/__init__.cpython-313.pyc +0 -0
  121. quarchpy/iometer/__pycache__/gen_iometer_template.cpython-311.pyc +0 -0
  122. quarchpy/iometer/__pycache__/{gen_iometer_template.cpython-312.pyc → gen_iometer_template.cpython-313.pyc} +0 -0
  123. quarchpy/iometer/__pycache__/iometerFuncs.cpython-311.pyc +0 -0
  124. quarchpy/iometer/__pycache__/iometerFuncs.cpython-313.pyc +0 -0
  125. quarchpy/qis/__pycache__/StreamHeaderInfo.cpython-311.pyc +0 -0
  126. quarchpy/qis/__pycache__/StreamHeaderInfo.cpython-313.pyc +0 -0
  127. quarchpy/qis/__pycache__/__init__.cpython-311.pyc +0 -0
  128. quarchpy/qis/__pycache__/__init__.cpython-313.pyc +0 -0
  129. quarchpy/qis/__pycache__/qisFuncs.cpython-311.pyc +0 -0
  130. quarchpy/qis/__pycache__/qisFuncs.cpython-313.pyc +0 -0
  131. quarchpy/qis/qisFuncs.py +4 -2
  132. quarchpy/qps/__pycache__/__init__.cpython-311.pyc +0 -0
  133. quarchpy/qps/__pycache__/__init__.cpython-313.pyc +0 -0
  134. quarchpy/qps/__pycache__/qpsFuncs.cpython-311.pyc +0 -0
  135. quarchpy/qps/__pycache__/qpsFuncs.cpython-313.pyc +0 -0
  136. quarchpy/user_interface/__pycache__/__init__.cpython-311.pyc +0 -0
  137. quarchpy/user_interface/__pycache__/__init__.cpython-313.pyc +0 -0
  138. quarchpy/user_interface/__pycache__/user_interface.cpython-311.pyc +0 -0
  139. quarchpy/user_interface/__pycache__/user_interface.cpython-313.pyc +0 -0
  140. quarchpy/utilities/__pycache__/TestCenter.cpython-311.pyc +0 -0
  141. quarchpy/utilities/__pycache__/TestCenter.cpython-313.pyc +0 -0
  142. quarchpy/utilities/__pycache__/TimeValue.cpython-311.pyc +0 -0
  143. quarchpy/utilities/__pycache__/TimeValue.cpython-313.pyc +0 -0
  144. quarchpy/utilities/__pycache__/Version.cpython-311.pyc +0 -0
  145. quarchpy/utilities/__pycache__/Version.cpython-313.pyc +0 -0
  146. quarchpy/utilities/__pycache__/__init__.cpython-311.pyc +0 -0
  147. quarchpy/utilities/__pycache__/__init__.cpython-313.pyc +0 -0
  148. {quarchpy-2.2.8.dev1.dist-info → quarchpy-2.2.9.dev1.dist-info}/METADATA +5 -1
  149. {quarchpy-2.2.8.dev1.dist-info → quarchpy-2.2.9.dev1.dist-info}/RECORD +152 -150
  150. quarchpy/.idea/.name +0 -1
  151. quarchpy/.idea/inspectionProfiles/Project_Default.xml +0 -50
  152. quarchpy/.idea/inspectionProfiles/profiles_settings.xml +0 -6
  153. quarchpy/.idea/misc.xml +0 -7
  154. quarchpy/.idea/modules.xml +0 -8
  155. quarchpy/.idea/quarchpy.iml +0 -12
  156. quarchpy/.idea/vcs.xml +0 -6
  157. quarchpy/.idea/workspace.xml +0 -173
  158. quarchpy/__pycache__/__init__.cpython-312.pyc +0 -0
  159. quarchpy/__pycache__/_version.cpython-312.pyc +0 -0
  160. quarchpy/__pycache__/connection.cpython-312.pyc +0 -0
  161. quarchpy/__pycache__/run.cpython-311.pyc +0 -0
  162. quarchpy/__pycache__/run.cpython-312.pyc +0 -0
  163. quarchpy/config_files/__pycache__/__init__.cpython-312.pyc +0 -0
  164. quarchpy/config_files/__pycache__/quarch_config_parser.cpython-312.pyc +0 -0
  165. quarchpy/connection_specific/QPS/win-amd64/InstallType.dat +0 -1
  166. quarchpy/connection_specific/QPS/win-amd64/qis/myFile.csv +0 -50
  167. quarchpy/connection_specific/__pycache__/StreamChannels.cpython-312.pyc +0 -0
  168. quarchpy/connection_specific/__pycache__/__init__.cpython-312.pyc +0 -0
  169. quarchpy/connection_specific/__pycache__/connection_QIS.cpython-312.pyc +0 -0
  170. quarchpy/connection_specific/__pycache__/connection_QPS.cpython-312.pyc +0 -0
  171. quarchpy/connection_specific/__pycache__/connection_ReST.cpython-312.pyc +0 -0
  172. quarchpy/connection_specific/__pycache__/connection_Serial.cpython-312.pyc +0 -0
  173. quarchpy/connection_specific/__pycache__/connection_TCP.cpython-312.pyc +0 -0
  174. quarchpy/connection_specific/__pycache__/connection_USB.cpython-312.pyc +0 -0
  175. quarchpy/connection_specific/__pycache__/mDNS.cpython-312.pyc +0 -0
  176. quarchpy/connection_specific/jdk_j21_jres/__pycache__/__init__.cpython-312.pyc +0 -0
  177. quarchpy/connection_specific/jdk_j21_jres/__pycache__/fix_permissions.cpython-312.pyc +0 -0
  178. quarchpy/connection_specific/serial/__pycache__/__init__.cpython-312.pyc +0 -0
  179. quarchpy/connection_specific/serial/__pycache__/serialutil.cpython-312.pyc +0 -0
  180. quarchpy/connection_specific/serial/__pycache__/serialwin32.cpython-312.pyc +0 -0
  181. quarchpy/connection_specific/serial/__pycache__/win32.cpython-312.pyc +0 -0
  182. quarchpy/connection_specific/serial/tools/__pycache__/__init__.cpython-312.pyc +0 -0
  183. quarchpy/connection_specific/serial/tools/__pycache__/list_ports.cpython-312.pyc +0 -0
  184. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_common.cpython-312.pyc +0 -0
  185. quarchpy/connection_specific/serial/tools/__pycache__/list_ports_windows.cpython-312.pyc +0 -0
  186. quarchpy/connection_specific/usb_libs/__pycache__/libusb1.cpython-312.pyc +0 -0
  187. quarchpy/connection_specific/usb_libs/__pycache__/usb1.cpython-312.pyc +0 -0
  188. quarchpy/debug/__pycache__/SystemTest.cpython-312.pyc +0 -0
  189. quarchpy/debug/__pycache__/__init__.cpython-312.pyc +0 -0
  190. quarchpy/debug/__pycache__/module_debug.cpython-311.pyc +0 -0
  191. quarchpy/debug/__pycache__/module_debug.cpython-312.pyc +0 -0
  192. quarchpy/debug/__pycache__/simple_terminal.cpython-311.pyc +0 -0
  193. quarchpy/debug/__pycache__/simple_terminal.cpython-312.pyc +0 -0
  194. quarchpy/debug/__pycache__/upgrade_quarchpy.cpython-311.pyc +0 -0
  195. quarchpy/debug/__pycache__/upgrade_quarchpy.cpython-312.pyc +0 -0
  196. quarchpy/debug/__pycache__/versionCompare.cpython-312.pyc +0 -0
  197. quarchpy/device/__pycache__/__init__.cpython-312.pyc +0 -0
  198. quarchpy/device/__pycache__/device.cpython-312.pyc +0 -0
  199. quarchpy/device/__pycache__/quarchArray.cpython-312.pyc +0 -0
  200. quarchpy/device/__pycache__/quarchPPM.cpython-312.pyc +0 -0
  201. quarchpy/device/__pycache__/quarchQPS.cpython-312.pyc +0 -0
  202. quarchpy/device/__pycache__/scanDevices.cpython-312.pyc +0 -0
  203. quarchpy/disk_test/__pycache__/AbsDiskFinder.cpython-312.pyc +0 -0
  204. quarchpy/disk_test/__pycache__/DiskTargetSelection.cpython-312.pyc +0 -0
  205. quarchpy/disk_test/__pycache__/__init__.cpython-312.pyc +0 -0
  206. quarchpy/disk_test/__pycache__/iometerDiskFinder.cpython-312.pyc +0 -0
  207. quarchpy/fio/__pycache__/FIO_interface.cpython-312.pyc +0 -0
  208. quarchpy/fio/__pycache__/__init__.cpython-312.pyc +0 -0
  209. quarchpy/iometer/__pycache__/__init__.cpython-312.pyc +0 -0
  210. quarchpy/iometer/__pycache__/iometerFuncs.cpython-312.pyc +0 -0
  211. quarchpy/qis/__pycache__/StreamHeaderInfo.cpython-312.pyc +0 -0
  212. quarchpy/qis/__pycache__/__init__.cpython-312.pyc +0 -0
  213. quarchpy/qis/__pycache__/qisFuncs.cpython-312.pyc +0 -0
  214. quarchpy/qps/__pycache__/__init__.cpython-312.pyc +0 -0
  215. quarchpy/qps/__pycache__/qpsFuncs.cpython-312.pyc +0 -0
  216. quarchpy/user_interface/__pycache__/__init__.cpython-312.pyc +0 -0
  217. quarchpy/user_interface/__pycache__/user_interface.cpython-312.pyc +0 -0
  218. quarchpy/utilities/__pycache__/TestCenter.cpython-312.pyc +0 -0
  219. quarchpy/utilities/__pycache__/TimeValue.cpython-312.pyc +0 -0
  220. quarchpy/utilities/__pycache__/Version.cpython-312.pyc +0 -0
  221. quarchpy/utilities/__pycache__/__init__.cpython-312.pyc +0 -0
  222. /quarchpy/fio/{test_performance_class.py → HIDEtest_performance_class.py} +0 -0
  223. {quarchpy-2.2.8.dev1.dist-info → quarchpy-2.2.9.dev1.dist-info}/WHEEL +0 -0
  224. {quarchpy-2.2.8.dev1.dist-info → quarchpy-2.2.9.dev1.dist-info}/top_level.txt +0 -0
@@ -1,632 +1,632 @@
1
- /*
2
- * Sphinx JavaScript utilities for the full-text search.
3
- */
4
- "use strict";
5
-
6
- /**
7
- * Simple result scoring code.
8
- */
9
- if (typeof Scorer === "undefined") {
10
- var Scorer = {
11
- // Implement the following function to further tweak the score for each result
12
- // The function takes a result array [docname, title, anchor, descr, score, filename]
13
- // and returns the new score.
14
- /*
15
- score: result => {
16
- const [docname, title, anchor, descr, score, filename, kind] = result
17
- return score
18
- },
19
- */
20
-
21
- // query matches the full name of an object
22
- objNameMatch: 11,
23
- // or matches in the last dotted part of the object name
24
- objPartialMatch: 6,
25
- // Additive scores depending on the priority of the object
26
- objPrio: {
27
- 0: 15, // used to be importantResults
28
- 1: 5, // used to be objectResults
29
- 2: -5, // used to be unimportantResults
30
- },
31
- // Used when the priority is not in the mapping.
32
- objPrioDefault: 0,
33
-
34
- // query found in title
35
- title: 15,
36
- partialTitle: 7,
37
- // query found in terms
38
- term: 5,
39
- partialTerm: 2,
40
- };
41
- }
42
-
43
- // Global search result kind enum, used by themes to style search results.
44
- class SearchResultKind {
45
- static get index() { return "index"; }
46
- static get object() { return "object"; }
47
- static get text() { return "text"; }
48
- static get title() { return "title"; }
49
- }
50
-
51
- const _removeChildren = (element) => {
52
- while (element && element.lastChild) element.removeChild(element.lastChild);
53
- };
54
-
55
- /**
56
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
57
- */
58
- const _escapeRegExp = (string) =>
59
- string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
60
-
61
- const _displayItem = (item, searchTerms, highlightTerms) => {
62
- const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
63
- const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
64
- const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
65
- const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
66
- const contentRoot = document.documentElement.dataset.content_root;
67
-
68
- const [docName, title, anchor, descr, score, _filename, kind] = item;
69
-
70
- let listItem = document.createElement("li");
71
- // Add a class representing the item's type:
72
- // can be used by a theme's CSS selector for styling
73
- // See SearchResultKind for the class names.
74
- listItem.classList.add(`kind-${kind}`);
75
- let requestUrl;
76
- let linkUrl;
77
- if (docBuilder === "dirhtml") {
78
- // dirhtml builder
79
- let dirname = docName + "/";
80
- if (dirname.match(/\/index\/$/))
81
- dirname = dirname.substring(0, dirname.length - 6);
82
- else if (dirname === "index/") dirname = "";
83
- requestUrl = contentRoot + dirname;
84
- linkUrl = requestUrl;
85
- } else {
86
- // normal html builders
87
- requestUrl = contentRoot + docName + docFileSuffix;
88
- linkUrl = docName + docLinkSuffix;
89
- }
90
- let linkEl = listItem.appendChild(document.createElement("a"));
91
- linkEl.href = linkUrl + anchor;
92
- linkEl.dataset.score = score;
93
- linkEl.innerHTML = title;
94
- if (descr) {
95
- listItem.appendChild(document.createElement("span")).innerHTML =
96
- " (" + descr + ")";
97
- // highlight search terms in the description
98
- if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
99
- highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
100
- }
101
- else if (showSearchSummary)
102
- fetch(requestUrl)
103
- .then((responseData) => responseData.text())
104
- .then((data) => {
105
- if (data)
106
- listItem.appendChild(
107
- Search.makeSearchSummary(data, searchTerms, anchor)
108
- );
109
- // highlight search terms in the summary
110
- if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
111
- highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
112
- });
113
- Search.output.appendChild(listItem);
114
- };
115
- const _finishSearch = (resultCount) => {
116
- Search.stopPulse();
117
- Search.title.innerText = _("Search Results");
118
- if (!resultCount)
119
- Search.status.innerText = Documentation.gettext(
120
- "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
121
- );
122
- else
123
- Search.status.innerText = Documentation.ngettext(
124
- "Search finished, found one page matching the search query.",
125
- "Search finished, found ${resultCount} pages matching the search query.",
126
- resultCount,
127
- ).replace('${resultCount}', resultCount);
128
- };
129
- const _displayNextItem = (
130
- results,
131
- resultCount,
132
- searchTerms,
133
- highlightTerms,
134
- ) => {
135
- // results left, load the summary and display it
136
- // this is intended to be dynamic (don't sub resultsCount)
137
- if (results.length) {
138
- _displayItem(results.pop(), searchTerms, highlightTerms);
139
- setTimeout(
140
- () => _displayNextItem(results, resultCount, searchTerms, highlightTerms),
141
- 5
142
- );
143
- }
144
- // search finished, update title and status message
145
- else _finishSearch(resultCount);
146
- };
147
- // Helper function used by query() to order search results.
148
- // Each input is an array of [docname, title, anchor, descr, score, filename, kind].
149
- // Order the results by score (in opposite order of appearance, since the
150
- // `_displayNextItem` function uses pop() to retrieve items) and then alphabetically.
151
- const _orderResultsByScoreThenName = (a, b) => {
152
- const leftScore = a[4];
153
- const rightScore = b[4];
154
- if (leftScore === rightScore) {
155
- // same score: sort alphabetically
156
- const leftTitle = a[1].toLowerCase();
157
- const rightTitle = b[1].toLowerCase();
158
- if (leftTitle === rightTitle) return 0;
159
- return leftTitle > rightTitle ? -1 : 1; // inverted is intentional
160
- }
161
- return leftScore > rightScore ? 1 : -1;
162
- };
163
-
164
- /**
165
- * Default splitQuery function. Can be overridden in ``sphinx.search`` with a
166
- * custom function per language.
167
- *
168
- * The regular expression works by splitting the string on consecutive characters
169
- * that are not Unicode letters, numbers, underscores, or emoji characters.
170
- * This is the same as ``\W+`` in Python, preserving the surrogate pair area.
171
- */
172
- if (typeof splitQuery === "undefined") {
173
- var splitQuery = (query) => query
174
- .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu)
175
- .filter(term => term) // remove remaining empty strings
176
- }
177
-
178
- /**
179
- * Search Module
180
- */
181
- const Search = {
182
- _index: null,
183
- _queued_query: null,
184
- _pulse_status: -1,
185
-
186
- htmlToText: (htmlString, anchor) => {
187
- const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
188
- for (const removalQuery of [".headerlink", "script", "style"]) {
189
- htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
190
- }
191
- if (anchor) {
192
- const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`);
193
- if (anchorContent) return anchorContent.textContent;
194
-
195
- console.warn(
196
- `Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.`
197
- );
198
- }
199
-
200
- // if anchor not specified or not found, fall back to main content
201
- const docContent = htmlElement.querySelector('[role="main"]');
202
- if (docContent) return docContent.textContent;
203
-
204
- console.warn(
205
- "Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template."
206
- );
207
- return "";
208
- },
209
-
210
- init: () => {
211
- const query = new URLSearchParams(window.location.search).get("q");
212
- document
213
- .querySelectorAll('input[name="q"]')
214
- .forEach((el) => (el.value = query));
215
- if (query) Search.performSearch(query);
216
- },
217
-
218
- loadIndex: (url) =>
219
- (document.body.appendChild(document.createElement("script")).src = url),
220
-
221
- setIndex: (index) => {
222
- Search._index = index;
223
- if (Search._queued_query !== null) {
224
- const query = Search._queued_query;
225
- Search._queued_query = null;
226
- Search.query(query);
227
- }
228
- },
229
-
230
- hasIndex: () => Search._index !== null,
231
-
232
- deferQuery: (query) => (Search._queued_query = query),
233
-
234
- stopPulse: () => (Search._pulse_status = -1),
235
-
236
- startPulse: () => {
237
- if (Search._pulse_status >= 0) return;
238
-
239
- const pulse = () => {
240
- Search._pulse_status = (Search._pulse_status + 1) % 4;
241
- Search.dots.innerText = ".".repeat(Search._pulse_status);
242
- if (Search._pulse_status >= 0) window.setTimeout(pulse, 500);
243
- };
244
- pulse();
245
- },
246
-
247
- /**
248
- * perform a search for something (or wait until index is loaded)
249
- */
250
- performSearch: (query) => {
251
- // create the required interface elements
252
- const searchText = document.createElement("h2");
253
- searchText.textContent = _("Searching");
254
- const searchSummary = document.createElement("p");
255
- searchSummary.classList.add("search-summary");
256
- searchSummary.innerText = "";
257
- const searchList = document.createElement("ul");
258
- searchList.setAttribute("role", "list");
259
- searchList.classList.add("search");
260
-
261
- const out = document.getElementById("search-results");
262
- Search.title = out.appendChild(searchText);
263
- Search.dots = Search.title.appendChild(document.createElement("span"));
264
- Search.status = out.appendChild(searchSummary);
265
- Search.output = out.appendChild(searchList);
266
-
267
- const searchProgress = document.getElementById("search-progress");
268
- // Some themes don't use the search progress node
269
- if (searchProgress) {
270
- searchProgress.innerText = _("Preparing search...");
271
- }
272
- Search.startPulse();
273
-
274
- // index already loaded, the browser was quick!
275
- if (Search.hasIndex()) Search.query(query);
276
- else Search.deferQuery(query);
277
- },
278
-
279
- _parseQuery: (query) => {
280
- // stem the search terms and add them to the correct list
281
- const stemmer = new Stemmer();
282
- const searchTerms = new Set();
283
- const excludedTerms = new Set();
284
- const highlightTerms = new Set();
285
- const objectTerms = new Set(splitQuery(query.toLowerCase().trim()));
286
- splitQuery(query.trim()).forEach((queryTerm) => {
287
- const queryTermLower = queryTerm.toLowerCase();
288
-
289
- // maybe skip this "word"
290
- // stopwords array is from language_data.js
291
- if (
292
- stopwords.indexOf(queryTermLower) !== -1 ||
293
- queryTerm.match(/^\d+$/)
294
- )
295
- return;
296
-
297
- // stem the word
298
- let word = stemmer.stemWord(queryTermLower);
299
- // select the correct list
300
- if (word[0] === "-") excludedTerms.add(word.substr(1));
301
- else {
302
- searchTerms.add(word);
303
- highlightTerms.add(queryTermLower);
304
- }
305
- });
306
-
307
- if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js
308
- localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" "))
309
- }
310
-
311
- // console.debug("SEARCH: searching for:");
312
- // console.info("required: ", [...searchTerms]);
313
- // console.info("excluded: ", [...excludedTerms]);
314
-
315
- return [query, searchTerms, excludedTerms, highlightTerms, objectTerms];
316
- },
317
-
318
- /**
319
- * execute search (requires search index to be loaded)
320
- */
321
- _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => {
322
- const filenames = Search._index.filenames;
323
- const docNames = Search._index.docnames;
324
- const titles = Search._index.titles;
325
- const allTitles = Search._index.alltitles;
326
- const indexEntries = Search._index.indexentries;
327
-
328
- // Collect multiple result groups to be sorted separately and then ordered.
329
- // Each is an array of [docname, title, anchor, descr, score, filename, kind].
330
- const normalResults = [];
331
- const nonMainIndexResults = [];
332
-
333
- _removeChildren(document.getElementById("search-progress"));
334
-
335
- const queryLower = query.toLowerCase().trim();
336
- for (const [title, foundTitles] of Object.entries(allTitles)) {
337
- if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
338
- for (const [file, id] of foundTitles) {
339
- const score = Math.round(Scorer.title * queryLower.length / title.length);
340
- const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
341
- normalResults.push([
342
- docNames[file],
343
- titles[file] !== title ? `${titles[file]} > ${title}` : title,
344
- id !== null ? "#" + id : "",
345
- null,
346
- score + boost,
347
- filenames[file],
348
- SearchResultKind.title,
349
- ]);
350
- }
351
- }
352
- }
353
-
354
- // search for explicit entries in index directives
355
- for (const [entry, foundEntries] of Object.entries(indexEntries)) {
356
- if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) {
357
- for (const [file, id, isMain] of foundEntries) {
358
- const score = Math.round(100 * queryLower.length / entry.length);
359
- const result = [
360
- docNames[file],
361
- titles[file],
362
- id ? "#" + id : "",
363
- null,
364
- score,
365
- filenames[file],
366
- SearchResultKind.index,
367
- ];
368
- if (isMain) {
369
- normalResults.push(result);
370
- } else {
371
- nonMainIndexResults.push(result);
372
- }
373
- }
374
- }
375
- }
376
-
377
- // lookup as object
378
- objectTerms.forEach((term) =>
379
- normalResults.push(...Search.performObjectSearch(term, objectTerms))
380
- );
381
-
382
- // lookup as search terms in fulltext
383
- normalResults.push(...Search.performTermsSearch(searchTerms, excludedTerms));
384
-
385
- // let the scorer override scores with a custom scoring function
386
- if (Scorer.score) {
387
- normalResults.forEach((item) => (item[4] = Scorer.score(item)));
388
- nonMainIndexResults.forEach((item) => (item[4] = Scorer.score(item)));
389
- }
390
-
391
- // Sort each group of results by score and then alphabetically by name.
392
- normalResults.sort(_orderResultsByScoreThenName);
393
- nonMainIndexResults.sort(_orderResultsByScoreThenName);
394
-
395
- // Combine the result groups in (reverse) order.
396
- // Non-main index entries are typically arbitrary cross-references,
397
- // so display them after other results.
398
- let results = [...nonMainIndexResults, ...normalResults];
399
-
400
- // remove duplicate search results
401
- // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept
402
- let seen = new Set();
403
- results = results.reverse().reduce((acc, result) => {
404
- let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(',');
405
- if (!seen.has(resultStr)) {
406
- acc.push(result);
407
- seen.add(resultStr);
408
- }
409
- return acc;
410
- }, []);
411
-
412
- return results.reverse();
413
- },
414
-
415
- query: (query) => {
416
- const [searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms] = Search._parseQuery(query);
417
- const results = Search._performSearch(searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms);
418
-
419
- // for debugging
420
- //Search.lastresults = results.slice(); // a copy
421
- // console.info("search results:", Search.lastresults);
422
-
423
- // print the results
424
- _displayNextItem(results, results.length, searchTerms, highlightTerms);
425
- },
426
-
427
- /**
428
- * search for object names
429
- */
430
- performObjectSearch: (object, objectTerms) => {
431
- const filenames = Search._index.filenames;
432
- const docNames = Search._index.docnames;
433
- const objects = Search._index.objects;
434
- const objNames = Search._index.objnames;
435
- const titles = Search._index.titles;
436
-
437
- const results = [];
438
-
439
- const objectSearchCallback = (prefix, match) => {
440
- const name = match[4]
441
- const fullname = (prefix ? prefix + "." : "") + name;
442
- const fullnameLower = fullname.toLowerCase();
443
- if (fullnameLower.indexOf(object) < 0) return;
444
-
445
- let score = 0;
446
- const parts = fullnameLower.split(".");
447
-
448
- // check for different match types: exact matches of full name or
449
- // "last name" (i.e. last dotted part)
450
- if (fullnameLower === object || parts.slice(-1)[0] === object)
451
- score += Scorer.objNameMatch;
452
- else if (parts.slice(-1)[0].indexOf(object) > -1)
453
- score += Scorer.objPartialMatch; // matches in last name
454
-
455
- const objName = objNames[match[1]][2];
456
- const title = titles[match[0]];
457
-
458
- // If more than one term searched for, we require other words to be
459
- // found in the name/title/description
460
- const otherTerms = new Set(objectTerms);
461
- otherTerms.delete(object);
462
- if (otherTerms.size > 0) {
463
- const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase();
464
- if (
465
- [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0)
466
- )
467
- return;
468
- }
469
-
470
- let anchor = match[3];
471
- if (anchor === "") anchor = fullname;
472
- else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname;
473
-
474
- const descr = objName + _(", in ") + title;
475
-
476
- // add custom score for some objects according to scorer
477
- if (Scorer.objPrio.hasOwnProperty(match[2]))
478
- score += Scorer.objPrio[match[2]];
479
- else score += Scorer.objPrioDefault;
480
-
481
- results.push([
482
- docNames[match[0]],
483
- fullname,
484
- "#" + anchor,
485
- descr,
486
- score,
487
- filenames[match[0]],
488
- SearchResultKind.object,
489
- ]);
490
- };
491
- Object.keys(objects).forEach((prefix) =>
492
- objects[prefix].forEach((array) =>
493
- objectSearchCallback(prefix, array)
494
- )
495
- );
496
- return results;
497
- },
498
-
499
- /**
500
- * search for full-text terms in the index
501
- */
502
- performTermsSearch: (searchTerms, excludedTerms) => {
503
- // prepare search
504
- const terms = Search._index.terms;
505
- const titleTerms = Search._index.titleterms;
506
- const filenames = Search._index.filenames;
507
- const docNames = Search._index.docnames;
508
- const titles = Search._index.titles;
509
-
510
- const scoreMap = new Map();
511
- const fileMap = new Map();
512
-
513
- // perform the search on the required terms
514
- searchTerms.forEach((word) => {
515
- const files = [];
516
- const arr = [
517
- { files: terms[word], score: Scorer.term },
518
- { files: titleTerms[word], score: Scorer.title },
519
- ];
520
- // add support for partial matches
521
- if (word.length > 2) {
522
- const escapedWord = _escapeRegExp(word);
523
- if (!terms.hasOwnProperty(word)) {
524
- Object.keys(terms).forEach((term) => {
525
- if (term.match(escapedWord))
526
- arr.push({ files: terms[term], score: Scorer.partialTerm });
527
- });
528
- }
529
- if (!titleTerms.hasOwnProperty(word)) {
530
- Object.keys(titleTerms).forEach((term) => {
531
- if (term.match(escapedWord))
532
- arr.push({ files: titleTerms[term], score: Scorer.partialTitle });
533
- });
534
- }
535
- }
536
-
537
- // no match but word was a required one
538
- if (arr.every((record) => record.files === undefined)) return;
539
-
540
- // found search word in contents
541
- arr.forEach((record) => {
542
- if (record.files === undefined) return;
543
-
544
- let recordFiles = record.files;
545
- if (recordFiles.length === undefined) recordFiles = [recordFiles];
546
- files.push(...recordFiles);
547
-
548
- // set score for the word in each file
549
- recordFiles.forEach((file) => {
550
- if (!scoreMap.has(file)) scoreMap.set(file, {});
551
- scoreMap.get(file)[word] = record.score;
552
- });
553
- });
554
-
555
- // create the mapping
556
- files.forEach((file) => {
557
- if (!fileMap.has(file)) fileMap.set(file, [word]);
558
- else if (fileMap.get(file).indexOf(word) === -1) fileMap.get(file).push(word);
559
- });
560
- });
561
-
562
- // now check if the files don't contain excluded terms
563
- const results = [];
564
- for (const [file, wordList] of fileMap) {
565
- // check if all requirements are matched
566
-
567
- // as search terms with length < 3 are discarded
568
- const filteredTermCount = [...searchTerms].filter(
569
- (term) => term.length > 2
570
- ).length;
571
- if (
572
- wordList.length !== searchTerms.size &&
573
- wordList.length !== filteredTermCount
574
- )
575
- continue;
576
-
577
- // ensure that none of the excluded terms is in the search result
578
- if (
579
- [...excludedTerms].some(
580
- (term) =>
581
- terms[term] === file ||
582
- titleTerms[term] === file ||
583
- (terms[term] || []).includes(file) ||
584
- (titleTerms[term] || []).includes(file)
585
- )
586
- )
587
- break;
588
-
589
- // select one (max) score for the file.
590
- const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
591
- // add result to the result list
592
- results.push([
593
- docNames[file],
594
- titles[file],
595
- "",
596
- null,
597
- score,
598
- filenames[file],
599
- SearchResultKind.text,
600
- ]);
601
- }
602
- return results;
603
- },
604
-
605
- /**
606
- * helper function to return a node containing the
607
- * search summary for a given text. keywords is a list
608
- * of stemmed words.
609
- */
610
- makeSearchSummary: (htmlText, keywords, anchor) => {
611
- const text = Search.htmlToText(htmlText, anchor);
612
- if (text === "") return null;
613
-
614
- const textLower = text.toLowerCase();
615
- const actualStartPosition = [...keywords]
616
- .map((k) => textLower.indexOf(k.toLowerCase()))
617
- .filter((i) => i > -1)
618
- .slice(-1)[0];
619
- const startWithContext = Math.max(actualStartPosition - 120, 0);
620
-
621
- const top = startWithContext === 0 ? "" : "...";
622
- const tail = startWithContext + 240 < text.length ? "..." : "";
623
-
624
- let summary = document.createElement("p");
625
- summary.classList.add("context");
626
- summary.textContent = top + text.substr(startWithContext, 240).trim() + tail;
627
-
628
- return summary;
629
- },
630
- };
631
-
632
- _ready(Search.init);
1
+ /*
2
+ * Sphinx JavaScript utilities for the full-text search.
3
+ */
4
+ "use strict";
5
+
6
+ /**
7
+ * Simple result scoring code.
8
+ */
9
+ if (typeof Scorer === "undefined") {
10
+ var Scorer = {
11
+ // Implement the following function to further tweak the score for each result
12
+ // The function takes a result array [docname, title, anchor, descr, score, filename]
13
+ // and returns the new score.
14
+ /*
15
+ score: result => {
16
+ const [docname, title, anchor, descr, score, filename, kind] = result
17
+ return score
18
+ },
19
+ */
20
+
21
+ // query matches the full name of an object
22
+ objNameMatch: 11,
23
+ // or matches in the last dotted part of the object name
24
+ objPartialMatch: 6,
25
+ // Additive scores depending on the priority of the object
26
+ objPrio: {
27
+ 0: 15, // used to be importantResults
28
+ 1: 5, // used to be objectResults
29
+ 2: -5, // used to be unimportantResults
30
+ },
31
+ // Used when the priority is not in the mapping.
32
+ objPrioDefault: 0,
33
+
34
+ // query found in title
35
+ title: 15,
36
+ partialTitle: 7,
37
+ // query found in terms
38
+ term: 5,
39
+ partialTerm: 2,
40
+ };
41
+ }
42
+
43
+ // Global search result kind enum, used by themes to style search results.
44
+ class SearchResultKind {
45
+ static get index() { return "index"; }
46
+ static get object() { return "object"; }
47
+ static get text() { return "text"; }
48
+ static get title() { return "title"; }
49
+ }
50
+
51
+ const _removeChildren = (element) => {
52
+ while (element && element.lastChild) element.removeChild(element.lastChild);
53
+ };
54
+
55
+ /**
56
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
57
+ */
58
+ const _escapeRegExp = (string) =>
59
+ string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
60
+
61
+ const _displayItem = (item, searchTerms, highlightTerms) => {
62
+ const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
63
+ const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
64
+ const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
65
+ const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
66
+ const contentRoot = document.documentElement.dataset.content_root;
67
+
68
+ const [docName, title, anchor, descr, score, _filename, kind] = item;
69
+
70
+ let listItem = document.createElement("li");
71
+ // Add a class representing the item's type:
72
+ // can be used by a theme's CSS selector for styling
73
+ // See SearchResultKind for the class names.
74
+ listItem.classList.add(`kind-${kind}`);
75
+ let requestUrl;
76
+ let linkUrl;
77
+ if (docBuilder === "dirhtml") {
78
+ // dirhtml builder
79
+ let dirname = docName + "/";
80
+ if (dirname.match(/\/index\/$/))
81
+ dirname = dirname.substring(0, dirname.length - 6);
82
+ else if (dirname === "index/") dirname = "";
83
+ requestUrl = contentRoot + dirname;
84
+ linkUrl = requestUrl;
85
+ } else {
86
+ // normal html builders
87
+ requestUrl = contentRoot + docName + docFileSuffix;
88
+ linkUrl = docName + docLinkSuffix;
89
+ }
90
+ let linkEl = listItem.appendChild(document.createElement("a"));
91
+ linkEl.href = linkUrl + anchor;
92
+ linkEl.dataset.score = score;
93
+ linkEl.innerHTML = title;
94
+ if (descr) {
95
+ listItem.appendChild(document.createElement("span")).innerHTML =
96
+ " (" + descr + ")";
97
+ // highlight search terms in the description
98
+ if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
99
+ highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
100
+ }
101
+ else if (showSearchSummary)
102
+ fetch(requestUrl)
103
+ .then((responseData) => responseData.text())
104
+ .then((data) => {
105
+ if (data)
106
+ listItem.appendChild(
107
+ Search.makeSearchSummary(data, searchTerms, anchor)
108
+ );
109
+ // highlight search terms in the summary
110
+ if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
111
+ highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
112
+ });
113
+ Search.output.appendChild(listItem);
114
+ };
115
+ const _finishSearch = (resultCount) => {
116
+ Search.stopPulse();
117
+ Search.title.innerText = _("Search Results");
118
+ if (!resultCount)
119
+ Search.status.innerText = Documentation.gettext(
120
+ "Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories."
121
+ );
122
+ else
123
+ Search.status.innerText = Documentation.ngettext(
124
+ "Search finished, found one page matching the search query.",
125
+ "Search finished, found ${resultCount} pages matching the search query.",
126
+ resultCount,
127
+ ).replace('${resultCount}', resultCount);
128
+ };
129
+ const _displayNextItem = (
130
+ results,
131
+ resultCount,
132
+ searchTerms,
133
+ highlightTerms,
134
+ ) => {
135
+ // results left, load the summary and display it
136
+ // this is intended to be dynamic (don't sub resultsCount)
137
+ if (results.length) {
138
+ _displayItem(results.pop(), searchTerms, highlightTerms);
139
+ setTimeout(
140
+ () => _displayNextItem(results, resultCount, searchTerms, highlightTerms),
141
+ 5
142
+ );
143
+ }
144
+ // search finished, update title and status message
145
+ else _finishSearch(resultCount);
146
+ };
147
+ // Helper function used by query() to order search results.
148
+ // Each input is an array of [docname, title, anchor, descr, score, filename, kind].
149
+ // Order the results by score (in opposite order of appearance, since the
150
+ // `_displayNextItem` function uses pop() to retrieve items) and then alphabetically.
151
+ const _orderResultsByScoreThenName = (a, b) => {
152
+ const leftScore = a[4];
153
+ const rightScore = b[4];
154
+ if (leftScore === rightScore) {
155
+ // same score: sort alphabetically
156
+ const leftTitle = a[1].toLowerCase();
157
+ const rightTitle = b[1].toLowerCase();
158
+ if (leftTitle === rightTitle) return 0;
159
+ return leftTitle > rightTitle ? -1 : 1; // inverted is intentional
160
+ }
161
+ return leftScore > rightScore ? 1 : -1;
162
+ };
163
+
164
+ /**
165
+ * Default splitQuery function. Can be overridden in ``sphinx.search`` with a
166
+ * custom function per language.
167
+ *
168
+ * The regular expression works by splitting the string on consecutive characters
169
+ * that are not Unicode letters, numbers, underscores, or emoji characters.
170
+ * This is the same as ``\W+`` in Python, preserving the surrogate pair area.
171
+ */
172
+ if (typeof splitQuery === "undefined") {
173
+ var splitQuery = (query) => query
174
+ .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu)
175
+ .filter(term => term) // remove remaining empty strings
176
+ }
177
+
178
+ /**
179
+ * Search Module
180
+ */
181
+ const Search = {
182
+ _index: null,
183
+ _queued_query: null,
184
+ _pulse_status: -1,
185
+
186
+ htmlToText: (htmlString, anchor) => {
187
+ const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
188
+ for (const removalQuery of [".headerlink", "script", "style"]) {
189
+ htmlElement.querySelectorAll(removalQuery).forEach((el) => { el.remove() });
190
+ }
191
+ if (anchor) {
192
+ const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`);
193
+ if (anchorContent) return anchorContent.textContent;
194
+
195
+ console.warn(
196
+ `Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.`
197
+ );
198
+ }
199
+
200
+ // if anchor not specified or not found, fall back to main content
201
+ const docContent = htmlElement.querySelector('[role="main"]');
202
+ if (docContent) return docContent.textContent;
203
+
204
+ console.warn(
205
+ "Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template."
206
+ );
207
+ return "";
208
+ },
209
+
210
+ init: () => {
211
+ const query = new URLSearchParams(window.location.search).get("q");
212
+ document
213
+ .querySelectorAll('input[name="q"]')
214
+ .forEach((el) => (el.value = query));
215
+ if (query) Search.performSearch(query);
216
+ },
217
+
218
+ loadIndex: (url) =>
219
+ (document.body.appendChild(document.createElement("script")).src = url),
220
+
221
+ setIndex: (index) => {
222
+ Search._index = index;
223
+ if (Search._queued_query !== null) {
224
+ const query = Search._queued_query;
225
+ Search._queued_query = null;
226
+ Search.query(query);
227
+ }
228
+ },
229
+
230
+ hasIndex: () => Search._index !== null,
231
+
232
+ deferQuery: (query) => (Search._queued_query = query),
233
+
234
+ stopPulse: () => (Search._pulse_status = -1),
235
+
236
+ startPulse: () => {
237
+ if (Search._pulse_status >= 0) return;
238
+
239
+ const pulse = () => {
240
+ Search._pulse_status = (Search._pulse_status + 1) % 4;
241
+ Search.dots.innerText = ".".repeat(Search._pulse_status);
242
+ if (Search._pulse_status >= 0) window.setTimeout(pulse, 500);
243
+ };
244
+ pulse();
245
+ },
246
+
247
+ /**
248
+ * perform a search for something (or wait until index is loaded)
249
+ */
250
+ performSearch: (query) => {
251
+ // create the required interface elements
252
+ const searchText = document.createElement("h2");
253
+ searchText.textContent = _("Searching");
254
+ const searchSummary = document.createElement("p");
255
+ searchSummary.classList.add("search-summary");
256
+ searchSummary.innerText = "";
257
+ const searchList = document.createElement("ul");
258
+ searchList.setAttribute("role", "list");
259
+ searchList.classList.add("search");
260
+
261
+ const out = document.getElementById("search-results");
262
+ Search.title = out.appendChild(searchText);
263
+ Search.dots = Search.title.appendChild(document.createElement("span"));
264
+ Search.status = out.appendChild(searchSummary);
265
+ Search.output = out.appendChild(searchList);
266
+
267
+ const searchProgress = document.getElementById("search-progress");
268
+ // Some themes don't use the search progress node
269
+ if (searchProgress) {
270
+ searchProgress.innerText = _("Preparing search...");
271
+ }
272
+ Search.startPulse();
273
+
274
+ // index already loaded, the browser was quick!
275
+ if (Search.hasIndex()) Search.query(query);
276
+ else Search.deferQuery(query);
277
+ },
278
+
279
+ _parseQuery: (query) => {
280
+ // stem the search terms and add them to the correct list
281
+ const stemmer = new Stemmer();
282
+ const searchTerms = new Set();
283
+ const excludedTerms = new Set();
284
+ const highlightTerms = new Set();
285
+ const objectTerms = new Set(splitQuery(query.toLowerCase().trim()));
286
+ splitQuery(query.trim()).forEach((queryTerm) => {
287
+ const queryTermLower = queryTerm.toLowerCase();
288
+
289
+ // maybe skip this "word"
290
+ // stopwords array is from language_data.js
291
+ if (
292
+ stopwords.indexOf(queryTermLower) !== -1 ||
293
+ queryTerm.match(/^\d+$/)
294
+ )
295
+ return;
296
+
297
+ // stem the word
298
+ let word = stemmer.stemWord(queryTermLower);
299
+ // select the correct list
300
+ if (word[0] === "-") excludedTerms.add(word.substr(1));
301
+ else {
302
+ searchTerms.add(word);
303
+ highlightTerms.add(queryTermLower);
304
+ }
305
+ });
306
+
307
+ if (SPHINX_HIGHLIGHT_ENABLED) { // set in sphinx_highlight.js
308
+ localStorage.setItem("sphinx_highlight_terms", [...highlightTerms].join(" "))
309
+ }
310
+
311
+ // console.debug("SEARCH: searching for:");
312
+ // console.info("required: ", [...searchTerms]);
313
+ // console.info("excluded: ", [...excludedTerms]);
314
+
315
+ return [query, searchTerms, excludedTerms, highlightTerms, objectTerms];
316
+ },
317
+
318
+ /**
319
+ * execute search (requires search index to be loaded)
320
+ */
321
+ _performSearch: (query, searchTerms, excludedTerms, highlightTerms, objectTerms) => {
322
+ const filenames = Search._index.filenames;
323
+ const docNames = Search._index.docnames;
324
+ const titles = Search._index.titles;
325
+ const allTitles = Search._index.alltitles;
326
+ const indexEntries = Search._index.indexentries;
327
+
328
+ // Collect multiple result groups to be sorted separately and then ordered.
329
+ // Each is an array of [docname, title, anchor, descr, score, filename, kind].
330
+ const normalResults = [];
331
+ const nonMainIndexResults = [];
332
+
333
+ _removeChildren(document.getElementById("search-progress"));
334
+
335
+ const queryLower = query.toLowerCase().trim();
336
+ for (const [title, foundTitles] of Object.entries(allTitles)) {
337
+ if (title.toLowerCase().trim().includes(queryLower) && (queryLower.length >= title.length/2)) {
338
+ for (const [file, id] of foundTitles) {
339
+ const score = Math.round(Scorer.title * queryLower.length / title.length);
340
+ const boost = titles[file] === title ? 1 : 0; // add a boost for document titles
341
+ normalResults.push([
342
+ docNames[file],
343
+ titles[file] !== title ? `${titles[file]} > ${title}` : title,
344
+ id !== null ? "#" + id : "",
345
+ null,
346
+ score + boost,
347
+ filenames[file],
348
+ SearchResultKind.title,
349
+ ]);
350
+ }
351
+ }
352
+ }
353
+
354
+ // search for explicit entries in index directives
355
+ for (const [entry, foundEntries] of Object.entries(indexEntries)) {
356
+ if (entry.includes(queryLower) && (queryLower.length >= entry.length/2)) {
357
+ for (const [file, id, isMain] of foundEntries) {
358
+ const score = Math.round(100 * queryLower.length / entry.length);
359
+ const result = [
360
+ docNames[file],
361
+ titles[file],
362
+ id ? "#" + id : "",
363
+ null,
364
+ score,
365
+ filenames[file],
366
+ SearchResultKind.index,
367
+ ];
368
+ if (isMain) {
369
+ normalResults.push(result);
370
+ } else {
371
+ nonMainIndexResults.push(result);
372
+ }
373
+ }
374
+ }
375
+ }
376
+
377
+ // lookup as object
378
+ objectTerms.forEach((term) =>
379
+ normalResults.push(...Search.performObjectSearch(term, objectTerms))
380
+ );
381
+
382
+ // lookup as search terms in fulltext
383
+ normalResults.push(...Search.performTermsSearch(searchTerms, excludedTerms));
384
+
385
+ // let the scorer override scores with a custom scoring function
386
+ if (Scorer.score) {
387
+ normalResults.forEach((item) => (item[4] = Scorer.score(item)));
388
+ nonMainIndexResults.forEach((item) => (item[4] = Scorer.score(item)));
389
+ }
390
+
391
+ // Sort each group of results by score and then alphabetically by name.
392
+ normalResults.sort(_orderResultsByScoreThenName);
393
+ nonMainIndexResults.sort(_orderResultsByScoreThenName);
394
+
395
+ // Combine the result groups in (reverse) order.
396
+ // Non-main index entries are typically arbitrary cross-references,
397
+ // so display them after other results.
398
+ let results = [...nonMainIndexResults, ...normalResults];
399
+
400
+ // remove duplicate search results
401
+ // note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept
402
+ let seen = new Set();
403
+ results = results.reverse().reduce((acc, result) => {
404
+ let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(',');
405
+ if (!seen.has(resultStr)) {
406
+ acc.push(result);
407
+ seen.add(resultStr);
408
+ }
409
+ return acc;
410
+ }, []);
411
+
412
+ return results.reverse();
413
+ },
414
+
415
+ query: (query) => {
416
+ const [searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms] = Search._parseQuery(query);
417
+ const results = Search._performSearch(searchQuery, searchTerms, excludedTerms, highlightTerms, objectTerms);
418
+
419
+ // for debugging
420
+ //Search.lastresults = results.slice(); // a copy
421
+ // console.info("search results:", Search.lastresults);
422
+
423
+ // print the results
424
+ _displayNextItem(results, results.length, searchTerms, highlightTerms);
425
+ },
426
+
427
+ /**
428
+ * search for object names
429
+ */
430
+ performObjectSearch: (object, objectTerms) => {
431
+ const filenames = Search._index.filenames;
432
+ const docNames = Search._index.docnames;
433
+ const objects = Search._index.objects;
434
+ const objNames = Search._index.objnames;
435
+ const titles = Search._index.titles;
436
+
437
+ const results = [];
438
+
439
+ const objectSearchCallback = (prefix, match) => {
440
+ const name = match[4]
441
+ const fullname = (prefix ? prefix + "." : "") + name;
442
+ const fullnameLower = fullname.toLowerCase();
443
+ if (fullnameLower.indexOf(object) < 0) return;
444
+
445
+ let score = 0;
446
+ const parts = fullnameLower.split(".");
447
+
448
+ // check for different match types: exact matches of full name or
449
+ // "last name" (i.e. last dotted part)
450
+ if (fullnameLower === object || parts.slice(-1)[0] === object)
451
+ score += Scorer.objNameMatch;
452
+ else if (parts.slice(-1)[0].indexOf(object) > -1)
453
+ score += Scorer.objPartialMatch; // matches in last name
454
+
455
+ const objName = objNames[match[1]][2];
456
+ const title = titles[match[0]];
457
+
458
+ // If more than one term searched for, we require other words to be
459
+ // found in the name/title/description
460
+ const otherTerms = new Set(objectTerms);
461
+ otherTerms.delete(object);
462
+ if (otherTerms.size > 0) {
463
+ const haystack = `${prefix} ${name} ${objName} ${title}`.toLowerCase();
464
+ if (
465
+ [...otherTerms].some((otherTerm) => haystack.indexOf(otherTerm) < 0)
466
+ )
467
+ return;
468
+ }
469
+
470
+ let anchor = match[3];
471
+ if (anchor === "") anchor = fullname;
472
+ else if (anchor === "-") anchor = objNames[match[1]][1] + "-" + fullname;
473
+
474
+ const descr = objName + _(", in ") + title;
475
+
476
+ // add custom score for some objects according to scorer
477
+ if (Scorer.objPrio.hasOwnProperty(match[2]))
478
+ score += Scorer.objPrio[match[2]];
479
+ else score += Scorer.objPrioDefault;
480
+
481
+ results.push([
482
+ docNames[match[0]],
483
+ fullname,
484
+ "#" + anchor,
485
+ descr,
486
+ score,
487
+ filenames[match[0]],
488
+ SearchResultKind.object,
489
+ ]);
490
+ };
491
+ Object.keys(objects).forEach((prefix) =>
492
+ objects[prefix].forEach((array) =>
493
+ objectSearchCallback(prefix, array)
494
+ )
495
+ );
496
+ return results;
497
+ },
498
+
499
+ /**
500
+ * search for full-text terms in the index
501
+ */
502
+ performTermsSearch: (searchTerms, excludedTerms) => {
503
+ // prepare search
504
+ const terms = Search._index.terms;
505
+ const titleTerms = Search._index.titleterms;
506
+ const filenames = Search._index.filenames;
507
+ const docNames = Search._index.docnames;
508
+ const titles = Search._index.titles;
509
+
510
+ const scoreMap = new Map();
511
+ const fileMap = new Map();
512
+
513
+ // perform the search on the required terms
514
+ searchTerms.forEach((word) => {
515
+ const files = [];
516
+ const arr = [
517
+ { files: terms[word], score: Scorer.term },
518
+ { files: titleTerms[word], score: Scorer.title },
519
+ ];
520
+ // add support for partial matches
521
+ if (word.length > 2) {
522
+ const escapedWord = _escapeRegExp(word);
523
+ if (!terms.hasOwnProperty(word)) {
524
+ Object.keys(terms).forEach((term) => {
525
+ if (term.match(escapedWord))
526
+ arr.push({ files: terms[term], score: Scorer.partialTerm });
527
+ });
528
+ }
529
+ if (!titleTerms.hasOwnProperty(word)) {
530
+ Object.keys(titleTerms).forEach((term) => {
531
+ if (term.match(escapedWord))
532
+ arr.push({ files: titleTerms[term], score: Scorer.partialTitle });
533
+ });
534
+ }
535
+ }
536
+
537
+ // no match but word was a required one
538
+ if (arr.every((record) => record.files === undefined)) return;
539
+
540
+ // found search word in contents
541
+ arr.forEach((record) => {
542
+ if (record.files === undefined) return;
543
+
544
+ let recordFiles = record.files;
545
+ if (recordFiles.length === undefined) recordFiles = [recordFiles];
546
+ files.push(...recordFiles);
547
+
548
+ // set score for the word in each file
549
+ recordFiles.forEach((file) => {
550
+ if (!scoreMap.has(file)) scoreMap.set(file, {});
551
+ scoreMap.get(file)[word] = record.score;
552
+ });
553
+ });
554
+
555
+ // create the mapping
556
+ files.forEach((file) => {
557
+ if (!fileMap.has(file)) fileMap.set(file, [word]);
558
+ else if (fileMap.get(file).indexOf(word) === -1) fileMap.get(file).push(word);
559
+ });
560
+ });
561
+
562
+ // now check if the files don't contain excluded terms
563
+ const results = [];
564
+ for (const [file, wordList] of fileMap) {
565
+ // check if all requirements are matched
566
+
567
+ // as search terms with length < 3 are discarded
568
+ const filteredTermCount = [...searchTerms].filter(
569
+ (term) => term.length > 2
570
+ ).length;
571
+ if (
572
+ wordList.length !== searchTerms.size &&
573
+ wordList.length !== filteredTermCount
574
+ )
575
+ continue;
576
+
577
+ // ensure that none of the excluded terms is in the search result
578
+ if (
579
+ [...excludedTerms].some(
580
+ (term) =>
581
+ terms[term] === file ||
582
+ titleTerms[term] === file ||
583
+ (terms[term] || []).includes(file) ||
584
+ (titleTerms[term] || []).includes(file)
585
+ )
586
+ )
587
+ break;
588
+
589
+ // select one (max) score for the file.
590
+ const score = Math.max(...wordList.map((w) => scoreMap.get(file)[w]));
591
+ // add result to the result list
592
+ results.push([
593
+ docNames[file],
594
+ titles[file],
595
+ "",
596
+ null,
597
+ score,
598
+ filenames[file],
599
+ SearchResultKind.text,
600
+ ]);
601
+ }
602
+ return results;
603
+ },
604
+
605
+ /**
606
+ * helper function to return a node containing the
607
+ * search summary for a given text. keywords is a list
608
+ * of stemmed words.
609
+ */
610
+ makeSearchSummary: (htmlText, keywords, anchor) => {
611
+ const text = Search.htmlToText(htmlText, anchor);
612
+ if (text === "") return null;
613
+
614
+ const textLower = text.toLowerCase();
615
+ const actualStartPosition = [...keywords]
616
+ .map((k) => textLower.indexOf(k.toLowerCase()))
617
+ .filter((i) => i > -1)
618
+ .slice(-1)[0];
619
+ const startWithContext = Math.max(actualStartPosition - 120, 0);
620
+
621
+ const top = startWithContext === 0 ? "" : "...";
622
+ const tail = startWithContext + 240 < text.length ? "..." : "";
623
+
624
+ let summary = document.createElement("p");
625
+ summary.classList.add("context");
626
+ summary.textContent = top + text.substr(startWithContext, 240).trim() + tail;
627
+
628
+ return summary;
629
+ },
630
+ };
631
+
632
+ _ready(Search.init);