diff --git a/docs/generate.py b/docs/generate.py
index 1b467727..5c607460 100755
--- a/docs/generate.py
+++ b/docs/generate.py
@@ -433,20 +433,26 @@ def generate_documentation(scheme_file):
layer = TLParser.find_layer(scheme_file)
types = set()
methods = []
+ constructors = []
for tlobject in tlobjects:
if tlobject.is_function:
methods.append(tlobject)
+ else:
+ constructors.append(tlobject)
types.add(tlobject.result)
types = sorted(types)
methods = sorted(methods, key=lambda m: m.name)
+ constructors = sorted(constructors, key=lambda c: c.name)
request_names = ', '.join('"' + get_class_name(m) + '"' for m in methods)
type_names = ', '.join('"' + get_class_name(t) + '"' for t in types)
+ constructor_names = ', '.join('"' + get_class_name(t) + '"' for t in constructors)
request_urls = ', '.join('"' + get_create_path_for(m) + '"' for m in methods)
type_urls = ', '.join('"' + get_path_for_type(t) + '"' for t in types)
+ constructor_urls = ', '.join('"' + get_create_path_for(t) + '"' for t in constructors)
replace_dict = {
'type_count': len(types),
@@ -456,8 +462,10 @@ def generate_documentation(scheme_file):
'request_names': request_names,
'type_names': type_names,
+ 'constructor_names': constructor_names,
'request_urls': request_urls,
- 'type_urls': type_urls
+ 'type_urls': type_urls,
+ 'constructor_urls': constructor_urls
}
with open('../res/core.html') as infile:
diff --git a/docs/res/core.html b/docs/res/core.html
index b7875a82..bc5c04b3 100644
--- a/docs/res/core.html
+++ b/docs/res/core.html
@@ -19,7 +19,21 @@
placeholder="Search for requests and types…" />
@@ -196,19 +210,65 @@ messages = result.messages
contentDiv = document.getElementById("contentDiv");
searchDiv = document.getElementById("searchDiv");
searchBox = document.getElementById("searchBox");
-searchTable = document.getElementById("searchTable");
+
+// Search lists
+methodsList = document.getElementById("methodsList");
+methodsCount = document.getElementById("methodsCount");
+
+typesList = document.getElementById("typesList");
+typesCount = document.getElementById("typesCount");
+
+constructorsList = document.getElementById("constructorsList");
+constructorsCount = document.getElementById("constructorsCount");
try {
requests = [{request_names}];
types = [{type_names}];
+ constructors = [{constructor_names}];
requestsu = [{request_urls}];
typesu = [{type_urls}];
+ constructorsu = [{constructor_urls}];
} catch (e) {
requests = [];
types = [];
- requetsu = [];
+ constructors = [];
+ requestsu = [];
typesu = [];
+ constructorsu = [];
+}
+
+// Given two input arrays "original" and "original urls" and a query,
+// return a pair of arrays with matching "query" elements from "original".
+//
+// TODO Perhaps return an array of pairs instead a pair of arrays (for cache).
+function getSearchArray(original, originalu, query) {
+ var destination = [];
+ var destinationu = [];
+
+ for (var i = 0; i < original.length; ++i) {
+ if (original[i].toLowerCase().indexOf(query) != -1) {
+ destination.push(original[i]);
+ destinationu.push(originalu[i]);
+ }
+ }
+
+ return [destination, destinationu];
+}
+
+// Modify "countSpan" and "resultList" accordingly based on the elements
+// given as [[elements], [element urls]] (both with the same length)
+function buildList(countSpan, resultList, foundElements) {
+ var result = "";
+ for (var i = 0; i < foundElements[0].length; ++i) {
+ result += '
';
+ result += '';
+ result += foundElements[0][i];
+ result += '';
+ }
+
+ countSpan.innerHTML = "" + foundElements[0].length;
+ resultList.innerHTML = result;
}
function updateSearch() {
@@ -217,46 +277,16 @@ function updateSearch() {
searchDiv.style.display = "";
var query = searchBox.value.toLowerCase();
- var foundRequests = [];
- var foundRequestsu = [];
- for (var i = 0; i < requests.length; ++i) {
- if (requests[i].toLowerCase().indexOf(query) != -1) {
- foundRequests.push(requests[i]);
- foundRequestsu.push(requestsu[i]);
- }
- }
- var foundTypes = [];
- var foundTypesu = [];
- for (var i = 0; i < types.length; ++i) {
- if (types[i].toLowerCase().indexOf(query) != -1) {
- foundTypes.push(types[i]);
- foundTypesu.push(typesu[i]);
- }
- }
+ var foundRequests = getSearchArray(requests, requestsu, query);
+ var foundTypes = getSearchArray(types, typesu, query);
+ var foundConstructors = getSearchArray(
+ constructors, constructorsu, query
+ );
- var top = foundRequests.length > foundTypes.length ?
- foundRequests.length : foundTypes.length;
-
- result = "";
- for (var i = 0; i <= top; ++i) {
- result += "
";
-
- if (i < foundRequests.length) {
- result +=
- ''+foundRequests[i]+'';
- }
-
- result += " | ";
-
- if (i < foundTypes.length) {
- result +=
- ''+foundTypes[i]+'';
- }
-
- result += " |
";
- }
- searchTable.innerHTML = result;
+ buildList(methodsCount, methodsList, foundRequests);
+ buildList(typesCount, typesList, foundTypes);
+ buildList(constructorsCount, constructorsList, foundConstructors);
} else {
contentDiv.style.display = "";
searchDiv.style.display = "none";
diff --git a/docs/res/css/docs.css b/docs/res/css/docs.css
index 9a9b710b..05c61c9f 100644
--- a/docs/res/css/docs.css
+++ b/docs/res/css/docs.css
@@ -52,7 +52,7 @@ table td {
margin: 0 8px -2px 0;
}
-h1 {
+h1, summary.title {
font-size: 24px;
}
@@ -137,6 +137,26 @@ button:hover {
color: #fff;
}
+/* https://www.w3schools.com/css/css_navbar.asp */
+ul.together {
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ overflow: hidden;
+}
+
+ul.together li {
+ float: left;
+}
+
+ul.together li a {
+ display: block;
+ border-radius: 8px;
+ background: #f0f4f8;
+ padding: 4px 8px;
+ margin: 8px;
+}
+
/* https://stackoverflow.com/a/30810322 */
.invisible {
left: 0;
@@ -153,7 +173,7 @@ button:hover {
}
@media (max-width: 640px) {
- h1 {
+ h1, summary.title {
font-size: 18px;
}
h3 {