chore(doc-gen): capture docs for modules from comments Closes #1258 docs(*): add module description jsdoc tags docs(*): add @public tag to public modules chore(doc-gen): fix overview-dump template The template was referencing an invalid property chore(doc-gen): use `@exportedAs` and `@public` rather than `@publicModule` This commit refactors how we describe components that are re-exported in another module. For example the "public" modules like `angular/angular` and `angular/annotations` are public but they only re-export components from "private" modules. Previously, you must apply the `@publicModule` tag to a component that was to be re-exported. Applying this tag caused the destination module to become public. Now, you specify that a module is public by applying the `@public` tag and then you can "re-export" components to other modules by applying the `@exportedAs` giving the name of the module from which the component will be re-exported. tag. This tag can be used multiple times on a single component, allowing the component to be exported on multiple modules. docs(*): rename `@publicModule` to `@exportedAs` The `@publicModule` dgeni tag has been replaced by the `@exportedAs` dgeni tag on components that are to be re-exported on another module. Closes #1290
		
			
				
	
	
		
			71 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var _ = require('lodash');
 | |
| 
 | |
| module.exports = function captureClassMembers(log, getJSDocComment) {
 | |
| 
 | |
|   return {
 | |
|     $runAfter: ['captureModuleExports'],
 | |
|     $runBefore: ['parsing-tags'],
 | |
|     ignorePrivateMembers: false,
 | |
|     $process: function(docs) {
 | |
|       var memberDocs = [];
 | |
|       var ignorePrivateMembers = this.ignorePrivateMembers;
 | |
|       _.forEach(docs, function(classDoc) {
 | |
|         if ( classDoc.docType === 'class' ) {
 | |
| 
 | |
|           classDoc.members = [];
 | |
| 
 | |
|           // Create a new doc for each member of the class
 | |
|           _.forEach(classDoc.elements, function(memberDoc) {
 | |
| 
 | |
|             var memberName = memberDoc.name.location.toString();
 | |
| 
 | |
|             if (ignorePrivateMembers && memberName.charAt(0) === '_') return;
 | |
| 
 | |
|             memberDocs.push(memberDoc);
 | |
| 
 | |
|             memberDoc.docType = 'member';
 | |
|             memberDoc.classDoc = classDoc;
 | |
|             memberDoc.name = memberName;
 | |
|             if (memberDoc.parameterList) {
 | |
|               memberDoc.params = memberDoc.parameterList.parameters.map(function(param) {
 | |
|                 return param.location.toString();
 | |
|               });
 | |
|             }
 | |
| 
 | |
|             if (memberDoc.commentBefore ) {
 | |
|               // If this export has a comment, remove it from the list of
 | |
|               // comments collected in the module
 | |
|               var index = classDoc.moduleDoc.comments.indexOf(memberDoc.commentBefore);
 | |
|               if ( index !== -1 ) {
 | |
|                 classDoc.moduleDoc.comments.splice(index, 1);
 | |
|               }
 | |
| 
 | |
|               _.assign(memberDoc, getJSDocComment(memberDoc.commentBefore));
 | |
|             }
 | |
| 
 | |
|             // Constuctor is a special case member
 | |
|             if (memberName === 'constructor') {
 | |
|               classDoc.constructorDoc = memberDoc;
 | |
|             } else {
 | |
|               insertSorted(classDoc.members, memberDoc, 'name');
 | |
|             }
 | |
| 
 | |
|           });
 | |
|         }
 | |
|       });
 | |
| 
 | |
|       return docs.concat(memberDocs);
 | |
|     }
 | |
|   };
 | |
| };
 | |
| 
 | |
| 
 | |
| function insertSorted(collection, item, property) {
 | |
|   var index = collection.length;
 | |
|   while(index>0) {
 | |
|     if(collection[index-1][property] < item[property]) break;
 | |
|     index -= 1;
 | |
|   }
 | |
|   collection.splice(index, 0, item);
 | |
| }
 |