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

Fix for multiple throws + IP support #413

Open
wants to merge 7 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
25 changes: 24 additions & 1 deletion lib/docparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,30 @@ YUI.add('docparser', function (Y) {
},

// @throws {type} description
'throws': 'return',
'throws': function(tagname, value, target) {

target[tagname] = target[tagname] || [];

var desc = implodeString(trim(value)),
type,
match = REGEX_TYPE.exec(desc),
result = {};

if (match) {
type = fixType(trim(match[2]));
desc = trim(match[1] + match[3]);
}

result = {
description: Y.unindent(explodeString(desc))
};

if (type) {
result.type = type;
}

target[tagname].push(result);
},

'injects': 'return',

Expand Down
10 changes: 9 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ YUI.add('options', function (Y) {
Y.Options = function (args) {
var options = {
port: 3000,
ip: '127.0.0.1',
nocode: false
};

Expand Down Expand Up @@ -108,12 +109,19 @@ YUI.add('options', function (Y) {
case '--server':
options.server = true;
var a = args.shift();
var delim = a.indexOf(':');
if (delim >= 0) {
var socket = a.split(':');
options.ip = socket[0];
options.port = socket[1];
break;
}
var p = parseInt(a, 10);
if (isNaN(p) || !p) {
if (a) {
args.unshift(a);
}
Y.log('Failed to extract port, setting to the default :3000', 'warn', 'yuidoc');
Y.log('Failed to extract socket, setting to the default 127.0.0.1:3000', 'warn', 'yuidoc');
} else {
options.port = p;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ YUI.add('server', function (Y) {
stat = Server.options.themedir || path.join(__dirname, '../', 'themes', 'default');
Server.app.use(express.static(stat));
Server.routes();
Server.app.listen(Server.options.port);
Server.app.listen(Server.options.port, Server.options.ip);

Y.log('Starting server: http:/' + '/127.0.0.1:' + Server.options.port, 'info', 'server');
Y.log('Starting server: http://' + Server.options.ip + ':' + Server.options.port, 'info', 'server');
},
/**
* Start the server with the supplied options.
Expand Down
25 changes: 13 additions & 12 deletions themes/default/partials/method.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,25 @@
</div>
{{/return}}

{{#throws}}
{{#if throws}}
<div class="throws">
<h4>Throws:</h4>

<div class="throws-description">
{{#if description}}
{{#if type}}
<span class="type">{{#crossLink type}}{{/crossLink}}</span>:
{{/if}}
{{{description}}}
{{else}}
<ul class="params-list">
{{#throws}}
<li class="param">
{{#if type}}
<span class="type">{{#crossLink type}}{{/crossLink}}</span>:
<span class="type">{{#crossLink type}}{{/crossLink}}</span>
{{/if}}
{{/if}}
</div>

<div class="param-description">
{{{description}}}
</div>
</li>
{{/throws}}
</ul>
</div>
{{/throws}}
{{/if}}

{{#example}}
<div class="example">
Expand Down
11 changes: 8 additions & 3 deletions themes/simple/partials/method.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@
{{/return}}
{{/if}}
{{#if throws}}
{{#throws}}
<br><div class="throws"><strong>Throws:</strong> {{#if type}}&lt;{{#crossLink type}}{{/crossLink}}&gt; {{/if}}{{{description}}}</div>
{{/throws}}
<br><strong>Throws:</strong>
<ul class="throws">
{{#throws}}
<li>
{{#if type}}&lt;{{#crossLink type}}{{/crossLink}}&gt; {{/if}}{{{description}}}
</li>
{{/throws}}
</ul>
{{/if}}
{{#if example}}
<h5>Example</h5>
Expand Down