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

Added try catch to JSON parsing area of code #4

Open
wants to merge 1 commit 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-jsdoc-ng",
"version": "0.0.3",
"version": "0.0.4",
"description": "A JsDoc3 plugin for Grunt plus an AngularJS based template",
"repository": {
"type": "git",
Expand Down
34 changes: 21 additions & 13 deletions template/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ exports.publish = function(taffyData, opts, tutorials) {
preserveLineBreaks: false,
collapseBooleanAttributes: true
});
}
};
} else {
logger.info("Output minification disabled");
}
Expand All @@ -99,17 +99,25 @@ exports.publish = function(taffyData, opts, tutorials) {
if (! doclet.name) return;
if (doclet.kind == 'file') return;

var current = renderLinks(helper, JSON.parse(JSON.stringify(doclet)));
var id = current.___id;
delete current.comment;
delete current.meta;
delete current.___id;
delete current.___s;

current.$href = createLink(helper, doclet, taffyData);
current.$id = id;
var current;
try {
current = renderLinks(helper, JSON.parse(JSON.stringify(doclet)));
} catch(e) {
logger.info('Error parsing JSON: ' + JSON.stringify(doclet));
logger.info(e);
}

doccos.push(current);
if (current) {
current.$href = createLink(helper, doclet, taffyData);
current.$id = current.___id;

delete current.comment;
delete current.meta;
delete current.___id;
delete current.___s;

doccos.push(current);
}
});

/* Non-minified angular script */
Expand All @@ -118,7 +126,7 @@ exports.publish = function(taffyData, opts, tutorials) {
+ ".constant('$title', " + (env.conf.templates.windowTitle ? JSON.stringify(env.conf.templates.windowTitle) : "'API documentation'") + ')'
+ ".constant('$readme', " + (opts.readme ? JSON.stringify(opts.readme) : "''") + ')'
+ ".constant('$doclets', " + JSON.stringify(doccos, null, 2) + ');'
+ "})();"
+ "})();";

if (doMinify) {
logger.info("Minifying JavaScript output");
Expand Down Expand Up @@ -166,4 +174,4 @@ exports.publish = function(taffyData, opts, tutorials) {
fs.copyFileSync(file, fontdir);
});

}
};