From 9a2ebe1b9daa892b9c9743cdfac44f7eef1497a9 Mon Sep 17 00:00:00 2001 From: Zhu Liang Date: Sun, 17 Mar 2019 18:12:00 +0800 Subject: [PATCH] docs: fix type, signature and return type --- lib/helper.js | 34 +++++++++++++++++----------------- theme/publish.js | 10 ++++++++++ theme/tmpl/method.tmpl | 9 +++++++++ theme/tmpl/type.tmpl | 2 +- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/lib/helper.js b/lib/helper.js index 6371512f..e6ee22f1 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -49,7 +49,7 @@ const safeQuote = string => JSON.stringify(String(string)); const extendsMixIn = wd => { /** * Initial browser window. - * @name initWindow + * @function initWindow * @summary Support: Web(WebView) * @param {object} browser options. * @type utility @@ -67,7 +67,7 @@ const extendsMixIn = wd => { /** * Get webpage from url util the page ready. - * @name getUrl + * @function getUrl * @summary Support: Web(WebView) * @param {string} the pointed url. * @type utility @@ -171,7 +171,7 @@ const extendsMixIn = wd => { /** * Save screenshots to ./screenshots. - * @name saveScreenshots + * @function saveScreenshots * @summary Support: Web(WebView) * @type utility * @returns {Promise.} @@ -190,7 +190,7 @@ const extendsMixIn = wd => { /** * Generate the coverage reporter. - * @name coverage + * @function coverage * @summary Support: Web(WebView) * @type utility * @returns {Promise.} @@ -226,7 +226,7 @@ const extendsMixIn = wd => { /** * Open all reporters in browser. - * @name openReporter + * @function openReporter * @summary Support: Web(WebView) * @param {boolean} if open. * @type utility @@ -253,7 +253,7 @@ const extendsMixIn = wd => { /** * Switch scene with DataHub. - * @name switchScene + * @function switchScene * @summary Support: Web(WebView) * @param {object} options. * @type datahub @@ -267,7 +267,7 @@ const extendsMixIn = wd => { }); /** * Switch multi-scene with DataHub. - * @name switchMultiScenes + * @function switchMultiScenes * @summary Support: Web(WebView) * @param {array} the scene list. * @type datahub @@ -285,7 +285,7 @@ const extendsMixIn = wd => { }); /** * Switch all scenes with DataHub. - * @name switchAllScenes + * @function switchAllScenes * @summary Support: Web(WebView) * @param {object} options. * @type datahub @@ -300,7 +300,7 @@ const extendsMixIn = wd => { /** * Type content to input element. - * @name formInput + * @function formInput * @summary Support: Web(WebView) * @param {string} content of type. * @type utility @@ -339,7 +339,7 @@ const extendsMixIn = wd => { /** * Type content to a contentEditable element. - * @name elementInput + * @function elementInput * @summary Support: Web(WebView) * @param {string} content of type. * @type utility @@ -378,10 +378,10 @@ const extendsMixIn = wd => { /** * Simulate the dom event. - * @name domEvent + * @function domEvent * @summary Support: Web(WebView) - * @param {string} eventType of the event. - * @param {object} options of the event. + * @param {string} eventType - type of the event. + * @param {object} options - options of the event. * @see https://github.com/macacajs/dom-event-simulate#support-events * @type utility * @returns {Promise.} @@ -399,7 +399,7 @@ const extendsMixIn = wd => { /** * Check if element has pointed text. - * @name hasText + * @function hasText * @summary Support: Web(WebView) * @param {string} text content. * @type assert @@ -413,7 +413,7 @@ const extendsMixIn = wd => { /** * Check if element is existed. - * @name hasElementByCss + * @function hasElementByCss * @summary Support: Web(WebView) * @param {string} text content. * @type assert @@ -431,7 +431,7 @@ const extendsMixIn = wd => { /** * Check if title exists. - * @name assertTitle + * @function assertTitle * @summary Support: Web(WebView) * @param {string} title of the web page. * @type assert @@ -447,7 +447,7 @@ const extendsMixIn = wd => { /** * Check if element's attribute right. - * @name assertAttribute + * @function assertAttribute * @summary Support: Web(WebView) * @param {string} attribute's name. * @param {string} expected value. diff --git a/theme/publish.js b/theme/publish.js index a31965d4..57a00269 100644 --- a/theme/publish.js +++ b/theme/publish.js @@ -153,6 +153,16 @@ function addSignatureReturns(f) { // jam all the return-type attributes into an array. this could create odd results (for example, // if there are both nullable and non-nullable return types), but let's assume that most people // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa. + + // remove our custom type from returns + if (f.returns.length === 2) { + for (var i = 0; i < f.returns.length; i++) { + if (f.returns[i].type.names[0] === f.type.names[0]) { + f.returns.splice(i, 1); + } + } + } + if (f.returns) { f.returns.forEach(function(item) { helper.getAttribs(item).forEach(function(attrib) { diff --git a/theme/tmpl/method.tmpl b/theme/tmpl/method.tmpl index 4983eecd..8296876f 100644 --- a/theme/tmpl/method.tmpl +++ b/theme/tmpl/method.tmpl @@ -33,6 +33,15 @@ name + (data.signature || '') ?> + +

Type:

+
    +
  • + +
  • +
+ +

This:

diff --git a/theme/tmpl/type.tmpl b/theme/tmpl/type.tmpl index 0935e783..46ca1af9 100644 --- a/theme/tmpl/type.tmpl +++ b/theme/tmpl/type.tmpl @@ -2,6 +2,6 @@ var data = obj; var self = this; data.forEach(function(name, i) { ?> - + |