@@ -2,8 +2,9 @@ import * as Util from "util";
22
33import { Reflection } from "../../models/reflections/abstract" ;
44import { Component , ContextAwareRendererComponent } from "../components" ;
5- import { MarkdownEvent } from "../events" ;
6-
5+ import { MarkdownEvent , RendererEvent } from "../events" ;
6+ import { Option } from "../../utils/component" ;
7+ import { ParameterType } from "../../utils/options/declaration" ;
78
89/**
910 * A plugin that builds links in markdown texts.
@@ -26,14 +27,24 @@ export class MarkedLinksPlugin extends ContextAwareRendererComponent
2627 */
2728 private urlPrefix :RegExp = / ^ ( h t t p | f t p ) s ? : \/ \/ / ;
2829
30+ @Option ( {
31+ name : 'listInvalidSymbolLinks' ,
32+ help : 'Emits a list of broken symbol [[navigation]] links after documentation generation' ,
33+ type : ParameterType . Boolean
34+ } )
35+ listInvalidSymbolLinks :boolean ;
2936
37+ private warnings : string [ ] = [ ] ;
3038
3139 /**
3240 * Create a new MarkedLinksPlugin instance.
3341 */
3442 initialize ( ) {
3543 super . initialize ( ) ;
36- this . listenTo ( this . owner , MarkdownEvent . PARSE , this . onParseMarkdown , 100 ) ;
44+ this . listenTo ( this . owner , {
45+ [ MarkdownEvent . PARSE ] : this . onParseMarkdown ,
46+ [ RendererEvent . END ] : this . onEndRenderer
47+ } , null , 100 ) ;
3748 }
3849
3950
@@ -101,6 +112,8 @@ export class MarkedLinksPlugin extends ContextAwareRendererComponent
101112 if ( reflection && reflection . url ) {
102113 target = this . getRelativeUrl ( reflection . url ) ;
103114 } else {
115+ reflection = this . reflection || this . project ;
116+ this . warnings . push ( `In ${ reflection . getFullName ( ) } : ${ original } ` ) ;
104117 return original ;
105118 }
106119 }
@@ -122,6 +135,20 @@ export class MarkedLinksPlugin extends ContextAwareRendererComponent
122135 event . parsedText = this . replaceInlineTags ( this . replaceBrackets ( event . parsedText ) ) ;
123136 }
124137
138+ /**
139+ * Triggered when [[Renderer]] is finished
140+ */
141+ onEndRenderer ( event :RendererEvent ) {
142+ if ( this . listInvalidSymbolLinks && this . warnings . length > 0 ) {
143+ this . application . logger . write ( '' ) ;
144+ this . application . logger . warn ( '[MarkedLinksPlugin]: Found invalid symbol reference(s) in JSDocs, ' +
145+ 'they will not render as links in the generated documentation.' ) ;
146+
147+ for ( var warning of this . warnings ) {
148+ this . application . logger . write ( ' ' + warning ) ;
149+ }
150+ }
151+ }
125152
126153 /**
127154 * Split the given link into text and target at first pipe or space.
0 commit comments