Repository navigation
Support embedding Text test cases into Markdown files - #2621
vairamsvsjdo wants to merge 4 commits into
Conversation
|
Navigating through legacy code constructs in robotframework:
|
pekkaklarck
left a comment
There was a problem hiding this comment.
The approach used looks fine but there were several things that ought to be fixed in the code. Need to also discuss about testing and documentation separately.
| from .txtreader import TxtReader | ||
|
|
||
|
|
||
| def MarkDownReader(): |
There was a problem hiding this comment.
There's no need for this extra factory function. RestReader uses it because the factory imports the external docutils module. This reader needs no external dependencies and MarkdownReader could simply be a class.
| Log hello world from markdown console=yes | ||
| ``` | ||
| ## Some more documentation | ||
| ''' |
There was a problem hiding this comment.
I don't think docstring is too useful. Documentation in general belongs to the User Guide and acknowledgements into AUTHORS.txt, commit messages or elsewhere. In general we've used docstrings only when documenting the public interfaces.
There was a problem hiding this comment.
agreed, will make appropriate change
| self.robot_data = '' | ||
|
|
||
| def robotize(self, md_file): | ||
| f = StringIO(md_file.read().decode('UTF-8')) |
There was a problem hiding this comment.
Wrapping the read data into a StringIO makes no sense. Much easier to just iterate over the lines of the original file.
There was a problem hiding this comment.
makes sense, will make appropriate change.
| include_line = False | ||
| else: | ||
| self.robot_lines.append(line) | ||
| self.robot_data = str(''.join(self.robot_lines)) |
There was a problem hiding this comment.
Using str here is totally unnecessary. It also causes UnicodeDecodeError with Python 2 if the data happens to contain non-ASCII characters.
| from .restreader import RestReader | ||
|
|
||
| from .mdreader import MarkDownReader | ||
|
|
There was a problem hiding this comment.
Should have two empty lines after imports.
| from .mdreader import MarkDownReader | ||
|
|
||
| READERS = {'html': HtmlReader, 'htm': HtmlReader, 'xhtml': HtmlReader, | ||
| 'tsv': TsvReader , 'rst': RestReader, 'rest': RestReader, |
There was a problem hiding this comment.
Fixing small PEP-8 errors here in the code that you edit is fine, but in general it would be better to have them in separate PRs. Having lot of unrelated changes in a PR makes reviewing it harder.
| table = self._datafile.start_table(DataRow(header).all) | ||
| self._populator = self._populators[table.type](table) \ | ||
| if table is not None else NullPopulator() | ||
| if table is not None else NullPopulator() |
There was a problem hiding this comment.
As I already commented, PEP-8 fixes in general belong to own PRs. In this particular case I also happen to like the original style better. Using four spaces for indentation when continuing a line is confusing.
|
Answers to your questions:
|
|
|
@pekkaklarck I was able to find atest for rest:
|
2. Added atest for markdown format 3. Todo: change mdreader finalize changes.
|
@pekkaklarck made changes as requested |
|
Great! Unfortunately I don't have time for a review in immediate future but I hopefully have time for this next week or week after that. |
|
Great, thanks |
|
Development hasn't been too active in the past, but we are starting RF 3.1 development and I'd like to get this enhancement in. On a quick look the approach used looks pretty good, but there are some places where code could be cleaned up a little. For example, imports weren't in format recommended by PEP-8. More importantly, some of the tests looked pretty strange with Robot data inside the code blocks formatted as tables like this: My guess is that these are copied from the current reStructuredText tests, where this format is used when the idea is to convert reST files to HTML and parse them then. We are going to deprecate and remove the support for using HTML data (as well as reST what is converted to HTML), so supporting anything like that with Markdown doesn't make sense either. The current code doesn't seem to support this either, so I would assume it's enough to just remove these tests. |
|
@pekkaklarck This was assumed at the time of making it work in markdown, we decided in our implementation to use reST format such that it will enable us to see these in markdown with syntax highlighting and work as a document for Acceptance Testing. Please provide how you envision and will make changes accordingly. |
|
We got new parser in RF 3.2 (#3076) and this PR is incompatible with it. Support for Markdown would be a nice addition, though, and adding it on top of the new parser ought to be easier than it was earlier. |
Support embedding Text test cases into Markdown files
fixes issue: #2610