@@ -116,6 +116,12 @@ export class YamlDocumenter {
116116 }
117117
118118 private _visitApiItems ( apiItem : ApiDocumentedItem , parentYamlFile : IYamlApiFile | undefined ) : boolean {
119+ let savedYamlReferences : IYamlReferences | undefined ;
120+ if ( ! this . _shouldEmbed ( apiItem . kind ) ) {
121+ savedYamlReferences = this . _yamlReferences ;
122+ this . _yamlReferences = undefined ;
123+ }
124+
119125 const yamlItem : IYamlItem | undefined = this . _generateYamlItem ( apiItem ) ;
120126 if ( ! yamlItem ) {
121127 return false ;
@@ -155,17 +161,12 @@ export class YamlDocumenter {
155161 }
156162 }
157163
158- if ( this . _yamlReferences ) {
159- if ( this . _yamlReferences . references . length > 0 ) {
160- if ( newYamlFile . references ) {
161- newYamlFile . references = [ ...newYamlFile . references , ...this . _yamlReferences . references ] ;
162- } else {
163- newYamlFile . references = this . _yamlReferences . references ;
164- }
165- }
166- this . _yamlReferences = undefined ;
164+ if ( this . _yamlReferences && this . _yamlReferences . references . length > 0 ) {
165+ newYamlFile . references = this . _yamlReferences . references ;
167166 }
168167
168+ this . _yamlReferences = savedYamlReferences ;
169+
169170 const yamlFilePath : string = this . _getYamlFilePath ( apiItem ) ;
170171
171172 if ( apiItem . kind === ApiItemKind . Package ) {
@@ -175,15 +176,10 @@ export class YamlDocumenter {
175176 this . _writeYamlFile ( newYamlFile , yamlFilePath , 'UniversalReference' , yamlApiSchema ) ;
176177
177178 if ( parentYamlFile ) {
178- if ( ! parentYamlFile . references ) {
179- parentYamlFile . references = [ ] ;
180- }
181-
182- parentYamlFile . references . push ( {
183- uid : this . _getUid ( apiItem ) ,
184- name : this . _getYamlItemName ( apiItem )
185- } ) ;
186-
179+ this . _recordYamlReference (
180+ this . _ensureYamlReferences ( ) ,
181+ this . _getUid ( apiItem ) ,
182+ this . _getYamlItemName ( apiItem ) ) ;
187183 }
188184 }
189185
0 commit comments