Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show @module tags in navigation panel #45

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
66 changes: 66 additions & 0 deletions demo/sample/dateUtils.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
});
16 changes: 16 additions & 0 deletions less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
6 changes: 6 additions & 0 deletions less/navigation.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
}
}

.typeHeading {
font: 600 1.1em Helvetica;
color: #f5f5f5;
border-bottom: 1px solid #333;
}

.search {
padding: 10px 15px;

Expand Down
52 changes: 49 additions & 3 deletions publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +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
Expand All @@ -226,14 +231,54 @@ 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,
displayName: v.name.replace(/\b(module|event):/g, ''),

url: helper.longnameToUrl[v.longname] || v.longname,

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
})
});
});
nav.Classes = classes;
}

if (members.modules.length) {
var modules = [];

_.each(members.modules, function(v) {
modules.push({
type: 'module',
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
Expand All @@ -252,6 +297,7 @@ function buildNav(members) {
})
});
});
nav.Modules = modules;
}

return nav;
Expand Down
137 changes: 71 additions & 66 deletions tmpl/navigation.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,73 +9,78 @@ var self = this;
</div>
<ul class="list">
<?js
this.nav.forEach(function (item) {
Object.keys(this.nav).forEach(function(key) {
?>
<li class="item" data-name="<?js= item.longname ?>">
<span class="title">
<?js= self.linkto(item.longname, item.longname) ?>
<?js if (item.type === 'namespace') { ?>
<span class="static">static</span>
<?js } ?>
</span>
<ul class="members itemMembers">
<?js
if (item.members.length) {
?>
<span class="subtitle">Members</span>
<?js
item.members.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="typedefs itemMembers">
<?js
if (item.typedefs.length) {
?>
<span class="subtitle">Typedefs</span>
<?js
item.typedefs.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="methods itemMembers">
<?js
if (item.methods.length) {
?>
<span class="subtitle">Methods</span>
<?js
<h3 class="typeHeading"><?js= key ?></h3>
<?js
this.nav[key].forEach(function (item) {
?>
<li class="item" data-name="<?js= item.url || item.longname ?>">
<span class="title">
<?js= self.linkto(item.longname, item.displayName) ?>
<?js if (item.type === 'namespace') { ?>
<span class="static">static</span>
<?js } ?>
</span>
<ul class="members itemMembers">
<?js
if (item.members.length) {
?>
<span class="subtitle">Members</span>
<?js
item.members.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="typedefs itemMembers">
<?js
if (item.typedefs.length) {
?>
<span class="subtitle">Typedefs</span>
<?js
item.typedefs.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="methods itemMembers">
<?js
if (item.methods.length) {
?>
<span class="subtitle">Methods</span>
<?js

item.methods.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="events itemMembers">
<?js
if (item.events.length) {
?>
<span class="subtitle">Events</span>
<?js
item.events.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
</li>
<?js }); ?>
item.methods.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
<ul class="events itemMembers">
<?js
if (item.events.length) {
?>
<span class="subtitle">Events</span>
<?js
item.events.forEach(function (v) {
?>
<li data-name="<?js= v.longname ?>"><?js= self.linkto(v.longname, v.name) ?></li>
<?js
});
}
?>
</ul>
</li>
<?js }); ?>
<?js }.bind(this)); ?>
</ul>
</div>