dox Executable Documentation

Parse code and comments

Parse method bodies in blocks of code separated by their comments

Just code

When I parse the method body ' $some = 3; $code = $some + 1;'
Then the scenario should be '[ { "content": "$some = 3;\\n$code = $some + 1;", "type": "code" } ]'

Just comment

Unfortunately, a comment is not parsed if there is no code

When I parse the method body '// Just a comment'
Then the scenario should be '[]'

As a workaround, null; is ignored so it can be used to make comments visible

When I parse the method body ' // Just a comment null;'
Then the scenario should be '[ { "content": "Just a comment", "type": "comment" } ]'

Code with line comment

When I parse the method body ' // Some comment describing the code $code = 3 + 4;'
Then the scenario should be '[ { "content": "Some comment describing the code", "type": "comment" }, { "content": "$code = 3 + 4;", "type": "code" } ]'

Code with two line comments

When I parse the method body ' // Some comment describing the code // Some more commenting $code = 3 + 4; $more = $code + 1;'
Then the scenario should be '[ { "content": "Some comment describing the code\\n\\nSome more commenting", "type": "comment" }, { "content": "$code = 3 + 4;\\n$more = $code + 1;", "type": "code" } ]'

Code with block comment

When I parse the method body ' /* * This is some * *block* comment. */ $code = 1 + 1;'
Then the scenario should be '[ { "content": "This is some\\n*block* comment.", "type": "comment" }, { "content": "$code = 1 + 1;", "type": "code" } ]'

Block comment with paragraphs

When I parse the method body ' /* * This is some comment. * * With two paragraphs. */ $code = 1 + 1;'
Then the scenario should be '[ { "content": "This is some comment.\\n\\nWith two paragraphs.", "type": "comment" }, { "content": "$code = 1 + 1;", "type": "code" } ]'

Multiple comments and code

When I parse the method body ' // Some comment $code = 1 + 1; /* * More comments */ $more = $code;'
Then the scenario should be '[ { "content": "Some comment", "type": "comment" }, { "content": "$code = 1 + 1;", "type": "code" }, { "content": "More comments", "type": "comment" }, { "content": "$more = $code;", "type": "code" } ]'