Adds the ability to expose global symbols in the API docs via the `@globalApi` tag. Also supports optionally setting a namespace which will be added to the name automatically (e.g. `foo` will be renamed to `ng.foo`). Relevant APIs should also be exported through the `global.ts` file which will show up under `core/global`. PR Close #34237
		
			
				
	
	
		
			27 lines
		
	
	
		
			935 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			935 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
/**
 | 
						|
 * @dgProcessor updateGlobalApiPath
 | 
						|
 *
 | 
						|
 * If a global API has a namespace, its name will contain a dot which will cause its
 | 
						|
 * URL to look like a file path. This processor updates it so it's less ambiguous.
 | 
						|
 */
 | 
						|
module.exports = function updateGlobalApiPathProcessor() {
 | 
						|
  return {
 | 
						|
    $runAfter: ['computePathsProcessor'],
 | 
						|
    $runBefore: ['processNgModuleDocs'],
 | 
						|
    $process: function(docs) {
 | 
						|
      docs.forEach(doc => {
 | 
						|
        if (doc.global && doc.globalNamespace) {
 | 
						|
          // We need to change the path to camel case, because having a dot
 | 
						|
          // in the URL will make it look like a file path.
 | 
						|
          const name = doc.unprefixedName;
 | 
						|
          const fileName = doc.globalNamespace + name[0].toUpperCase() + name.slice(1);
 | 
						|
 | 
						|
          doc.path = `${doc.moduleDoc.moduleFolder}/${fileName}`;
 | 
						|
          doc.outputPath =
 | 
						|
              `${doc.moduleDoc.moduleFolder}/${fileName}.json`;
 | 
						|
        }
 | 
						|
      });
 | 
						|
    }
 | 
						|
  };
 | 
						|
};
 |