Status: New Owner: ---- Labels: Type-Enhancement Priority-Medium
New issue 173 by SonOfLilit: Parser could allow "non-table comments" http://code.google.com/p/robotframework/issues/detail?id=173 Today, a robot table starts with an HTML <table> tag and ends with the matching </table>. Also, currently I know of no way to write interleaved testing code and pretty HTML explanations. The parser could easily be changed to allow the second, changing the first: | Test | Action | Argument | Argument | | # not-pretty comment that explains stuff | | | | | A test | A keyword | Arg | | | # more explanations | | | | | | Foo | Bar | | Could instead be written as: | Test | Action | Argument | Argument | This is outside the table. Therefore, the parser doesn't care a bit and we can write paragraphs of text, add pictures, do whatever we feel like doing. <H1>So here's a pretty explanation of the next test</H1> | A test | A keyword | Arg | | The next keyword is gonna foo the bar. Isn't this much prettier than a "# comment" inside the table? | | Foo | Bar | | How is this done? Instead of the parser ignoring tables that don't start with either "Settings", "Variables", "Keywords" or "Tests", the parser will only ignore tables starting with "Comment" (or another selected keyword). Also, it will only emit "end of table" tokens upon meeting a new table that starts with either "Settings", "Variables", "Keywords" or "Tests". This enhancement would allow me to write much more readable acceptance tests in robot framework without detracting a bit from the power of the language. It would only require changes to this area in parsing/htmlreader.py: # from table_name = self.current_row[0] if self.data.start_table(table_name): self.state = self.PROCESS else: self.state = self.IGNORE # to something like table_name = self.current_row[0] self.data.start_table(table_name): self.state = self.PROCESS and in parsing/rawdata.py: # from def start_table(self, name): """Makes rawdata instance ready to receive new data This method should be called with table's name before adding table's data with 'add_row'. Returns False if data from specified table will not be processed. Client should thus check the return value and only call 'add_row' if it is True. """ name = self._collapse_whitespace(name) table, data = self._get_table_and_data(name) if table is not None: self._table = table(name, self.source, data, self._syslog) else: self._table = None return self._table is not None # to something like def start_table(self, name): """Makes rawdata instance ready to receive new data This method should be called with table's name before adding table's data with 'add_row'. Returns False if data from specified table will be processed as part of pre-existing table. """ name = self._collapse_whitespace(name) table, data = self._get_table_and_data(name) if table is not None: self._table = table(name, self.source, data, self._syslog) else: if self._table is None: throw RuntimeException("First table has to start with table-type row") return table is not None These aren't tested, of course, and should only be seen as pseudo-code. They also lack support for non-robot tables. ("comment tables"). -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings
