@@ -29,8 +29,9 @@ export interface IParsedScopeName {
2929 * then use DocItemLoader.getItem to retrieve the IDocItem of a particular API item.
3030 */
3131export default class DocItemLoader {
32- private cache : Map < string , IDocPackage > ;
33- private projectFolder : string ; // Root directory to check for node modules
32+ private _cache : Map < string , IDocPackage > ;
33+ private _projectFolder : string ; // Root directory to check for node modules
34+ private _errorHandler : ( message : string ) => void ;
3435
3536 /**
3637 * The projectFolder is the top-level folder containing package.json for a project
@@ -41,8 +42,8 @@ export default class DocItemLoader {
4142 throw new Error ( `An NPM project was not found in the specified folder: ${ projectFolder } ` ) ;
4243 }
4344
44- this . projectFolder = projectFolder ;
45- this . cache = new Map < string , IDocPackage > ( ) ;
45+ this . _projectFolder = projectFolder ;
46+ this . _cache = new Map < string , IDocPackage > ( ) ;
4647 }
4748
4849 /**
@@ -51,12 +52,13 @@ export default class DocItemLoader {
5152 * will attempt to the locate the associated json file to load the package and
5253 * check there. If the API item can not be found the method will return undefined.
5354 */
54- public getItem ( apiDefinitionRef : IApiDefinitionReference ) : IDocItem {
55+ public getItem ( apiDefinitionRef : IApiDefinitionReference , reportError : ( message : string ) => void ) : IDocItem {
5556 if ( ! apiDefinitionRef ) {
56- throw new Error ( 'Expected param to DocItemLoader.getItem() to be defined' ) ;
57+ reportError ( 'Expected reference within {@inheritdoc} tag' ) ;
58+ return undefined ;
5759 }
5860 // Try to load the package given the provided packageName into the cache
59- const docPackage : IDocPackage = this . getPackage ( apiDefinitionRef ) ;
61+ const docPackage : IDocPackage = this . getPackage ( apiDefinitionRef , reportError ) ;
6062
6163 // Check if package was not found
6264 if ( ! docPackage ) {
@@ -90,7 +92,7 @@ export default class DocItemLoader {
9092 *
9193 * @param apiDefinitionRef - interface with propropties pertaining to the API definition reference
9294 */
93- public getPackage ( apiDefinitionRef : IApiDefinitionReference ) : IDocPackage {
95+ public getPackage ( apiDefinitionRef : IApiDefinitionReference , reportError : ( message : string ) => void ) : IDocPackage {
9496 let cachePackageName : string = '' ;
9597
9698 // We concatenate the scopeName and packageName in case there are packageName conflicts
@@ -100,13 +102,18 @@ export default class DocItemLoader {
100102 cachePackageName = apiDefinitionRef . packageName ;
101103 }
102104 // Check if package exists in cache
103- if ( this . cache . has ( cachePackageName ) ) {
104- return this . cache . get ( cachePackageName ) ;
105+ if ( this . _cache . has ( cachePackageName ) ) {
106+ return this . _cache . get ( cachePackageName ) ;
107+ }
108+
109+ if ( ! apiDefinitionRef . packageName ) {
110+ // Local export resolution is currently not supported yet
111+ return ;
105112 }
106113
107114 // Doesn't exist in cache, attempt to load the json file
108115 const packageJsonFilePath : string = path . join (
109- this . projectFolder ,
116+ this . _projectFolder ,
110117 'node_modules' ,
111118 apiDefinitionRef . scopeName ,
112119 apiDefinitionRef . packageName ,
@@ -141,7 +148,7 @@ export default class DocItemLoader {
141148 ) ;
142149
143150 const packageName : string = path . basename ( packageJsonFilePath ) . split ( '.' ) . shift ( ) ;
144- this . cache . set ( packageName , apiPackage ) ;
151+ this . _cache . set ( packageName , apiPackage ) ;
145152 return apiPackage ;
146153 }
147154}
0 commit comments