File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import * as fsx from 'fs-extra' ;
55import * as path from 'path' ;
6+ import * as colors from 'colors' ;
7+
68import yaml = require( 'js-yaml' ) ;
79import { JsonFile , JsonSchema , Text } from '@microsoft/node-core-library' ;
810import {
@@ -13,7 +15,8 @@ import {
1315 IApiProperty ,
1416 IApiEnumMember ,
1517 IApiClass ,
16- IApiInterface
18+ IApiInterface ,
19+ Markup
1720} from '@microsoft/api-extractor' ;
1821
1922import { DocItemSet , DocItem , DocItemKind , IDocItemSetResolveResult } from '../utils/DocItemSet' ;
@@ -354,7 +357,8 @@ export class YamlDocumenter {
354357 const result : IDocItemSetResolveResult = this . _docItemSet . resolveApiItemReference ( args . reference ) ;
355358 if ( ! result . docItem ) {
356359 // Eventually we should introduce a warnings file
357- console . error ( '==> UNRESOLVED REFERENCE: ' + JSON . stringify ( args . reference ) ) ;
360+ console . error ( colors . yellow ( 'Warning: Unresolved hyperlink to '
361+ + Markup . formatApiItemReference ( args . reference ) ) ) ;
358362 } else {
359363 args . prefix = '[' ;
360364 args . suffix = `](xref:${ this . _getUid ( result . docItem ) } )` ;
Original file line number Diff line number Diff line change @@ -358,6 +358,33 @@ export class Markup {
358358 }
359359 }
360360
361+ /**
362+ * This formats an IApiItemReference as its AEDoc notation.
363+ *
364+ * @remarks
365+ * Depending on the provided components, example return values might look like
366+ * "\@ms/my-library:SomeClass.someProperty", "my-library:SomeClass", "SomeClass",
367+ * or "SomeClass.someProperty".
368+ */
369+ public static formatApiItemReference ( apiItemReference : IApiItemReference ) : string {
370+ // Example: "SomeClass"
371+ let result : string = apiItemReference . exportName ;
372+ if ( apiItemReference . packageName ) {
373+ // Example: "my-library:SomeClass"
374+ result = apiItemReference . packageName + ':' + result ;
375+
376+ if ( apiItemReference . scopeName ) {
377+ // Example: "@ms/my-library:SomeClass"
378+ result = apiItemReference . scopeName + '/' + result ;
379+ }
380+ }
381+ if ( apiItemReference . memberName ) {
382+ // Example: "@ms/my-library:SomeClass.someProperty"
383+ result += '.' + apiItemReference . memberName ;
384+ }
385+ return result ;
386+ }
387+
361388 private static _extractTextContent ( elements : MarkupElement [ ] , buffer : { text : string } ) : void {
362389 for ( const element of elements ) {
363390 switch ( element . kind ) {
Original file line number Diff line number Diff line change @@ -367,6 +367,7 @@ class Markup {
367367 static createWebLink ( textElements : MarkupLinkTextElement [ ] , targetUrl : string ) : IMarkupWebLink ;
368368 static createWebLinkFromText ( text : string , targetUrl : string ) : IMarkupWebLink ;
369369 static extractTextContent ( elements : MarkupElement [ ] ) : string ;
370+ static formatApiItemReference ( apiItemReference : IApiItemReference ) : string ;
370371 static normalize < T extends MarkupElement > ( elements : T [ ] ) : void ;
371372 static PARAGRAPH : IMarkupParagraph ;
372373}
You can’t perform that action at this time.
0 commit comments