コード例 #1
0
ファイル: argument.py プロジェクト: enthought/sectiondoc
    def to_rst(self):
        """ Render an item as an argument using the ``:param:``
        role.

        Example
        -------

        ::

            >>> item = Item('indent', 'int',
            ... ['The indent to use for the description block.',
                 ''
                 'This is the second paragraph of the argument definition.'])
            >>> renderer = Argument(item)
            >>> renderer.to_rst()
            :param indent:
                The indent to use for the description block.
                This is the second paragraph of the argument definition.
            :type indent: int

        .. note::

            There is no new line added at the last line of the :meth:`to_rst`
            method.

        """
        item = self.item
        argument = fix_star(item.term)
        argument = fix_trailing_underscore(argument)
        argument_types = ' or '.join(item.classifiers)
        definition = '\n'.join(add_indent(item.definition))
        template = self.templates[item.mode].format(
            argument, argument_types, definition)
        return template.splitlines()
コード例 #2
0
 def test_fix_star(self):
     output = fix_star('*arg')
     self.assertEqual(r'\*arg', output)
     output = fix_star('**sfg')
     self.assertEqual(r'\*\*sfg', output)