Skip to content

Commit e5813bb

Browse files
thegeckoblakeembrey
authored andcommitted
Added toc option to allow restriction of top-level menu items (#407)
1 parent e073d95 commit e5813bb

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/lib/output/plugins/TocPlugin.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export class TocPlugin extends RendererComponent
4040
model = model.parent;
4141
}
4242

43+
var tocRestriction = this.owner.toc;
4344
page.toc = new NavigationItem();
44-
TocPlugin.buildToc(model, trail, page.toc);
45+
TocPlugin.buildToc(model, trail, page.toc, tocRestriction);
4546
}
4647

4748

@@ -51,8 +52,9 @@ export class TocPlugin extends RendererComponent
5152
* @param model The models whose children should be written to the toc.
5253
* @param trail Defines the active trail of expanded toc entries.
5354
* @param parent The parent [[NavigationItem]] the toc should be appended to.
55+
* @param restriction The restricted table of contents.
5456
*/
55-
static buildToc(model:Reflection, trail:Reflection[], parent:NavigationItem) {
57+
static buildToc(model:Reflection, trail:Reflection[], parent:NavigationItem, restriction?: string[]) {
5658
var index = trail.indexOf(model);
5759
var children = model['children'] || [];
5860

@@ -64,6 +66,9 @@ export class TocPlugin extends RendererComponent
6466
TocPlugin.buildToc(child, trail, item);
6567
} else {
6668
children.forEach((child:DeclarationReflection) => {
69+
70+
if (restriction && restriction.length > 0 && restriction.indexOf(child.name) === -1) return;
71+
6772
if (child.kindOf(ReflectionKind.SomeModule)) {
6873
return;
6974
}

src/lib/output/renderer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ export class Renderer extends ChildableComponent<Application, RendererComponent>
105105
})
106106
entryPoint:string;
107107

108+
@Option({
109+
name: 'toc',
110+
help: 'Specifies the top level table of contents.',
111+
type: ParameterType.Array
112+
})
113+
toc:string[];
114+
108115
/**
109116
* Create a new Renderer instance.
110117
*

src/lib/utils/options/declaration.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export enum ParameterType {
1212
Number,
1313
Boolean,
1414
Map,
15-
Mixed
15+
Mixed,
16+
Array
1617
}
1718

1819

@@ -96,6 +97,13 @@ export class OptionDeclaration
9697
case ParameterType.String:
9798
value = value || "";
9899
break;
100+
case ParameterType.Array:
101+
if (!value) {
102+
value = [];
103+
} else if (typeof value === "string") {
104+
value = value.split(",");
105+
}
106+
break;
99107
case ParameterType.Map:
100108
if (this.map !== 'object') {
101109
var key = value ? (value + "").toLowerCase() : '';

0 commit comments

Comments
 (0)