@@ -650,11 +650,46 @@ export class YamlDocumenter {
650650
651651 private _getYamlItemName ( apiItem : ApiItem ) : string {
652652 if ( apiItem . parent && apiItem . parent . kind === ApiItemKind . Namespace ) {
653- // For members a namespace, show the full name excluding the package part:
654- // Example: excel.Excel.Binding --> Excel.Binding
655- return apiItem . getScopedNameWithinPackage ( ) ;
653+ // If the immediate parent is a namespace, then add the namespaces to the name. For example:
654+ //
655+ // // Name: "N1"
656+ // export namespace N1 {
657+ // // Name: "N1.N2"
658+ // export namespace N2 {
659+ // // Name: "N1.N2.f(x,y)"
660+ // export function f(x: string, y: string): string {
661+ // return x + y;
662+ // }
663+ //
664+ //
665+ // // Name: "N1.N2.C"
666+ // export class C {
667+ // // Name: "member(x,y)" <===========
668+ // public member(x: string, y: string): string {
669+ // return x + y;
670+ // }
671+ // }
672+ // }
673+ // }
674+ //
675+ // In the above example, "member(x, y)" does not appear as "N1.N2.C.member(x,y)" because YamlDocumenter
676+ // embeds this entry in the web page for "N1.N2.C", so the container is obvious. Whereas "N1.N2.f(x,y)"
677+ // needs to be qualified because the DocFX template doesn't make pages for namespaces. Instead, they get
678+ // flattened into the package's page.
679+ const nameParts : string [ ] = [ Utilities . getConciseSignature ( apiItem ) ] ;
680+
681+ for ( let current : ApiItem | undefined = apiItem . parent ; current ; current = current . parent ) {
682+ if ( current . kind !== ApiItemKind . Namespace ) {
683+ break ;
684+ }
685+
686+ nameParts . unshift ( current . displayName ) ;
687+ }
688+
689+ return nameParts . join ( '.' ) ;
690+ } else {
691+ return Utilities . getConciseSignature ( apiItem ) ;
656692 }
657- return Utilities . getConciseSignature ( apiItem ) ;
658693 }
659694
660695 private _getYamlFilePath ( apiItem : ApiItem ) : string {
0 commit comments