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

Commit 211a4cb

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 22b8a34 commit 211a4cb

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

ngdoc/processors/api-docs.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ module.exports = {
4343
// Compute the package name and filename for the module
4444
var match = /^ng(.*)/.exec(doc.name);
4545
if ( match ) {
46-
var packageName = match[1].toLowerCase();
47-
if ( packageName ) { packageName = '-' + packageName; }
48-
doc.packageName = 'angular' + packageName;
46+
if ( !doc.packageName ) {
47+
var packageName = match[1].toLowerCase();
48+
if ( packageName ) { packageName = '-' + packageName; }
49+
doc.packageName = 'angular' + packageName;
50+
}
4951
doc.packageFile = doc.packageName + '.js';
5052
}
5153

ngdoc/spec/processors/api-docs.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ describe("api-docs processor", function() {
3333
});
3434
});
3535

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

ngdoc/tag-defs/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@ module.exports = [
114114

115115
{ name: 'title' },
116116
{ name: 'parent' },
117+
{ name: 'packageName' }
117118

118119
];

0 commit comments

Comments
 (0)