mailr16301 - /branches/uf_redesign/prompt/uf_objects.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on May 13, 2012 - 18:45:
Author: bugman
Date: Sun May 13 18:45:04 2012
New Revision: 16301

URL: http://svn.gna.org/viewcvs/relax?rev=16301&view=rev
Log:
Redesigned the prompt help system for the auto-generated user functions.

The documentation is closer to the style in the relax manual, including 
'Synopsis' and 'Default'
sections (i.e. see http://www.nmr-relax.com/manual/value_set.html).


Modified:
    branches/uf_redesign/prompt/uf_objects.py

Modified: branches/uf_redesign/prompt/uf_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/uf_redesign/prompt/uf_objects.py?rev=16301&r1=16300&r2=16301&view=diff
==============================================================================
--- branches/uf_redesign/prompt/uf_objects.py (original)
+++ branches/uf_redesign/prompt/uf_objects.py Sun May 13 18:45:04 2012
@@ -100,23 +100,16 @@
 
         # Function intro text.
         if status.prompt_intro:
-            # The prompt and user function name.
-            text = "%s%s(" % (status.ps3, self._name)
-
-            # The keyword args.
-            for i in range(len(self._kargs)):
-                # Comma separation.
-                if i >= 1:
-                    text += ", "
-
-                # Add the arg.
-                text += "%s=%s" % (self._kargs[i]['name'], 
repr(uf_kargs[self._kargs[i]['name']]))
-
-            # The end.
-            text += ")"
-
-            # Print out.
-            print(text)
+            # Convert the keys and values.
+            keys = []
+            values = []
+            for i in range(self._karg_num):
+                keys.append(self._kargs[i]['name'])
+                values.append(uf_kargs[self._kargs[i]['name']])
+
+            # The print out.
+            asdf
+            print(self._intro_text(keys, values))
 
         # Check the argument values.
         for i in range(self._karg_num):
@@ -243,21 +236,36 @@
         # Initialise.
         doc = ""
 
-        # Add the title.
-        doc = "%s%s\n" % (doc, bold_text(self._title))
+        # A title.
+        doc += build_subtitle("The %s user function." % self._name)
+
+        # The synopsis.
+        doc += build_subtitle("Synopsis")
+        doc += "%s" % self._title
+        doc += "\n\n"
+
+        # The defaults.
+        doc += build_subtitle("Defaults")
+        keys = []
+        values = []
+        for i in range(self._karg_num):
+            keys.append(self._kargs[i]['name'])
+            values.append(self._kargs[i]['default'])
+        doc += "%s" % self._intro_text(keys, values, prompt=False)
+        doc += "\n\n"
 
         # Add the keyword args.
         if self._kargs != None:
             doc += build_subtitle("Keyword Arguments")
             for i in range(len(self._kargs)):
                 # The text.
-                text = "%s:  %s" % (self._kargs[i]['name'], 
self._kargs[i]['desc'])
+                text = "%s:  %s" % (bold_text(self._kargs[i]['name']), 
self._kargs[i]['desc'])
 
                 # Format.
                 text = format_text(text)
 
                 # Add to the docstring.
-                doc = "%s%s\n" % (doc, text)
+                doc += "    %s\n" % text
 
         # Add the description.
         if self._desc != None:
@@ -278,3 +286,42 @@
 
         # Return the documentation.
         return doc
+
+
+    def _intro_text(self, keys, values, prompt=True):
+        """Build and return the user function intro text.
+
+        @param keys:        The user function keys.
+        @type keys:         list of str
+        @param values:      The values corresponding to the keys.
+        @type values:       list
+        @keyword prompt:    A flag which if True will cause the prompt text 
to be included.
+        @type prompt:       bool
+        @return:            The user function intro text.
+        @rtype:             str
+        """
+
+        # Initialise.
+        text = ""
+
+        # The prompt.
+        if prompt:
+            text += status.ps3
+
+        # The user function name.
+        text += "%s(" % self._name
+
+        # The keyword args.
+        for i in range(len(keys)):
+            # Comma separation.
+            if i >= 1:
+                text += ", "
+
+            # Add the arg.
+            text += "%s=%s" % (keys[i], repr(values[i]))
+
+        # The end.
+        text += ")"
+
+        # Return the text.
+        return text




Related Messages


Powered by MHonArc, Updated Sun May 13 19:00:02 2012