From a94af931c2e9178c7a6d6da9977d6d8f811a1d8f Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Sat, 1 Jul 2017 09:50:10 -0400 Subject: [PATCH] docs: find module name from @name tag --- packages/dlp/src/index.js | 6 ++++++ scripts/docs/parser.js | 26 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/dlp/src/index.js b/packages/dlp/src/index.js index 21666baa1dc..9f72276ee30 100644 --- a/packages/dlp/src/index.js +++ b/packages/dlp/src/index.js @@ -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'); diff --git a/scripts/docs/parser.js b/scripts/docs/parser.js index dbe992081d3..5eacc0a7b65 100644 --- a/scripts/docs/parser.js +++ b/scripts/docs/parser.js @@ -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))