Exemplo n.º 1
0
    def _format_text(self, text):
        """Format the text by stripping whitespace.

        @param text:    The text to strip.
        @type text:     str
        @return:        The stripped 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

        # Return the text.
        return stripped_text
Exemplo n.º 2
0
    def _format_text(self, text):
        """Format the text by stripping whitespace.

        @param text:    The text to strip.
        @type text:     str
        @return:        The stripped 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

        # Return the text.
        return stripped_text
Exemplo n.º 3
0
    def _build_doc(self):
        """Create the user function class documentation.

        @return:    The user function class documentation to use in the help system.
        @rtype:     str
        """

        # Initialise.
        doc = ""

        # The title.
        doc += build_subtitle("The %s user function class." % self._name,
                              start_nl=False)

        # The synopsis.
        doc += build_subtitle("Synopsis")
        doc += self._desc
        doc += "\n\n"

        # Usage help string.
        doc += build_subtitle("Usage")
        doc += format_text(relax_class_help)
        doc += "\n"

        # Add a description to the help string.
        if hasattr(self, '__description__'):
            doc += build_subtitle("Description")
            doc += "\n\n%s\n" % strip_lead(self.__description__)

        # The member user functions.
        doc += build_subtitle("Contents")
        doc += "This class contains the following user functions:\n\n"
        for uf_name, uf in uf_info.uf_loop(self._name):
            # The unformatted text.
            text = "    %s:  %s" % (uf_name, uf.title)

            # Format.
            text = format_text(text)

            # Replace the arg text with bold text.
            length = 7 + len(uf_name)
            text = "    %s:  %s" % (bold_text(uf_name), text[length:])

            # Add to the docstring.
            doc += "%s\n" % text

        # Return the documentation.
        return doc
Exemplo n.º 4
0
    def _build_doc(self):
        """Create the user function class documentation.

        @return:    The user function class documentation to use in the help system.
        @rtype:     str
        """

        # Initialise.
        doc = ""

        # The title.
        doc += build_subtitle("The %s user function class." % self._name, start_nl=False)

        # The synopsis.
        doc += build_subtitle("Synopsis")
        doc += self._desc
        doc += "\n\n"

        # Usage help string.
        doc += build_subtitle("Usage")
        doc += format_text(relax_class_help)
        doc += "\n"

        # Add a description to the help string.
        if hasattr(self, '__description__'):
            doc += build_subtitle("Description")
            doc += "\n\n%s\n" % strip_lead(self.__description__)

        # The member user functions.
        doc += build_subtitle("Contents")
        doc += "This class contains the following user functions:\n\n"
        for uf_name, uf in uf_info.uf_loop(self._name):
            # The unformatted text.
            text = "    %s:  %s" % (uf_name, uf.title)

            # Format.
            text = format_text(text)

            # Replace the arg text with bold text.
            length = 7 + len(uf_name)
            text = "    %s:  %s" % (bold_text(uf_name), text[length:])

            # Add to the docstring.
            doc += "%s\n" % text

        # Return the documentation.
        return doc