Skip to content

Commit

Permalink
fix(deps): @link to all miscellaneous
Browse files Browse the repository at this point in the history
fix #416
  • Loading branch information
vogloblinsky committed Dec 22, 2017
1 parent fd8bbfa commit 0194c1b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/app/compiler/dependencies.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

export interface IDep {
id?: string;
type: string;
type?: string;
ctype: string;
name: string;
}

Expand Down
21 changes: 11 additions & 10 deletions src/app/compiler/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class Dependencies {
let functionDep: IFunctionDecDep = {
name,
file: file,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'function',
description: this.visitEnumTypeAliasFunctionDeclarationDescription(node)
};
Expand All @@ -419,7 +419,7 @@ export class Dependencies {
let enumDeps: IEnumDecDep = {
name,
childs: infos,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'enum',
description: this.visitEnumTypeAliasFunctionDeclarationDescription(node),
file: file
Expand All @@ -430,7 +430,7 @@ export class Dependencies {
let name = infos.name;
let typeAliasDeps: ITypeAliasDecDep = {
name,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'typealias',
rawtype: this.classHelper.visitType(node),
file: file,
Expand Down Expand Up @@ -513,7 +513,7 @@ export class Dependencies {
let name = infos.name;
let deps: any = {
name,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'variable',
file: file
};
Expand All @@ -532,14 +532,15 @@ export class Dependencies {
this.routerParser.addModuleWithRoutes(name, [routingInitializer], file);
this.routerParser.addModule(name, [routingInitializer]);
}

outputSymbols.miscellaneous.variables.push(deps);
}
if (ts.isTypeAliasDeclaration(node)) {
let infos = this.visitTypeDeclaration(node);
let name = infos.name;
let deps: any = {
let deps: ITypeAliasDecDep = {
name,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'typealias',
rawtype: this.classHelper.visitType(node),
file: file,
Expand All @@ -553,9 +554,9 @@ export class Dependencies {
if (ts.isFunctionDeclaration(node)) {
let infos = this.visitFunctionDeclaration(node);
let name = infos.name;
let deps: any = {
let deps: IFunctionDecDep = {
name,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'function',
file: file,
description: this.visitEnumTypeAliasFunctionDeclarationDescription(node)
Expand All @@ -571,10 +572,10 @@ export class Dependencies {
if (ts.isEnumDeclaration(node)) {
let infos = this.visitEnumDeclaration(node);
let name = node.name.text;
let deps = {
let deps: IEnumDecDep = {
name,
childs: infos,
type: 'miscellaneous',
ctype: 'miscellaneous',
subtype: 'enum',
description: this.visitEnumTypeAliasFunctionDeclarationDescription(node),
file: file
Expand Down
16 changes: 14 additions & 2 deletions src/app/engines/dependencies.engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,20 @@ export class DependenciesEngine {
}

public findInCompodoc(name: string) {
let mergedData = _.concat([], this.modules, this.components, this.directives,
this.injectables, this.interceptors, this.interfaces, this.pipes, this.classes);
let mergedData = _.concat([],
this.modules,
this.components,
this.directives,
this.injectables,
this.interceptors,
this.interfaces,
this.pipes,
this.classes,
this.miscellaneous.enumerations,
this.miscellaneous.typealiases,
this.miscellaneous.variables,
this.miscellaneous.functions
);
let result = _.find(mergedData, { 'name': name } as any);
return result || false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/engines/html-engine-helpers/link-type.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class LinkTypeHelper implements IHtmlEngineHelper {
_result.data.type = 'classe';
}
context.type.href = '../' + _result.data.type + 's/' + _result.data.name + '.html';
if (_result.data.type === 'miscellaneous') {
if (_result.data.type === 'miscellaneous' || (_result.data.ctype && _result.data.ctype === 'miscellaneous')) {
let mainpage = '';
switch (_result.data.subtype) {
case 'enum':
Expand All @@ -40,7 +40,7 @@ export class LinkTypeHelper implements IHtmlEngineHelper {
case 'variable':
mainpage = 'variables';
}
context.type.href = '../' + _result.data.type + '/' + mainpage + '.html#' + _result.data.name;
context.type.href = '../' + _result.data.ctype + '/' + mainpage + '.html#' + _result.data.name;
}
context.type.target = '_self';
} else {
Expand Down
22 changes: 20 additions & 2 deletions src/app/engines/html-engine-helpers/parse-description.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class ParseDescriptionHelper implements IHtmlEngineHelper {
let rootPath;
let stringtoReplace;
let anchor = '';
let label;
let pageName;

split = splitLinkText(tagInfo.text);

Expand All @@ -41,6 +43,9 @@ export class ParseDescriptionHelper implements IHtmlEngineHelper {

if (result) {

label = result.name;
pageName = result.name;

if (leadingText) {
stringtoReplace = '[' + leadingText + ']' + tagInfo.completeTag;
} else if (leading.leadingText !== undefined) {
Expand All @@ -53,6 +58,19 @@ export class ParseDescriptionHelper implements IHtmlEngineHelper {

if (result.type === 'class') {
result.type = 'classe';
} else if (result.type === 'miscellaneous' || (result.ctype && result.ctype === 'miscellaneous')) {
result.type = 'miscellaneou';
label = result.name;
anchor = '#' + result.name;
if (result.subtype === 'enum') {
pageName = 'enumerations';
} else if (result.subtype === 'function') {
pageName = 'functions';
} else if (result.subtype === 'typealias') {
pageName = 'typealiases';
} else if (result.subtype === 'variable') {
pageName = 'variables';
}
}

rootPath = '';
Expand All @@ -70,15 +88,15 @@ export class ParseDescriptionHelper implements IHtmlEngineHelper {
break;
}

let label = result.name;
if (leading.leadingText !== undefined) {
label = leading.leadingText;
}
if (typeof split.linkText !== 'undefined') {
label = split.linkText;
}

newLink = `<a href="${rootPath}${result.type}s/${result.name}.html${anchor}">${label}</a>`;
newLink = `<a href="${rootPath}${result.type}s/${pageName}.html${anchor}">${label}</a>`;

return string.replace(stringtoReplace, newLink);
} else {
return string;
Expand Down
8 changes: 8 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,12 @@ describe('CLI simple generation - big app', () => {
expect(file).to.contain('<code>./home.component.html</code>');
expect(file).to.contain('<td class="col-md-3">template</td>');
});

it('should support @link to miscellaneous', () => {
let file = read('documentation/components/AboutComponent.html');
expect(file).to.contain('<a href="../miscellaneous/variables.html#PIT">PIT</a>');
expect(file).to.contain('<a href="../miscellaneous/enumerations.html#Direction">Direction</a>');
expect(file).to.contain('<a href="../miscellaneous/typealiases.html#ChartChange">ChartChange</a>');
expect(file).to.contain('<a href="../miscellaneous/functions.html#foo">foo</a>');
});
});
8 changes: 8 additions & 0 deletions test/src/todomvc-ng2/src/app/about/about.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import { Subscription } from 'rxjs/Subscription';

/**
* The about component
*
* {@link PIT}
*
* {@link Direction}
*
* {@link ChartChange}
*
* {@link foo}
*
* Display some text with links for details about TodoMVC & Compodoc.
*/
Expand Down

0 comments on commit 0194c1b

Please sign in to comment.