Author: bugman Date: Fri Jun 1 13:31:40 2012 New Revision: 16584 URL: http://svn.gna.org/viewcvs/relax?rev=16584&view=rev Log: Added support for no spacing in tables for the prompt help strings. The Desc_container.add_table_titles() method now accepts and stores the 'spacing' arg. This is passed all the way into the prompt help system to format the tables with. Modified: branches/uf_redesign/prompt/uf_docstring.py branches/uf_redesign/prompt/uf_objects.py branches/uf_redesign/user_functions/objects.py Modified: branches/uf_redesign/prompt/uf_docstring.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_docstring.py?rev=16584&r1=16583&r2=16584&view=diff ============================================================================== --- branches/uf_redesign/prompt/uf_docstring.py (original) +++ branches/uf_redesign/prompt/uf_docstring.py Fri Jun 1 13:31:40 2012 @@ -88,13 +88,15 @@ return new -def create_table(table): +def create_table(table, spacing=True): """Format and return the table as text. - @param table: The table data. - @type table: list of lists of str - @return: The formatted table. - @rtype: str + @param table: The table data. + @type table: list of lists of str + @keyword spacing: A flag which if True will cause empty rows to be placed between elements. + @type spacing: bool + @return: The formatted table. + @rtype: str """ # Initialise some variables. @@ -217,8 +219,9 @@ # Pack the data. col_text[k][j] = lines[k] - # Blank line. - text += table_line(widths=new_widths) + # Blank line (between rows when asked, and for the first row after the header). + if spacing or i == 1: + text += table_line(widths=new_widths) # The contents. for k in range(num_lines): Modified: branches/uf_redesign/prompt/uf_objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_objects.py?rev=16584&r1=16583&r2=16584&view=diff ============================================================================== --- branches/uf_redesign/prompt/uf_objects.py (original) +++ branches/uf_redesign/prompt/uf_objects.py Fri Jun 1 13:31:40 2012 @@ -326,7 +326,7 @@ doc += build_subtitle(self._desc[i].get_title()) # Loop over the elements. - for type, element in self._desc[i].element_loop(): + for type, element, format in self._desc[i].element_loop(format=True): # A paragraph or verbatim text. if type == 'paragraph': doc += format_text(element) + '\n' @@ -355,7 +355,7 @@ # A table. elif type == 'table': - doc += create_table(element) + '\n' + doc += create_table(element, spacing=format) + '\n' # A prompt example. elif type == 'prompt': Modified: branches/uf_redesign/user_functions/objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/user_functions/objects.py?rev=16584&r1=16583&r2=16584&view=diff ============================================================================== --- branches/uf_redesign/user_functions/objects.py (original) +++ branches/uf_redesign/user_functions/objects.py Fri Jun 1 13:31:40 2012 @@ -97,6 +97,7 @@ # Initialise internal storage objects. self._data = [] self._types = [] + self._format = {} def add_item_list_element(self, item, text): @@ -164,16 +165,21 @@ self._data[-1].append(text) - def add_table_titles(self, titles): + def add_table_titles(self, titles, spacing=True): """Add a row of table titles to the description. - @param text: The table titles. - @type text: list of str + @param titles: The table titles. + @type titles: list of str + @keyword spacing: A flag which if True will cause empty rows to be placed between elements. + @type spacing: bool """ # Create a new table. self._data.append([titles]) self._types.append('table') + + # Store the formatting. + self._format[repr(len(self._data)-1)] = spacing def add_table_row(self, row): @@ -205,16 +211,29 @@ self._types.append('verbatim') - def element_loop(self): + def element_loop(self, format=False): """Iterator method yielding the description elements. - @return: The element type and corresponding data. - @rtype: str and anything + @keyword format: A flag which if True will cause formatting information to be returned. + @return: The element type and corresponding data (and formatting info, if asked for). + @rtype: str and anything """ # Loop over the elements. for i in range(len(self._data)): - yield self._types[i], self._data[i] + # The format. + if format: + # The key and value. + key = repr(i) + val = None + if self._format.has_key(key): + val = self._format[key] + + yield self._types[i], self._data[i], val + + # No format. + else: + yield self._types[i], self._data[i] def get_title(self):