Skip to content

Commit

Permalink
docs: update template
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Sep 4, 2023
1 parent 6f751c7 commit 5342d78
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 41 deletions.
24 changes: 18 additions & 6 deletions DisCatSharp.Docs/dcs/layout/_master.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@
{{#_urlNormalizationActive}}
<meta name="docfx:urlnormalizationactive" content="true">{{/_urlNormalizationActive}}
<meta name="docfx:docurl" content="{{docurl}}">{{/docurl}}
<meta name="loc:inThisArticle" content="{{__global.inThisArticle}}">
<meta name="loc:searchResultsCount" content="{{__global.searchResultsCount}}">
<meta name="loc:searchNoResults" content="{{__global.searchNoResults}}">
<meta name="loc:tocFilter" content="{{__global.tocFilter}}">
<meta name="loc:nextArticle" content="{{__global.nextArticle}}">
<meta name="loc:prevArticle" content="{{__global.prevArticle}}">
<meta name="loc:themeLight" content="{{__global.themeLight}}">
<meta name="loc:themeDark" content="{{__global.themeDark}}">
<meta name="loc:themeAuto" content="{{__global.themeAuto}}">
<meta name="loc:changeTheme" content="{{__global.changeTheme}}">
<meta name="loc:copy" content="{{__global.copy}}">
<script src="//code.jquery.com/jquery-latest.js"></script>
<script defer src='https://static.cloudflareinsights.com/beacon.min.js'
data-cf-beacon='{"token": "de6c22ce0b3e4c17bb78c8c31b4e695b"}'></script>
Expand Down Expand Up @@ -212,9 +223,11 @@
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="{{_appLogoUrl}}{{^_appLogoUrl}}{{_rel}}index.html{{/_appLogoUrl}}"><img
id="logo" class="svg" src="{{_rel}}{{{_appLogoPath}}}{{^_appLogoPath}}logo.svg{{/_appLogoPath}}"
alt="{{_appName}}">&nbsp;&nbsp;{{_appName}}</a>
<a class="navbar-brand" href="{{_appLogoUrl}}{{^_appLogoUrl}}{{_rel}}index.html{{/_appLogoUrl}}">
<img id="logo" class="svg"
src="{{_rel}}{{{_appLogoPath}}}{{^_appLogoPath}}logo.svg{{/_appLogoPath}}" alt="{{_appName}}">
&nbsp;&nbsp;{{_appName}}
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse"
data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false"
aria-label="Toggle navigation">
Expand Down Expand Up @@ -268,18 +281,17 @@
{{^_disableContribution}}
<div class="contribution d-print-none">
{{#sourceurl}}
<a href="{{sourceurl}}" class="edit-link">Edit this page</a>
<a href="{{sourceurl}}" class="edit-link">{{__global.improveThisDoc}}</a>
{{/sourceurl}}
{{^sourceurl}}{{#docurl}}
<a href="{{docurl}}" class="edit-link">Edit this page</a>
<a href="{{docurl}}" class="edit-link">{{__global.improveThisDoc}}</a>
{{/docurl}}{{/sourceurl}}
</div>
{{/_disableContribution}}

{{^_disableNextArticle}}
<div class="next-article d-print-none border-top" id="nextArticle"></div>
{{/_disableNextArticle}}

</div>

<div class="affix">
Expand Down
64 changes: 32 additions & 32 deletions DisCatSharp.Docs/dcs/public/docfx.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions DisCatSharp.Docs/dcs/public/docfx.min.js.map

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions DisCatSharp.Docs/dcs/toc.json.js
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;
}
}
}
3 changes: 3 additions & 0 deletions DisCatSharp.Docs/dcs/toc.json.tmpl
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}}}

0 comments on commit 5342d78

Please sign in to comment.