Skip to content

Commit

Permalink
docs: find module name from @name tag (#2429)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored Jul 5, 2017
1 parent d395a4b commit 09f2be3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/dlp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*!
* @module dlp
* @name DLP
*/

'use strict';

var extend = require('extend');
Expand Down
26 changes: 24 additions & 2 deletions scripts/docs/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,43 @@ function getMixinMethods(comments) {
}

function parseFile(fileName, contents, umbrellaMode) {
var comments = dox.parseComments(contents).filter(isPublic);
var comments = dox.parseComments(contents);
var constructor = comments.filter(prop('isConstructor'))[0];
var id = getId(fileName);
var parent = getParent(id);

var name;

if (constructor) {
name = getName(constructor);
} else {
// GAPICs don't have constructors.
var tags = comments.map(prop('tags'));

tags.forEach(tags => {
var isModuleTag = tags.some(tag => tag.type === 'module');

if (isModuleTag) {
tags.forEach(tag => {
if (tag.type === 'name') {
name = tag.string;
}
});
}
});
}

return {
id: id,
type: 'class',
name: getName(constructor),
name: name,
overview: createOverview(parent || id, umbrellaMode),
description: getClassDesc(constructor),
source: path.normalize(fileName),
parent: parent,
children: getChildren(id),
methods: comments
.filter(isPublic)
.filter(isMethod)
.map(createMethod.bind(null, fileName, id))
.concat(getMixinMethods(comments))
Expand Down

0 comments on commit 09f2be3

Please sign in to comment.