Author: bugman Date: Thu May 31 15:50:34 2012 New Revision: 16560 URL: http://svn.gna.org/viewcvs/relax?rev=16560&view=rev Log: Converted the prompt user function objects to use the new Desc_container objects for the help strings. Modified: branches/uf_redesign/prompt/uf_docstring.py branches/uf_redesign/prompt/uf_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=16560&r1=16559&r2=16560&view=diff ============================================================================== --- branches/uf_redesign/prompt/uf_docstring.py (original) +++ branches/uf_redesign/prompt/uf_docstring.py Thu May 31 15:50:34 2012 @@ -80,44 +80,20 @@ def format_text(text): - """Format the text by stripping whitespace and wrapping. + """Format the line of text by wrapping. - @param text: The text to strip and wrap. + @param text: The line of text to wrap. @type text: str - @return: The stripped and wrapped text. + @return: The wrapped text. @rtype: str """ - # First strip whitespace. - stripped_text = strip_lead(text) - - # Remove the first characters if newlines. - while True: - if stripped_text[0] == "\n": - stripped_text = stripped_text[1:] - else: - break - - # Remove the last character if a newline. - while True: - if stripped_text[-1] == "\n": - stripped_text = stripped_text[:-1] - else: - break - - # Then split into lines. - lines = split(stripped_text, "\n") - # Then wrap each line. new_text = "" - for line in lines: - # Empty line, so preserve. - if not len(line): - new_text = new_text + "\n" - # Wrap the line. - for wrapped_line in wrap(line, status.text_width): - new_text = new_text + wrapped_line + "\n" + # Wrap the line. + for wrapped_line in wrap(text, status.text_width): + new_text += wrapped_line + "\n" # Return the formatted text. return new_text Modified: branches/uf_redesign/prompt/uf_objects.py URL: http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_objects.py?rev=16560&r1=16559&r2=16560&view=diff ============================================================================== --- branches/uf_redesign/prompt/uf_objects.py (original) +++ branches/uf_redesign/prompt/uf_objects.py Thu May 31 15:50:34 2012 @@ -254,31 +254,44 @@ if self._kargs != None: doc += build_subtitle("Keyword Arguments") for i in range(len(self._kargs)): - # The text. - text = "%s: %s" % (bold_text(self._kargs[i]['name']), self._kargs[i]['desc']) + # The unformatted text. + text = " %s: %s" % (self._kargs[i]['name'], self._kargs[i]['desc']) # Format. text = format_text(text) + # Replace the arg text with bold text. + length = 7 + len(self._kargs[i]['name']) + text = " %s: %s" % (bold_text(self._kargs[i]['name']), text[length:]) + # Add to the docstring. - doc += " %s\n" % text - - # Add the description. - if self._desc != None: - doc += build_subtitle("Description") - doc += format_text(self._desc) - - # Add the additional sections. - if self._additional != None: - # Loop over each section. - for i in range(len(self._additional)): - doc += '\n%s' % build_subtitle(self._additional[i][0]) - doc += format_text(self._additional[i][1]) - - # Add the examples. - if self._examples != None: - doc += '\n%s' % build_subtitle("Examples") - doc += format_text(self._examples) + doc += "%s\n" % text + + # Add the description sections. + if isinstance(self._desc, list) and len(self._desc): + # Loop over the sections. + for i in range(len(self._desc)): + # The title. + doc += build_subtitle(self._desc[i].get_title()) + + # Loop over the elements. + for type, element in self._desc[i].element_loop(): + # A paragraph or verbatim text. + if type in ['paragraph', 'verbatim']: + doc += format_text(element) + '\n' + + # A table. + elif type == 'table': + doc += create_table(element) + '\n' + + # A prompt example. + elif type == 'prompt': + # Loop over the prompt examples. + for j in range(len(element)): + doc += format_text(element[j]) + + # Final newline. + doc += '\n' # Return the documentation. return doc