-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
149 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
exports.transform = function (model) { | ||
|
||
if (model.memberLayout === 'SeparatePages') { | ||
model = transformMemberPage(model); | ||
} | ||
|
||
for (var key in model) { | ||
if (key[0] === '_') { | ||
delete model[key] | ||
} | ||
} | ||
|
||
return { | ||
content: JSON.stringify(model) | ||
}; | ||
} | ||
|
||
function transformMemberPage(model) { | ||
var groupNames = { | ||
"constructor": { key: "constructorsInSubtitle" }, | ||
"field": { key: "fieldsInSubtitle" }, | ||
"property": { key: "propertiesInSubtitle" }, | ||
"method": { key: "methodsInSubtitle" }, | ||
"event": { key: "eventsInSubtitle" }, | ||
"operator": { key: "operatorsInSubtitle" }, | ||
"eii": { key: "eiisInSubtitle" }, | ||
}; | ||
|
||
groupChildren(model); | ||
transformItem(model, 1); | ||
return model; | ||
|
||
function groupChildren(item) { | ||
if (!item || !item.items || item.items.length == 0) { | ||
return; | ||
} | ||
var grouped = {}; | ||
var items = []; | ||
item.items.forEach(function (element) { | ||
groupChildren(element); | ||
if (element.type) { | ||
var type = element.isEii ? "eii" : element.type.toLowerCase(); | ||
if (!grouped.hasOwnProperty(type)) { | ||
if (!groupNames.hasOwnProperty(type)) { | ||
groupNames[type] = { | ||
name: element.type | ||
}; | ||
console.log(type + " is not predefined type, use its type name as display name.") | ||
} | ||
grouped[type] = []; | ||
} | ||
grouped[type].push(element); | ||
} else { | ||
items.push(element); | ||
} | ||
}, this); | ||
|
||
// With order defined in groupNames | ||
for (var key in groupNames) { | ||
if (groupNames.hasOwnProperty(key) && grouped.hasOwnProperty(key)) { | ||
items.push({ | ||
name: model.__global[groupNames[key].key] || groupNames[key].name, | ||
items: grouped[key] | ||
}) | ||
} | ||
} | ||
|
||
item.items = items; | ||
} | ||
|
||
function transformItem(item, level) { | ||
// set to null in case mustache looks up | ||
item.topicHref = item.topicHref || null; | ||
item.tocHref = item.tocHref || null; | ||
item.name = item.name || null; | ||
|
||
item.level = level; | ||
|
||
if (item.items && item.items.length > 0) { | ||
item.leaf = false; | ||
var length = item.items.length; | ||
for (var i = 0; i < length; i++) { | ||
transformItem(item.items[i], level + 1); | ||
}; | ||
} else { | ||
item.items = []; | ||
item.leaf = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}} | ||
|
||
{{{content}}} |