Skip to content

Commit

Permalink
Add @apiDeprecated.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Jan 13, 2017
1 parent 089abce commit e52de0a
Showing 2 changed files with 24 additions and 26 deletions.
13 changes: 8 additions & 5 deletions lib/parser.js
Original file line number Diff line number Diff line change
@@ -245,20 +245,23 @@ Parser.prototype._parseBlockElements = function(indexApiBlocks, detectedElements
) {
for (var markdownIndex = 0; markdownIndex < elementParser.markdownFields.length; markdownIndex += 1) {
var field = elementParser.markdownFields[markdownIndex];
if (values[field]) {
values[field] = app.markdownParser.render(values[field]);
var value = _.get(values, field);
if (value) {
value = app.markdownParser.render(value);
// remove line breaks
values[field] = values[field].replace(/(\r\n|\n|\r)/g, ' ');
value = value.replace(/(\r\n|\n|\r)/g, ' ');

values[field] = values[field].trim();
value = value.trim();
_.set(values, field, value);

// TODO: Little hacky, not sure to handle this here or in template
if ( elementParser.markdownRemovePTags &&
elementParser.markdownRemovePTags.length > 0 &&
elementParser.markdownRemovePTags.indexOf(field) !== -1
) {
// Remove p-Tags
values[field] = values[field].replace(/(<p>|<\/p>)/g, '');
value = value.replace(/(<p>|<\/p>)/g, '');
_.set(values, field, value);
}
}
}
37 changes: 16 additions & 21 deletions lib/parsers/api_deprecated.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
var trim = require('../utils/trim');
var unindent = require('../utils/unindent');

function parse(content) {
var deprecated = trim(content);

if (deprecated.length > 0) {
var group = deprecated.split(' ')[0];
group = group.charAt(0).toUpperCase() + group.slice(1);
var name = deprecated.substr(deprecated.indexOf(' ') + 1);
var url = name.replace(/(\s+)/g, '_').replace(/\'/g, '_');
return {
deprecated: {
group: group,
name: name,
url: url
}
};
}
var deprecated = trim(content);

if (deprecated.length > 0) {
return {
deprecated: {
url: null
}
deprecated: {
content: unindent(deprecated)
}
};
}

return {
deprecated: true
};
}

/**
* Exports
*/
module.exports = {
parse : parse,
path : 'local',
method : 'insert'
parse : parse,
path : 'local',
method: 'insert',
markdownFields: [ 'deprecated.content' ],
markdownRemovePTags: [ 'deprecated.content' ]
};

0 comments on commit e52de0a

Please sign in to comment.