apidoc-core
Version:
Core parser library to generate apidoc result following the apidoc-spec
29 lines (23 loc) • 545 B
JavaScript
var trim = require('../utils/trim');
function parse(content) {
content = trim(content);
// Search: type, url and title
// Example: {get} /user/:id Get User by ID.
var parseRegExp = /^(?:(?:\{(.+?)\})?\s*)?(.+?)(?:\s+(.+?))?$/g;
var matches = parseRegExp.exec(content);
if ( ! matches)
return null;
return {
type : matches[1],
url : matches[2],
title: matches[3] || ''
};
}
/**
* Exports
*/
module.exports = {
parse : parse,
path : 'local',
method: 'insert'
};