From 8da1c378ca8d955ce3a916771860c991abfc47f9 Mon Sep 17 00:00:00 2001 From: James Cardona Date: Mon, 10 Oct 2016 15:21:25 -0400 Subject: [PATCH 1/4] configured so @module tags added to nav list Added an if statement in buildNav method to add modules and added a sample file --- demo/sample/dateUtils.js | 66 ++++++++++++++++++++++++++++++++++++++++ publish.js | 29 ++++++++++++++++++ tmpl/navigation.tmpl | 2 +- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 demo/sample/dateUtils.js diff --git a/demo/sample/dateUtils.js b/demo/sample/dateUtils.js new file mode 100644 index 00000000..2ea62d51 --- /dev/null +++ b/demo/sample/dateUtils.js @@ -0,0 +1,66 @@ +/** + * A utility that has methods for converting dates to different formats. + * @module samples/dateUtils + */ +define([ + ], function( + + ) { + + return /** @alias module:samples/dateUtils */{ + + /** + * Converts a timestamp in epoch time (milliseconds since Jan 1, 1970) to a string. + * The string gets returned as a string in format "date month year hour:minute:second. + * For example "13 Feb 1999 12:18:32" + * + * @param {number} UNIX_timestamp The date in milliseconds after Jan 1, 1970 + * + * @returns {string} + * + * @static + */ + unixToDateTime: function (UNIX_timestamp) { + var a = new Date(UNIX_timestamp); + var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + var year = a.getFullYear(); + var month = months[a.getMonth()]; + var date = a.getDate(); + var hour = a.getHours(); + var min = a.getMinutes(); + var sec = a.getSeconds(); + var time = date + " " + month + " " + year + " " + hour + ":" + min + ":" + sec; + return time; + }, + + /** + * Date parser that handles date string generation. + * @param {Date|number|string} value The date to convert to a string. It can be a JavaScript Date object, + * a unix time stamp, or a string that represents a date. + * @param {string} format The desired date format from the parser. Valid examples are + * * "MM/DD/YYYY HH:mm:ss" - "09/09/2000 13:02:08" + * * "DDD MMM DD YYYY h:mm A" - "Tue Jan 3 2002 8:08 AM" + * @returns {String} Returns a string representation of the passed in date value + * following the format definition provided as the format parameter. If the value cannot + * be parsed, the method returns "<value> (Not parsed)" + * + * @static + */ + getDateString: function (value, format) { + //var isValid = moment(value).isValid(); + var isValid = true; + var dateString; + + if (isValid && value instanceof Date) { + dateString = moment(value).format(format); + } else if (isValid && !isNaN(value)) { + dateString = moment.unix(value).format(format); + } else if (isValid && typeof(value) === "string") { + dateString = moment(value).format(format); + } else { + dateString = value + " (Not parsed)"; + } + return dateString; + } + }; +}); diff --git a/publish.js b/publish.js index 21b283ea..9ee8ad60 100644 --- a/publish.js +++ b/publish.js @@ -208,6 +208,7 @@ function buildNav(members) { type: 'namespace', longname: v.longname, name: v.name, + displayName: v.name.replace(/\b(module|event):/g, ''), members: find({ kind: 'member', memberof: v.longname @@ -234,6 +235,34 @@ function buildNav(members) { type: 'class', longname: v.longname, name: v.name, + displayName: v.name.replace(/\b(module|event):/g, ''), + members: find({ + kind: 'member', + memberof: v.longname + }), + methods: find({ + kind: 'function', + memberof: v.longname + }), + typedefs: find({ + kind: 'typedef', + memberof: v.longname + }), + events: find({ + kind: 'event', + memberof: v.longname + }) + }); + }); + } + + if (members.modules.length) { + _.each(members.modules, function(v) { + nav.push({ + type: 'module', + longname: v.longname, + name: v.name, + displayName: v.name.replace(/\b(module|event):/g, ''), members: find({ kind: 'member', memberof: v.longname diff --git a/tmpl/navigation.tmpl b/tmpl/navigation.tmpl index 0f70feb0..14993ea3 100644 --- a/tmpl/navigation.tmpl +++ b/tmpl/navigation.tmpl @@ -13,7 +13,7 @@ var self = this; ?>
  • - + static From f2fb3b69912358fc8f43165409231b8a3ea077e3 Mon Sep 17 00:00:00 2001 From: James Cardona Date: Mon, 10 Oct 2016 15:31:30 -0400 Subject: [PATCH 2/4] render ol and ul tags as bulleted lists --- less/main.less | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/less/main.less b/less/main.less index 2cd7f6a5..d2aeed28 100644 --- a/less/main.less +++ b/less/main.less @@ -299,4 +299,20 @@ list-style-type: disc; } } + + .class-description { + ol, ul { + margin-left: 25px; + } + + ol > li { + list-style-type: decimal; + margin-bottom: 5px; + } + + ul > li { + margin-bottom: 5px; + list-style-type: disc; + } + } } \ No newline at end of file From 1c2ac56a827dc3dea5065cd908443d13c4d346a5 Mon Sep 17 00:00:00 2001 From: James Cardona Date: Mon, 10 Oct 2016 15:48:12 -0400 Subject: [PATCH 3/4] fix method to show members for AMD modules In recent version of jsdoc, amd module file names changed; this commit fixes data-name page-name mismatch causing problem with displaying memebers in navigation panel --- publish.js | 9 +++++++++ tmpl/navigation.tmpl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/publish.js b/publish.js index 9ee8ad60..a503f967 100644 --- a/publish.js +++ b/publish.js @@ -209,6 +209,9 @@ function buildNav(members) { longname: v.longname, name: v.name, displayName: v.name.replace(/\b(module|event):/g, ''), + + url: helper.longnameToUrl[v.longname] || v.longname, + members: find({ kind: 'member', memberof: v.longname @@ -236,6 +239,9 @@ function buildNav(members) { longname: v.longname, name: v.name, displayName: v.name.replace(/\b(module|event):/g, ''), + + url: helper.longnameToUrl[v.longname] || v.longname, + members: find({ kind: 'member', memberof: v.longname @@ -263,6 +269,9 @@ function buildNav(members) { longname: v.longname, name: v.name, displayName: v.name.replace(/\b(module|event):/g, ''), + + url: helper.longnameToUrl[v.longname] || v.longname, + members: find({ kind: 'member', memberof: v.longname diff --git a/tmpl/navigation.tmpl b/tmpl/navigation.tmpl index 14993ea3..bf3ca54a 100644 --- a/tmpl/navigation.tmpl +++ b/tmpl/navigation.tmpl @@ -11,7 +11,7 @@ var self = this; -
  • +
  • From d7d7846b1092492b97855707bc7ba0b9000d4770 Mon Sep 17 00:00:00 2001 From: James Cardona Date: Mon, 10 Oct 2016 16:29:40 -0400 Subject: [PATCH 4/4] show type names in navigation panel --- Gruntfile.js | 2 +- less/navigation.less | 6 ++ publish.js | 18 ++++-- tmpl/navigation.tmpl | 137 ++++++++++++++++++++++--------------------- 4 files changed, 91 insertions(+), 72 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index e4ba5df8..425c6ed4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -108,7 +108,7 @@ module.exports = function (grunt) { 'grunt-contrib-copy', 'grunt-contrib-clean', 'grunt-contrib-less', - 'grunt-jsdoc', + 'grunt-jsdoc' ].forEach(function (taskName) { grunt.loadNpmTasks(taskName); }); diff --git a/less/navigation.less b/less/navigation.less index 5e221b24..f74ac0cf 100644 --- a/less/navigation.less +++ b/less/navigation.less @@ -29,6 +29,12 @@ } } + .typeHeading { + font: 600 1.1em Helvetica; + color: #f5f5f5; + border-bottom: 1px solid #333; + } + .search { padding: 10px 15px; diff --git a/publish.js b/publish.js index a503f967..f09e302c 100644 --- a/publish.js +++ b/publish.js @@ -200,18 +200,19 @@ function attachModuleSymbols(doclets, modules) { * @return {string} The HTML for the navigation sidebar. */ function buildNav(members) { - var nav = []; + var nav = {}; if (members.namespaces.length) { + var namespaces = []; + _.each(members.namespaces, function (v) { - nav.push({ + namespaces.push({ type: 'namespace', longname: v.longname, name: v.name, displayName: v.name.replace(/\b(module|event):/g, ''), url: helper.longnameToUrl[v.longname] || v.longname, - members: find({ kind: 'member', memberof: v.longname @@ -230,11 +231,14 @@ function buildNav(members) { }) }); }); + nav.Namespaces = namespaces; } if (members.classes.length) { + var classes = []; + _.each(members.classes, function (v) { - nav.push({ + classes.push({ type: 'class', longname: v.longname, name: v.name, @@ -260,11 +264,14 @@ function buildNav(members) { }) }); }); + nav.Classes = classes; } if (members.modules.length) { + var modules = []; + _.each(members.modules, function(v) { - nav.push({ + modules.push({ type: 'module', longname: v.longname, name: v.name, @@ -290,6 +297,7 @@ function buildNav(members) { }) }); }); + nav.Modules = modules; } return nav; diff --git a/tmpl/navigation.tmpl b/tmpl/navigation.tmpl index bf3ca54a..fa338037 100644 --- a/tmpl/navigation.tmpl +++ b/tmpl/navigation.tmpl @@ -9,73 +9,78 @@ var self = this;
      -
    • - - - - static - - -
        - - Members - -
      • - -
      -
        - - Typedefs - -
      • - -
      -
        - - Methods - + +
      • + + + + static + + +
          + + Members + +
        • + +
        +
          + + Typedefs + +
        • + +
        +
          + + Methods + -
        • - -
        -
          - - Events - -
        • - -
        -
      • - + item.methods.forEach(function (v) { + ?> +
      • + +
      +
        + + Events + +
      • + +
      +
    • + +
    \ No newline at end of file