Skip to content

Commit

Permalink
Bugfix python regexp.
Browse files Browse the repository at this point in the history
  • Loading branch information
rottmann committed Nov 18, 2014
1 parent fc41ebe commit 73bf5f7
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 28 deletions.
30 changes: 15 additions & 15 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,41 +334,41 @@ Parser.prototype._findBlocks = function() {

var regexs = {
'.coffee': {
// Find document blocks between '###' and '###'
// find document blocks between '###' and '###'
docBlocksRegExp: /###\uffff?(.+?)###/g,
// Remove not needed ' ' (tabs) at the beginning
inlineRegExp: /^(\s*)?[ ]?/gm
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.erl': {
// Find document blocks between '%{' and '%}'
docBlocksRegExp: /\%*\{\uffff?(.+?)\%+\}/g,
// Remove not needed ' % ' and ' ' (tabs) at the beginning
// 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,
// Remove not needed ' ' (tabs) at the beginning
inlineRegExp: /^(\s*)?[ ]?/gm
// find document blocks between """ and """
docBlocksRegExp: /\"\"\"\uffff?(.+?)\"\"\"/g,
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.rb': {
// Find document blocks between '=begin' and '=end'
// find document blocks between '=begin' and '=end'
docBlocksRegExp: /\=begin\uffff?(.+?)\=end/g,
// Remove not needed ' ' (tabs) at the beginning
inlineRegExp: /^(\s*)?[ ]?/gm
// remove not needed tabs at the beginning
inlineRegExp: /^(\t*)?/gm
},
'.pm': {
// Find document blocks between '#**' and '#*'
// find document blocks between '#**' and '#*'
// or between '=pod' and '=cut'
docBlocksRegExp: /#\*\*\uffff?(.+?)#\*|=pod\uffff?(.+?)=cut/g,
// Remove not needed ' # ' and ' ' (tabs) at the beginning
// remove not needed ' # ' and tabs at the beginning
inlineRegExp: /^(\s*)?(#)[ ]?/gm
},
'default': {
// Find document blocks between '#**' and '#*'
// find document blocks between '#**' and '#*'
docBlocksRegExp: /\/\*\*\uffff?(.+?)\*\//g,
// Remove not needed ' * ' and ' ' (tabs) at the beginning
// remove not needed ' * ' and tabs at the beginning
inlineRegExp: /^(\s*)?(\*)[ ]?/gm
}
};
Expand Down
70 changes: 65 additions & 5 deletions test/fixtures/api_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ define({ api: [
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -703,7 +703,7 @@ define({ api: [
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand Down Expand Up @@ -905,7 +905,7 @@ define({ api: [
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -917,6 +917,66 @@ define({ api: [
}
]
},
{
"type": "get",
"url": "/language/python",
"title": "Python",
"name": "GetLanguagePython",
"group": "Language",
"version": "0.4.0",
"description": "<p>Test for Python Comment-Syntax.</p> ",
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python"
}
]
},
{
"type": "get",
"url": "/language/python/indented1",
"title": "Python indented 1",
"name": "GetLanguagePythonIndented1",
"group": "Language",
"version": "0.4.0",
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python/indented1"
}
]
},
{
"type": "get",
"url": "/language/python/indented2",
"title": "Python indented 2",
"name": "GetLanguagePythonIndented2",
"group": "Language",
"version": "0.4.0",
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python/indented2"
}
]
},
{
"type": "get",
"url": "/language/ruby",
Expand All @@ -943,7 +1003,7 @@ define({ api: [
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -965,7 +1025,7 @@ define({ api: [
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand Down
70 changes: 65 additions & 5 deletions test/fixtures/api_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -703,7 +703,7 @@
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand Down Expand Up @@ -905,7 +905,7 @@
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -917,6 +917,66 @@
}
]
},
{
"type": "get",
"url": "/language/python",
"title": "Python",
"name": "GetLanguagePython",
"group": "Language",
"version": "0.4.0",
"description": "<p>Test for Python Comment-Syntax.</p> ",
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python"
}
]
},
{
"type": "get",
"url": "/language/python/indented1",
"title": "Python indented 1",
"name": "GetLanguagePythonIndented1",
"group": "Language",
"version": "0.4.0",
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python/indented1"
}
]
},
{
"type": "get",
"url": "/language/python/indented2",
"title": "Python indented 2",
"name": "GetLanguagePythonIndented2",
"group": "Language",
"version": "0.4.0",
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
"filename": "test/fixtures/example/language.py",
"groupTitle": "Language",
"sampleRequest": [
{
"url": "https://api.github.com/v1/language/python/indented2"
}
]
},
{
"type": "get",
"url": "/language/ruby",
Expand All @@ -943,7 +1003,7 @@
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand All @@ -965,7 +1025,7 @@
"examples": [
{
"title": "Test for indented comment.",
"content": "This is example line 2.\nThis is example line 3.\nLine 4 indented (with tab at beginning).\nLine 5 indented.\nThis is example line 6.",
"content": "This is example line 2.\nThis is example line 3.\n Line 4 indented (with tab at beginning).\n Line 5 indented.\nThis is example line 6.",
"type": "json"
}
],
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/api_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define({
},
"generator": {
"version": "0.8.0",
"time": "2014-11-18T08:44:50.010Z"
"time": "2014-11-18T09:02:40.011Z"
},
"apidoc": "0.2.0"
});
2 changes: 1 addition & 1 deletion test/fixtures/api_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"generator": {
"version": "0.8.0",
"time": "2014-11-18T08:44:50.010Z"
"time": "2014-11-18T09:02:40.011Z"
},
"apidoc": "0.2.0"
}
2 changes: 1 addition & 1 deletion test/fixtures/example/language.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This is example line 6.
@apiExample Test for indented comment.
This is example line 2.
This is example line 3.
Line 4 indented (with tab at beginning).
Line 4 indented (with tab at beginning).
Line 5 indented.
This is example line 6.
=cut

0 comments on commit 73bf5f7

Please sign in to comment.