Skip to content

Commit

Permalink
Bugfix: Extend parser regexp to allow inline comment-code apidoc#180.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Dec 15, 2014
1 parent ce0827d commit 34ecdfa
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,39 +335,45 @@ Parser.prototype._findBlocks = function() {
var regexs = {
'.coffee': {
// find document blocks between '###' and '###'
docBlocksRegExp: /###\uffff?(.+?)###/g,
// docBlocksRegExp: /###\uffff?(.+?)###/g,
docBlocksRegExp: /###\uffff?(.+?)\uffff(?:\s*)?###/g,
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.erl': {
// Find document blocks between '%{' and '%}'
docBlocksRegExp: /\%*\{\uffff?(.+?)\%+\}/g,
// docBlocksRegExp: /\%*\{\uffff?(.+?)\%+\}/g,
docBlocksRegExp: /\%*\{\uffff?(.+?)\uffff(?:\s*)?\%+\}/g,
// remove not needed ' % ' and tabs at the beginning
// HINT: Not sure if erlang developer use the %, but i think it should be no problem
inlineRegExp: /^(\s*)?(\%*)[ ]?/gm
},
'.py': {
// find document blocks between """ and """
docBlocksRegExp: /\"\"\"\uffff?(.+?)\"\"\"/g,
// docBlocksRegExp: /\"\"\"\uffff?(.+?)\"\"\"/g,
docBlocksRegExp: /\"\"\"\uffff?(.+?)\uffff(?:\s*)?\"\"\"/g,
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.rb': {
// find document blocks between '=begin' and '=end'
docBlocksRegExp: /\=begin\uffff?(.+?)\=end/g,
// docBlocksRegExp: /\=begin\uffff?(.+?)\=end/g,
docBlocksRegExp: /\=begin\uffff?(.+?)\uffff(?:\s*)?\=end/g,
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.pm': {
// find document blocks between '#**' and '#*'
// or between '=pod' and '=cut'
docBlocksRegExp: /#\*\*\uffff?(.+?)#\*|=pod\uffff?(.+?)=cut/g,
// docBlocksRegExp: /#\*\*\uffff?(.+?)#\*|=pod\uffff?(.+?)=cut/g,
docBlocksRegExp: /#\*\*\uffff?(.+?)\uffff(?:\s*)?#\*|=pod\uffff?(.+?)\uffff(?:\s*)?=cut/g,
// remove not needed ' # ' and tabs at the beginning
inlineRegExp: /^(\s*)?(#)[ ]?/gm
},
'default': {
// find document blocks between '#**' and '#*'
docBlocksRegExp: /\/\*\*\uffff?(.+?)\*\//g,
// docBlocksRegExp: /\/\*\*\uffff?(.+?)\*\//g,
docBlocksRegExp: /\/\*\*\uffff?(.+?)\uffff(?:\s*)?\*\//g,
// remove not needed ' * ' and tabs at the beginning
inlineRegExp: /^(\s*)?(\*)[ ]?/gm
}
Expand All @@ -381,7 +387,6 @@ Parser.prototype._findBlocks = function() {
block = block.replace(/\uffff/g, '\n');

block = block.replace(regexForFile.inlineRegExp, '');

blocks.push(block);

// Find next
Expand Down

0 comments on commit 34ecdfa

Please sign in to comment.