Permalink
Browse files

Update

  • Loading branch information...
1 parent 09ecfda commit cd86fd812c843967e5ec3ba8590ab261d86193c5 @JacksonTian committed Aug 3, 2015
Showing with 43 additions and 18 deletions.
  1. +5 −3 bin/doxmate
  2. +20 −2 lib/doxmate.js
  3. +18 −13 templates/default/section.html
View
@@ -5,7 +5,7 @@
*/
var program = require('commander'),
- exec = require('child_process').exec,
+ execFile = require('child_process').execFile,
path = require('path'),
fs = require('fs'),
join = path.join,
@@ -60,9 +60,11 @@ if (fs.existsSync(local)) {
}
// execute command
-exec('node ' + bin + ' ' + args.join(' '), function (err, stdout) {
+var options = {maxBuffer: 1024 * 1024};
+execFile(local, args, options, function (err, stdout) {
if (err) {
- return console.error(err);
+ console.error(err);
+ return;
}
console.log(stdout);
});
View
@@ -45,7 +45,18 @@ var types = {
"function": "函数",
"declaration": "声明",
"exception": "异常",
- "callmethod": "调用方式"
+ "callmethod": "调用方式",
+ "name": "名字"
+};
+
+var getName = function (comment) {
+ for (var i = 0; i < comment.tags.length; i++) {
+ var tag = comment.tags[i];
+ if (tag.type === 'name') {
+ return tag.string;
+ }
+ }
+ return comment.ctx && comment.ctx.name || 'unknown name';
};
var getAPIs = function (basedir, folder, option) {
@@ -68,7 +79,13 @@ var getAPIs = function (basedir, folder, option) {
basename = folder ? folder + '/' + basename : basename;
var buf = fs.readFileSync(path.join(basedir, file), 'utf8');
var obj = dox.parseComments(buf, {});
- apis[basename] = {types: types, comments: obj, basename: basename, options: options};
+ apis[basename] = {
+ types: types,
+ comments: obj,
+ basename: basename,
+ options: options,
+ __getName: getName
+ };
});
return apis;
@@ -190,6 +207,7 @@ exports.process = function (input, output, skin, dir) {
//主题配置文件
var section = getTemplates(skin).section;
var folders = getFolders(libDir, obj.options);
+
for (var folder in folders) {
for (var key in folders[folder]) {
obj.apis[key] = folders[folder][key];
@@ -3,14 +3,14 @@
<ul class="indexs">
<%
var indexs = comments.filter(function (item) {
- return !item.ignore && item.ctx;
- }).map(function (item) {
- return item.ctx;
- }).forEach(function (item) {
- item.receiver = item.receiver || '';
+ return !item.ignore;
+ }).forEach(function (comment) {
+ comment.ctx.receiver = comment.ctx.receiver || '';
%>
<li>
- <a href="#<%= basename + '_' + item.receiver + '_' + item.name%>"><%= item.name%></a>
+ <a href="#<%= basename + '_' + comment.ctx.receiver + '_' + __getName(comment)%>">
+ <%=__getName(comment)%>
+ </a>
</li>
<% }); %>
</ul>
@@ -21,11 +21,9 @@
continue;
}
%>
- <% if (comment.ctx) { %>
- <h3 data-id="<%= basename + '_' + comment.ctx.receiver + '_' + comment.ctx.name%>">
- <%=comment.ctx.name%>
+ <h3 data-id="<%= basename + '_' + comment.ctx.receiver + '_' + __getName(comment)%>">
+ <%=__getName(comment)%>
</h3>
- <% } %>
<% if (comment.code) { %>
<%-comment.description.full%>
<% } %>
@@ -34,18 +32,18 @@ <h3 data-id="<%= basename + '_' + comment.ctx.receiver + '_' + comment.ctx.name%
<% if (comment.ctx) { %>
<tr>
<td><%=types[comment.ctx.type] %></td>
- <td colspan="3"><%=comment.ctx.string %></td>
+ <td colspan="3"><%=comment.ctx.string %></td>
</tr>
<% } %>
-<% for (var j = 0, k = comment.tags.length; j < k; j++) {
+<% for (var j = 0, k = comment.tags.length; j < k; j++) {
var tag = comment.tags[j];
switch (tag.type) {
case 'return':
%>
<tr>
<td><%=types[tag.type]%></td>
<td><%=tag.types && tag.types.join(',')%></td>
- <td colspan="2"><pre><%=tag.description%></pre></td> </tr>
+ <td colspan="2"><%-tag.description%></td> </tr>
<% break;
case 'param':
%>
@@ -83,6 +81,13 @@ <h3 data-id="<%= basename + '_' + comment.ctx.receiver + '_' + comment.ctx.name%
<td colspan="3"><%=tag.string%></td>
</tr>
<% break;
+ case 'name':
+ %>
+ <tr>
+ <td><%=types[tag.type]%></td>
+ <td colspan="3"><%=tag.string%></td>
+ </tr>
+ <% break;
default:
%>
<tr>

0 comments on commit cd86fd8

Please sign in to comment.