Skip to content

Commit 5c8a666

Browse files
kamranayubblakeembrey
authored andcommitted
Move theme options to renderer (#230)
1 parent aab7af9 commit 5c8a666

File tree

4 files changed

+35
-38
lines changed

4 files changed

+35
-38
lines changed

src/lib/output/renderer.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class Renderer extends ChildableComponent<Application, RendererComponent>
6969
type: ParameterType.String,
7070
defaultValue: 'default'
7171
})
72-
themeName:string
72+
themeName:string;
7373

7474
@Option({
7575
name: 'disableOutputCheck',
@@ -78,7 +78,32 @@ export class Renderer extends ChildableComponent<Application, RendererComponent>
7878
})
7979
disableOutputCheck:boolean;
8080

81+
@Option({
82+
name: 'gaID',
83+
help: 'Set the Google Analytics tracking ID and activate tracking code.'
84+
})
85+
gaID:string;
86+
87+
@Option({
88+
name: 'gaSite',
89+
help: 'Set the site name for Google Analytics. Defaults to `auto`.',
90+
defaultValue: 'auto'
91+
})
92+
gaSite:string;
8193

94+
@Option({
95+
name: 'hideGenerator',
96+
help: 'Do not print the TypeDoc link at the end of the page.',
97+
type: ParameterType.Boolean
98+
})
99+
hideGenerator:boolean;
100+
101+
@Option({
102+
name: 'entryPoint',
103+
help: 'Specifies the fully qualified name of the root symbol. Defaults to global namespace.',
104+
type: ParameterType.String
105+
})
106+
entryPoint:string;
82107

83108
/**
84109
* Create a new Renderer instance.

src/lib/output/theme.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {ProjectReflection} from "../models/reflections/project";
33
import {UrlMapping} from "./models/UrlMapping";
44
import {NavigationItem} from "./models/NavigationItem";
55
import {RendererComponent} from "./components";
6-
import {Component} from "../utils/component";
6+
import {Component, Option} from "../utils/component";
77
import {Resources} from "./utils/resources";
8-
8+
import {ParameterType} from "../utils/options/declaration";
99

1010
/**
1111
* Base class of all themes.
@@ -50,15 +50,15 @@ import {Resources} from "./utils/resources";
5050
* of TypeDoc. If this file is not present, an instance of [[DefaultTheme]] will be used to render
5151
* this theme.
5252
*/
53-
@Component({name:"rendrer:theme", internal:true})
53+
@Component({name:"theme", internal:true})
5454
export class Theme extends RendererComponent
5555
{
5656
/**
5757
* The base path of this theme.
5858
*/
5959
basePath:string;
6060

61-
resources:Resources;
61+
resources:Resources;
6262

6363

6464
/**

src/lib/output/themes/DefaultTheme.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import {ReflectionGroup} from "../../models/ReflectionGroup";
88
import {UrlMapping} from "../models/UrlMapping";
99
import {NavigationItem} from "../models/NavigationItem";
1010
import {RendererEvent} from "../events";
11-
import {Option} from "../../utils/component";
12-
import {ParameterType} from "../../utils/options/declaration";
13-
11+
import {Component} from "../../utils/component";
1412

1513
/**
1614
* Defines a mapping of a [[Models.Kind]] to a template file.
@@ -47,34 +45,7 @@ export interface ITemplateMapping
4745
* [[BaseTheme]] implementation, this theme class will be used.
4846
*/
4947
export class DefaultTheme extends Theme
50-
{
51-
@Option({
52-
name: 'gaID',
53-
help: 'Set the Google Analytics tracking ID and activate tracking code.'
54-
})
55-
gaID:string;
56-
57-
@Option({
58-
name: 'gaSite',
59-
help: 'Set the site name for Google Analytics. Defaults to `auto`.',
60-
defaultValue: 'auto'
61-
})
62-
gaSite:string;
63-
64-
@Option({
65-
name: 'hideGenerator',
66-
help: 'Do not print the TypeDoc link at the end of the page.',
67-
type: ParameterType.Boolean
68-
})
69-
hideGenerator:boolean;
70-
71-
@Option({
72-
name: 'entryPoint',
73-
help: 'Specifies the fully qualified name of the root symbol. Defaults to global namespace.',
74-
type: ParameterType.String
75-
})
76-
entryPoint:string;
77-
48+
{
7849
/**
7950
* Mappings of reflections kinds to templates used by this theme.
8051
*/
@@ -170,7 +141,7 @@ export class DefaultTheme extends Theme
170141
* @returns The reflection that should be used as the entry point.
171142
*/
172143
getEntryPoint(project:ProjectReflection):ContainerReflection {
173-
var entryPoint = this.entryPoint;
144+
var entryPoint = this.owner.entryPoint;
174145
if (entryPoint) {
175146
var reflection = project.getChildByName(entryPoint);
176147
if (reflection) {

test/renderer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ describe('Renderer', function() {
6262
it('constructs', function() {
6363
app = new TypeDoc.Application({
6464
mode: 'Modules',
65-
logger: 'none',
65+
logger: 'console',
6666
target: 'ES5',
6767
module: 'CommonJS',
68+
gaSite: 'foo.com', // verify theme option without modifying output
6869
noLib: true
6970
});
7071
});

0 commit comments

Comments
 (0)