Skip to content

Commit fa4c634

Browse files
Docs/provide extra search features 3 (#330)
* Add layout and css changes * Add JS support for new HTML Search structure * Add annotations and change the system name
1 parent 2f728e0 commit fa4c634

File tree

14 files changed

+160
-130
lines changed

14 files changed

+160
-130
lines changed

__DOC_RESOURCES__/customStyles.css

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ body {
7878
padding-right:5px;
7979
margin-right:5px;
8080
color:grey;
81+
display: inline-block;
82+
width: 64px;
83+
font-size: 10px;
84+
text-align: center;
8185
}
8286

8387
.lunr-search-result-pill.action {
@@ -102,6 +106,17 @@ body {
102106
color:white;
103107
}
104108

109+
.lunr-search-result-pill.config {
110+
border:1px solid black;
111+
background-color: lightpink;
112+
}
113+
114+
.lunr-search-result-pill.test {
115+
border:1px solid black;
116+
background-color: mediumpurple;
117+
color: white;
118+
}
119+
105120
/**
106121
* ENSURE ALL RIGHT-SIDE MENUS ARE ALWAYS OPEN
107122
*/
@@ -116,20 +131,37 @@ body {
116131
max-height:9999px!important;
117132
}
118133

119-
.search-result-line-item {
120-
border-top: 1px solid #b1b0b0;
121-
padding-top: 12px;
122-
}
123-
124-
.symbol-title {
134+
.symbol-title.function {
125135
padding: 10px;
126136
border: 1px solid black;
127137
border-radius:2px;
128138
}
129139

130-
.symbol-title.namespace {
131-
padding: 0;
132-
border: none;
133-
border-radius:0;
140+
/**
141+
* Support left-right columns in the search
142+
*/
143+
.modal-body {
144+
display:flex;
145+
}
146+
147+
.modal-dialog {
148+
width:900px;
134149
}
135150

151+
.modal-body__left {
152+
width:500px;
153+
}
154+
.modal-body__right {
155+
width: 350px;
156+
padding-left: 10px;
157+
margin-left: 20px;
158+
border-left: 1px solid black;
159+
}
160+
161+
.pill-desc {
162+
white-space: initial;
163+
}
164+
165+
.pill-legend {
166+
padding-bottom:15px;
167+
}

__TESTS__/unit/actions/Overlay.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import {Timeline} from "../../../src/values/timeline";
1212
import {base64Encode} from "../../../src/internal/utils/base64Encode";
1313
import {TextStyle} from "../../../src/values/textStyle";
1414

15+
/**
16+
* @summary test
17+
* @namespace OverlayTests
18+
* @description Tests covering the various use cases for overlays
19+
*/
1520
describe('Tests for overlay actions', () => {
1621
it('Tests Image on Image with publicID encoding', () => {
1722
const asset = createNewImage();

__docTemplate/src/static/js/lunr-search.js

Lines changed: 55 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@
140140
* @type {jQuery}
141141
*/
142142
this.$body = $('#lunr-search-body');
143+
144+
/**
145+
* @summary The Bootstrap modals' body's left column found in the lunr-search-modal.tmpl.
146+
* @type {jQuery}
147+
*/
148+
this.$bodyLeft = $('#lunr-search-body').find('.modal-body__left');
149+
150+
/**
151+
* @summary The Bootstrap modals' body's right column found in the lunr-search-modal.tmpl.
152+
* @type {jQuery}
153+
*/
154+
this.$bodyRight = $('#lunr-search-body').find('.modal-body__right');
155+
143156
/**
144157
* @summary The Bootstrap modals' footer found in the lunr-search-modal.tmpl.
145158
* @type {jQuery}
@@ -154,7 +167,7 @@
154167
* @summary The maximum number of results to display per page.
155168
* @type {number}
156169
*/
157-
this.limit = 5;
170+
this.limit = 10;
158171
}
159172

160173
/**
@@ -202,82 +215,52 @@
202215
var self = this;
203216
return this.db.search(query).then(function (results) {
204217
var pages = [], index = -1;
205-
// first split the results into pages using the limit
206218

219+
// first split the results into pages using the limit
207220

208-
// Here we can perform one last sort, in case we need to.
209-
var __actions = [];
210-
var __qualifiers = [];
211-
var __namespaces = [];
212-
var __methods = [];
213-
var __classes = [];
214-
var __sdk = [];
215-
var __rest = [];
221+
var all = {};
222+
var summaries = ['action', 'qualifier', 'namespace','sdk', 'test',' config', 'method', 'class']
216223

217224
results.forEach(function(doclet){
218-
if (doclet.summary === 'action') {
219-
__actions.push(doclet);
220-
return;
221-
}
222-
223-
if (doclet.summary === 'qualifier') {
224-
__qualifiers.push(doclet);
225-
return;
225+
for (var i = 0; i < summaries.length; i++) {
226+
var summaryKey = summaries[i];
227+
if (summaryKey === doclet.summary) {
228+
all[summaryKey] = all[summaryKey] || [];
229+
all[summaryKey].push(doclet);
230+
return;
231+
} else if (summaryKey === doclet.kind) {
232+
all[summaryKey] = all[summaryKey] || [];
233+
all[summaryKey].push(doclet);
234+
return;
235+
}
226236
}
227237

228-
if (doclet.summary.toLowerCase() === 'sdk') {
229-
__sdk.push(doclet);
230-
return;
231-
}
238+
// if nothing was found
239+
all['rest'] = all['rest'] || [];
240+
all['rest'].push(doclet);
241+
});
232242

233-
if (doclet.kind === 'function') {
234-
__methods.push(doclet);
235-
return;
236-
}
243+
var sortedResults = [];
237244

238-
if (doclet.kind === 'classes') {
239-
__classes.push(doclet);
240-
return;
245+
summaries.forEach(function(summaryKey) {
246+
// make sure it exists, it might not!
247+
if (all[summaryKey]) {
248+
all[summaryKey].forEach(function(doclet){ sortedResults.push(doclet); });
241249
}
242-
243-
if (doclet.kind === 'namespace') {
244-
__namespaces.push(doclet);
245-
return;
246-
}
247-
__rest.push(doclet);
248250
});
249251

250-
results = [].concat(__namespaces, __actions, __qualifiers, __sdk, __classes, __methods, __rest);
252+
if (all['rest']) {
253+
all['rest'].forEach(function(doclet){ sortedResults.push(doclet); });
254+
}
251255

252-
$.each(results, function (i, result) {
256+
$.each(sortedResults, function (i, result) {
253257
if (i % self.limit === 0) {
254258
index = pages.push([]) - 1;
255259
}
256260
pages[index].push(result);
257261
});
258262
// once done clear the body and generate each page as it's own ul
259-
self.$body.empty();
260-
261-
var $div = $('<h4/>', {'style': 'font-weight:bold'}).text('Legend:');
262-
self.$body.append($div);
263-
264-
var $div = $('<div/>');
265-
$div.append($('<span/>', {'class': 'lunr-search-result-pill action'}).text('action'));
266-
$div.append($('<span/>', {'class': ''}).text(' - Contains the foo bar'));
267-
self.$body.append($div);
268-
269-
var $div = $('<div/>');
270-
$div.append($('<span/>', {'class': 'lunr-search-result-pill qualifier'}).text('qualifier'));
271-
$div.append($('<span/>', {'class': ''}).text(' - Contains the foo bar'));
272-
self.$body.append($div);
273-
274-
var $div = $('<div/>');
275-
$div.append($('<span/>', {'class': 'lunr-search-result-pill namespace'}).text('namespace'));
276-
$div.append($('<span/>', {'class': ''}).text(' - Contains the foo bar'));
277-
self.$body.append($div);
278-
279-
var $div = $('<h4/>', {'style': 'font-weight:bold'}).text('Results:');
280-
self.$body.append($div);
263+
self.$bodyLeft.empty();
281264

282265
$.each(pages, function (i, page) {
283266
var $ul = $('<ul/>', {'class': 'lunr-search-results-page', id: 'lunr-search-result-page-' + i});
@@ -289,64 +272,42 @@
289272
var $li = $('<li/>');
290273
$li.addClass('search-result-line-item');
291274

292-
293-
console.log(result);
294-
295-
// var summary = result.summary;
296-
// var isBuilder = summary.indexOf('@builder') >= 0;
275+
// sanitize the id, it can have .html, or .html#foobar, we want use use each part as a a searchable item, but without the html
276+
// Foo.Bar.Zoo.html#qwerty -> [Foo, Bar, Zoo, querty]
297277
var docletNamespace = result.id.replace('.html#', '.').replace('.html', '.').split('.').filter(function (a) {
298278
return a;
299279
});
300-
var type = docletNamespace[0]; // Actions, Values, SDK - master namespace
301-
var masterType;
302-
303-
// if (type === 'Actions' && isBuilder) {
304-
// masterType = 'Action builder';
305-
// } else if ( type === 'Values' && isBuilder) {
306-
// masterType = 'Qualifier builder';
307-
// } else if (kind === 'namespace') {
308-
// masterType = 'Namespace';
309-
// } else {
310-
// masterType = docletNamespace[0]+ kind;
311-
// }
312-
313-
masterType = docletNamespace[0] + ' -> ' + kind;
314280

315281
var $div = $('<div/>');
316-
var group = docletNamespace[1]; // Delivery, Resize etc.
317-
318-
console.log(docletNamespace);
319-
320-
// MasterType -> _Group_ -> Method?
321-
// Master type
322-
323-
var colors = ['black', 'black', 'black', 'teal'];
324282

325283
(result.summary || kind).split(' ').forEach(function (pillText) {
326284
if (pillText) {
327285
$div.append($('<span/>', {'class': 'lunr-search-result-pill' + ' ' + pillText.toLowerCase()}).text(pillText));
328286
}
329287
})
330288

331-
332289
docletNamespace.forEach(function (namespaceChunk, i) {
333-
$div.append($('<span/>', {'style': 'color:' + colors[i] || 'black' + ';font-weight:bold'}).text(namespaceChunk));
290+
var nextItemAsSpan = $('<span/>', {'style': 'font-weight:bold'});
291+
334292
if (docletNamespace[i + 1]) {
293+
$div.append($('<span/>', nextItemAsSpan).text(namespaceChunk));
335294
$div.append($('<span/>').text(' -> '));
295+
} else {
296+
var nextItemAsLink = $('<a/>', {
297+
href: result.id,
298+
'style': 'font-weight:bold',
299+
target: 'blank'
300+
}).text(namespaceChunk);
301+
$div.append(nextItemAsLink);
336302
}
337303
});
338304

339305
$li.append($div);
340-
var $a = $('<a/>', {
341-
href: result.id,
342-
'class': 'lunr-search-result-title'
343-
}).html(result.title).prepend($('<span/>', {'class': 'lunr-search-result-kind', text: result.kind + ': '}));
344-
$li.append($a);
345306
$li.append($('<div/>', {'class': 'lunr-search-result-desc'}).text(result.description))
346307
$ul.append($li);
347308
});
348309

349-
self.$body.append($ul);
310+
self.$bodyLeft.append($ul);
350311
});
351312
// if there is a pagination component from a previous search remove it now before we lose the reference to it
352313
if (self.$pagination.length) {
Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
11
<!-- start:lunr-search-modal.hbs -->
22
<div class="modal fade" id="lunr-search-modal">
3-
<div class="modal-dialog">
4-
<div class="modal-content">
5-
<div class="modal-header">
6-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
7-
<h4 class="modal-title">Search results</h4>
8-
</div>
9-
<div class="modal-body" id="lunr-search-body">
10-
</div>
11-
<div class="modal-footer" id="lunr-search-footer">
12-
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
13-
</div>
14-
</div><!-- /.modal-content -->
15-
</div><!-- /.modal-dialog -->
3+
<div class="modal-dialog">
4+
<div class="modal-content">
5+
<div class="modal-header">
6+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
7+
aria-hidden="true">&times;</span></button>
8+
<h4 class="modal-title">Search results</h4>
9+
</div>
10+
<div class="modal-body foobar" id="lunr-search-body">
11+
<div class="modal-body__left"></div>
12+
<div class="modal-body__right">
13+
<div style="font-weight:bold;text-decoration: underline">Quick Help</div>
14+
<div class="pill-legend">
15+
<span class="lunr-search-result-pill action">action</span><span class="pill-desc">An action object passed to a Transformation or an Asset</span>
16+
</div>
17+
18+
<div class="pill-legend">
19+
<span class="lunr-search-result-pill qualifier">qualifier</span><span class="pill-desc">A value passed to an Action, or to another Qualifier</span>
20+
</div>
21+
22+
<div class="pill-legend">
23+
<span class="lunr-search-result-pill namespace">namespace</span><span class="pill-desc">A collection of actions or qualifiers, grouped by a common theme</span>
24+
</div>
25+
26+
<div class="pill-legend">
27+
<span class="lunr-search-result-pill sdk">sdk</span><span class="pill-desc">Internal SDK methods and classes</span>
28+
</div>
29+
30+
<div class="pill-legend">
31+
<span class="lunr-search-result-pill test">test</span><span class="pill-desc">Unit test examples of the SDK</span>
32+
</div>
33+
34+
<div class="pill-legend">
35+
<span class="lunr-search-result-pill config">config</span><span class="pill-desc">Configuration related methods, interfaces and classes</span>
36+
</div>
37+
38+
<div>You can search for any of the above terms, for example "tests" or "action"</div>
39+
</div>
40+
</div>
41+
<div class="modal-footer" id="lunr-search-footer">
42+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
43+
</div>
44+
</div><!-- /.modal-content -->
45+
</div><!-- /.modal-dialog -->
1646
</div>
17-
<!-- end:lunr-search-modal.hbs -->
47+
<!-- end:lunr-search-modal.hbs -->

__docTemplate/src/tmpl/site/_layout.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
{{#if options.copyright}}
217217
<div class="copyright">{{{options.copyright}}}</div>
218218
{{/if}}
219-
<div class="generated-by">Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc {{config.version}}</a>{{#if options.includeDate}} on {{config.date}}{{/if}} using the <a href="https://github.com/steveush/foodoc">FooDoc template</a>.</div>
219+
<div class="generated-by">Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc {{config.version}}</a>{{#if options.includeDate}} on {{config.date}}{{/if}}</a>.</div>
220220
{{/block}}
221221
</footer>
222222
{{#if config.debug}}

jsdoc.config.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"dictionaries": ["jsdoc","closure"]
55
},
66
"source": {
7-
"include": ["src"],
8-
"includePattern": ".+\\.ts(doc|x)?$",
9-
"excludePattern": "(^|\\/|\\\\)_"
7+
"include": ["src", "__TESTS__"],
8+
"includePattern": ".+\\.ts(doc|x)?$"
109
},
1110
"plugins": [
1211
"plugins/markdown",
@@ -28,7 +27,7 @@
2827
"search": true,
2928
"monospaceLinks": true,
3029
"systemColor": "#3448C5",
31-
"systemName": "Cloudinary JS.2.0 SDK",
30+
"systemName": "Cloudinary JS SDK v2",
3231
"systemLogo": "__DOC_RESOURCES__/navLogo.png",
3332
"systemSummary": "@cloudinary/base",
3433
"favicon": "__DOC_RESOURCES__/favico.png",

0 commit comments

Comments
 (0)