Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions docs/template/api_wiki/ManagedReference.extension.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@

exports.postTransform = function (model) {
console.log("ManagedReference.extension.js EXECUTED");
console.log("Root model: " + JSON.stringify(model));

setMemberFlags(model);

return model;
};

function setMemberFlags(item, inheritedType) {
if (!item || typeof item !== 'object') return;

// Determine the current item's declaration type.
var t = item.type
? String(item.type).toLowerCase()
: inheritedType;

// DocFX member-group containers identify their children
// through properties such as inMethod, inProperty, etc.
// Member-group containers carry their kind in typePropertyName (inMethod, ...)
if (item.typePropertyName) {
var groupType = String(item.typePropertyName)
.replace(/^in/, '')
Expand All @@ -28,29 +21,53 @@ function setMemberFlags(item, inheritedType) {
}
}

// Container / Type declarations
// ---- Declaration kinds -------------------------------------------------
// postTransform runs AFTER ManagedReference.common.js's transform, which
// already set isClass = true for class/struct/interface/delegate because
// ManagedReference.html.primary.tmpl dispatches on isClass. Setting
// isClass = (t === 'class') here would clobber that and blank every
// interface, struct and delegate page. Mirror common.js instead.
item.isNamespace = (t === 'namespace');
item.isClass = (t === 'class');
item.isClass = (
t === 'class' ||
t === 'struct' ||
t === 'interface' ||
t === 'delegate'
);
item.isStruct = (t === 'struct');
item.isInterface = (t === 'interface');
item.isEnum = (t === 'enum');
item.isDelegate = (t === 'delegate');

// Member declarations
// ---- Member kinds ------------------------------------------------------
item.isConstructor = (t === 'constructor');
item.isMethod = (t === 'method');
item.isProperty = (t === 'property');
item.isField = (t === 'field');
item.isEvent = (t === 'event');
item.isOperator = (t === 'operator');

// Useful grouped helpers
// ---- in* flags, as consumed by the partials ({{#inClass}}, {{#inEnum}}) --
// common.js sets these only on the root and on group containers. Emit them
// here too so the partials never depend on transform order.
item.inNamespace = (t === 'namespace');
item.inClass = (t === 'class');
item.inStruct = (t === 'struct');
item.inInterface = (t === 'interface');
item.inEnum = (t === 'enum');
item.inDelegate = (t === 'delegate');

item.inConstructor = (t === 'constructor');
item.inMethod = (t === 'method');
item.inProperty = (t === 'property');
item.inField = (t === 'field');
item.inEvent = (t === 'event');
item.inOperator = (t === 'operator');

// ---- Aggregates --------------------------------------------------------
item.isType = (
item.isClass ||
item.isStruct ||
item.isInterface ||
item.isEnum ||
item.isDelegate
item.isEnum
);

item.isMember = (
Expand All @@ -62,8 +79,6 @@ function setMemberFlags(item, inheritedType) {
item.isOperator
);

// Recursively process nested models.
// Pass the current group type down to its children.
if (Array.isArray(item.children)) {
item.children.forEach(function (child) {
setMemberFlags(child, t);
Expand All @@ -75,4 +90,4 @@ function setMemberFlags(item, inheritedType) {
setMemberFlags(child, t);
});
}
}
}
26 changes: 26 additions & 0 deletions docs/template/api_wiki/ManagedReference.html.primary.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{!Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license.}}
{{!master(layout/_master.tmpl)}}

{{#isNamespace}}
{{>partials/namespace}}
{{/isNamespace}}

{{#_splitReference}}
{{#isClass}}
{{>partials/class.memberpage}}
{{/isClass}}
{{/_splitReference}}

{{^_splitReference}}
{{^isEnum}}
{{#isType}}
{{>partials/class}}
{{/isType}}
{{/isEnum}}
{{/_splitReference}}

{{#isEnum}}
{{>partials/enum}}
{{/isEnum}}

{{>partials/customMREFContent}}
31 changes: 23 additions & 8 deletions docs/template/api_wiki/partials/class.header.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,33 @@
<summary>
<h2 class="extensionMethods">Extension Methods (Click me to Expand)</h2>
</summary>
<p>The following are methods in which you can use that act as extensions to this type: </p>
<p>The following are methods which can be used as extensions to this type:</p>
<div class="typelist-content">
{{/extensionMethods.0}}

{{#extensionMethods}}
<div>
{{#definition}}
<xref uid="{{definition}}" altProperty="fullName" displayProperty="nameWithType"/>
{{/definition}}
{{^definition}}
<xref uid="{{uid}}" altProperty="fullName" displayProperty="nameWithType"/>
{{/definition}}
<div class="extension-method">
<div class="extension-method-header">
{{#definition}}
<xref uid="{{definition}}" altProperty="fullName" displayProperty="nameWithType"/>
{{/definition}}
{{^definition}}
<xref uid="{{uid}}" altProperty="fullName" displayProperty="nameWithType"/>
{{/definition}}
</div>

{{#definition}}
<xref uid="{{definition}}" template="partials/extensionMethod.summary.tmpl"/>
{{/definition}}
{{^definition}}
<xref uid="{{uid}}" template="partials/extensionMethod.summary.tmpl"/>
{{/definition}}

{{#specName.0.value}}
<div class="codewrapper">
<pre><code class="lang-csharp hljs">{{{specName.0.value}}}</code></pre>
</div>
{{/specName.0.value}}
</div>
{{/extensionMethods}}

Expand Down
3 changes: 3 additions & 0 deletions docs/template/api_wiki/partials/extensionMethod.summary.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#summary}}
<div class="markdown level1 summary">{{{summary}}}</div>
{{/summary}}
Loading