Skip to content

Commit 38fd208

Browse files
committed
Include the properties required for the new sidebar
This also includes removes the filter by description and whether a doc object has signatures so that everything is included. Any doc objects with @hide are still filtered out.
1 parent abb46b1 commit 38fd208

File tree

3 files changed

+51
-27
lines changed

3 files changed

+51
-27
lines changed

generators/search-map.js

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,43 @@ module.exports = function(docMap, siteConfig) {
2424
var searchMap = {};
2525
var name;
2626
for (name in docMap) {
27-
if (docMap.hasOwnProperty(name)) {
28-
var docObj = docMap[name];
29-
var description = docObj.description && docObj.description.trim();
30-
var signaturesHaveContent = docObj.signatures && docObj.signatures.some(function(signature){
31-
return signature.params || signature.return || signature.options;
32-
});
33-
// If there is no body, it's likely we don't want to index it
34-
if ((description && description !== 'undefined') || signaturesHaveContent) {
35-
var helpers = bitDocsHelpers(docMap, siteConfig, function(){
36-
return docObj;
37-
}, {});
27+
var docObj = (docMap.hasOwnProperty(name)) ? docMap[name] : null;
28+
if (docObj && !docObj.hide) {
29+
30+
var helpers = bitDocsHelpers(docMap, siteConfig, function(){
31+
return docObj;
32+
}, {});
3833

39-
// Convert bit-docs markdown to HTML
40-
var descriptionAsHTML = helpers.makeLinks(helpers.makeHtml(description));
34+
// Convert bit-docs markdown to HTML
35+
var description = docObj.description && docObj.description.trim();
36+
var descriptionAsHTML = helpers.makeLinks(helpers.makeHtml(description));
4137

42-
// Only allow certain HTML elements
43-
var descriptionAsStrippedHTML = striptags(descriptionAsHTML, ['a', 'code', 'em', 'strong']);
38+
// Only allow certain HTML elements
39+
var descriptionAsStrippedHTML = striptags(descriptionAsHTML, ['a', 'code', 'em', 'strong']);
4440

45-
var searchObj = {
46-
name: docObj.name,
47-
title: docObj.title,
48-
description: descriptionAsStrippedHTML,
49-
url: filename(docObj, siteConfig),
50-
dest: 'doc/'
51-
};
52-
searchMap[name] = searchObj;
41+
var searchObj = {
42+
name: docObj.name,
43+
title: docObj.title,
44+
description: descriptionAsStrippedHTML,
45+
url: filename(docObj, siteConfig),
46+
dest: 'doc/'
47+
};
48+
if (docObj.collection) {
49+
searchObj.collection = docObj.collection;
50+
}
51+
if (docObj.order) {
52+
searchObj.order = docObj.order;
53+
}
54+
if (docObj.parent) {
55+
searchObj.parent = docObj.parent;
56+
}
57+
if (docObj.subchildren) {
58+
searchObj.subchildren = docObj.subchildren;
59+
}
60+
if (docObj.type) {
61+
searchObj.type = docObj.type;
5362
}
63+
searchMap[name] = searchObj;
5464
}
5565
}
5666

test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ describe("bitDocs.generators.searchMap",function(){
4242
});
4343
});
4444

45+
it("(bitDocs.generators.searchMap.searchMap) Excludes docObjects with @hide", function(){
46+
return docMapPromise.then(function(docMap){
47+
return searchMap(docMap, siteConfig).then(function(searchMapResult){
48+
assert.ok(!searchMapResult['guides/what-is-canjs']);
49+
});
50+
});
51+
});
52+
4553
it("(bitDocs.generators.searchMap.searchMap) Strips HTML from the description", function(){
4654
return docMapPromise.then(function(docMap){
4755
return searchMap(docMap, siteConfig);
@@ -60,18 +68,18 @@ describe("bitDocs.generators.searchMap",function(){
6068
});
6169
});
6270

63-
it("(bitDocs.generators.searchMap.searchMap) Filters hidden and empty docObjects", function(){
71+
it("(bitDocs.generators.searchMap.searchMap) Does not filter hidden and empty docObjects", function(){
6472
return docMapPromise.then(function(docMap){
6573
return searchMap(docMap, siteConfig).then(function(searchMapResult){
66-
assert.ok(!searchMapResult.Component);
74+
assert.ok(searchMapResult.Component);
6775
});
6876
});
6977
});
7078

71-
it("(bitDocs.generators.searchMap.searchMap) Filters docObjects with only “undefined\n” as their description", function(){
79+
it("(bitDocs.generators.searchMap.searchMap) Does not filter docObjects with only “undefined\n” as their description", function(){
7280
return docMapPromise.then(function(docMap){
7381
return searchMap(docMap, siteConfig).then(function(searchMapResult){
74-
assert.ok(!searchMapResult['can.Control']);
82+
assert.ok(searchMapResult['can.Control']);
7583
});
7684
});
7785
});

testDocMap.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,11 @@
178178
"description": "undefined\n",
179179
"url": "can.Control.html",
180180
"dest": "doc/"
181+
},
182+
"guides/what-is-canjs": {
183+
"description": "\n",
184+
"name": "guides/what-is-canjs",
185+
"title": "What is CanJS?",
186+
"hide": true
181187
}
182188
}

0 commit comments

Comments
 (0)