Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 83c7e1f

Browse files
feat(api-docs): allow packageName to be specified as a tag
See angular/angular.js#7284 See angular/angular.js#8038
1 parent 085bdc8 commit 83c7e1f

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

ngdoc/processors/apiDocs.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ module.exports = function apiDocsProcessor(log, partialNameMap, moduleMap) {
4040
// Compute the package name and filename for the module
4141
var match = /^ng(.*)/.exec(doc.name);
4242
if ( match ) {
43-
var packageName = match[1].toLowerCase();
44-
if ( packageName ) { packageName = '-' + packageName; }
45-
doc.packageName = 'angular' + packageName;
43+
if ( !doc.packageName ) {
44+
var packageName = match[1].toLowerCase();
45+
if ( packageName ) { packageName = '-' + packageName; }
46+
doc.packageName = 'angular' + packageName;
47+
}
4648
doc.packageFile = doc.packageName + '.js';
4749
}
4850

ngdoc/spec/processors/apiDocs.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ describe("api-docs processor", function() {
3535
});
3636
});
3737

38+
it("should compute the packageName and packageFile if not already provided", function() {
39+
var doc1 = { area: 'api', docType: 'module', name: 'ng' };
40+
var doc2 = { area: 'api', docType: 'module', name: 'ngResource' };
41+
var doc3 = { area: 'api', docType: 'module', name: 'ngMock', packageName: 'angular-mocks' };
42+
processor.$process([doc1,doc2, doc3]);
43+
expect(doc1.packageName).toEqual('angular');
44+
expect(doc1.packageFile).toEqual('angular.js');
45+
expect(doc2.packageName).toEqual('angular-resource');
46+
expect(doc2.packageFile).toEqual('angular-resource.js');
47+
expect(doc3.packageName).toEqual('angular-mocks');
48+
expect(doc3.packageFile).toEqual('angular-mocks.js');
49+
});
50+
3851
it("should extract the container and member from the name if it is a memberOf type", function() {
3952
var doc = {
4053
docType: 'method',

ngdoc/tag-defs/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ module.exports = [
1111
require('./fullName'),
1212
require('./priority'),
1313
require('./title'),
14-
require('./parent')
14+
require('./parent'),
15+
require('./packageName')
1516
];

ngdoc/tag-defs/packageName.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function() {
2+
return { name: 'packageName' };
3+
};

0 commit comments

Comments
 (0)