Exemple #1
0
    def test_explicit_role_actual(self):
        """Workaround output for issue #1."""
        def test():
            """start :py:class:`int` end"""

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, 'start :py:class:`int` end')
Exemple #2
0
    def test_no_doc(self):
        def test(param):
            pass

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, '')
        self.assertEqual(doc.params, {})
Exemple #3
0
    def test_numpy(self):
        # Docstring taken from Napoleon's example (plus a keyword argument).
        def func(arg1, arg2, arg3=None):
            """One line summary.

            Extended description.

            Parameters
            ----------
            arg1 : int
                Description of arg1
            arg2 : str
                Description of arg2
            Keyword Arguments
            -----------------
            arg3 : float
                Description of arg3
            Returns
            -------
            str
                Description of return value.
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #4
0
    def test_explicit_role_desired(self):
        """Desired output for issue #1."""
        def test():
            """start :py:class:`int` end"""

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, 'start int end')
Exemple #5
0
 def test_param_only(self):
     def test(param):
         """:param int param: test"""
     doc = defopt._parse_doc(test)
     self.assertEqual(doc.text, '')
     param = doc.params['param']
     self.assertEqual(param.text, 'test')
     self.assertEqual(param.type, 'int')
Exemple #6
0
    def test_param_only(self):
        def test(param):
            """:param int param: test"""

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, '')
        param = doc.params['param']
        self.assertEqual(param.text, 'test')
        self.assertEqual(param.type, 'int')
Exemple #7
0
    def test_parse_doubles(self):
        def test(param):
            """Test function

            :param int param: the parameter
            :type param: int
            """
        with self.assertRaises(ValueError):
            defopt._parse_doc(test)

        def test(param):
            """Test function

            :type param: int
            :param int param: the parameter
            """
        with self.assertRaises(ValueError):
            defopt._parse_doc(test)
Exemple #8
0
    def test_literal_block(self):
        def func():
            """
            ::

                Literal block
                    Multiple lines
            """
        doc = defopt._parse_doc(func)
        self.assertEqual(doc.text, '    Literal block\n        Multiple lines')
Exemple #9
0
    def test_literal_block(self):
        def func():
            """
            ::

                Literal block
                    Multiple lines
            """

        doc = defopt._parse_doc(func)
        self.assertEqual(doc.text, '    Literal block\n        Multiple lines')
Exemple #10
0
    def test_parse_doubles(self):
        def test(param):
            """Test function

            :param int param: the parameter
            :type param: int
            """

        with self.assertRaises(ValueError):
            defopt._parse_doc(test)

        def test(param):
            """Test function

            :type param: int
            :param int param: the parameter
            """

        with self.assertRaises(ValueError):
            defopt._parse_doc(test)
Exemple #11
0
    def test_sphinx(self):
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            :param int arg1: Description of `arg1`
            :param str arg2: Description of `arg2`
            :returns: Description of return value.
            :rtype: str
            """
        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #12
0
    def test_sphinx(self):
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            :param int arg1: Description of `arg1`
            :param str arg2: Description of `arg2`
            :returns: Description of return value.
            :rtype: str
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #13
0
    def test_sphinx(self):
        def func(arg1, arg2, arg3=None):
            """One line summary.

            Extended description.

            :param int arg1: Description of arg1
            :param str arg2: Description of arg2
            :keyword float arg3: Description of arg3
            :returns: Description of return value.
            :rtype: str
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #14
0
    def test_google(self):
        # Docstring taken from Napoleon's example.
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            Args:
              arg1(int): Description of `arg1`
              arg2(str): Description of `arg2`
            Returns:
              str: Description of return value.
            """
        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #15
0
    def test_google(self):
        # Docstring taken from Napoleon's example.
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            Args:
              arg1(int): Description of `arg1`
              arg2(str): Description of `arg2`
            Returns:
              str: Description of return value.
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #16
0
    def test_parse_doc(self):
        def test(one, two):
            """Test function

            :param one: first param
            :type one: int
            :param float two: second param
            :returns: str
            :junk one two: nothing
            """
        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, 'Test function')
        one = doc.params['one']
        self.assertEqual(one.text, 'first param')
        self.assertEqual(one.type, 'int')
        two = doc.params['two']
        self.assertEqual(two.text, 'second param')
        self.assertEqual(two.type, 'float')
Exemple #17
0
    def test_google(self):
        # Docstring taken from Napoleon's example (plus a keyword argument).
        def func(arg1, arg2, arg3=None):
            """One line summary.

            Extended description.

            Args:
              arg1(int): Description of arg1
              arg2(str): Description of arg2
            Keyword Arguments:
              arg3(float): Description of arg3
            Returns:
              str: Description of return value.
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #18
0
    def test_parse_doc(self):
        def test(one, two):
            """Test function

            :param one: first param
            :type one: int
            :param float two: second param
            :returns: str
            :junk one two: nothing
            """

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, 'Test function')
        one = doc.params['one']
        self.assertEqual(one.text, 'first param')
        self.assertEqual(one.type, 'int')
        two = doc.params['two']
        self.assertEqual(two.text, 'second param')
        self.assertEqual(two.type, 'float')
Exemple #19
0
    def test_parse_params(self):
        def test(first, second, third, fourth, fifth, sixth):
            """Test function

            :param first: first param
            :parameter int second: second param
            :arg third: third param
            :argument float fourth: fourth param
            :key fifth: fifth param
            :keyword str sixth: sixth param
            """

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.params['first'].text, 'first param')
        self.assertEqual(doc.params['second'].text, 'second param')
        self.assertEqual(doc.params['third'].text, 'third param')
        self.assertEqual(doc.params['fourth'].text, 'fourth param')
        self.assertEqual(doc.params['fifth'].text, 'fifth param')
        self.assertEqual(doc.params['sixth'].text, 'sixth param')
Exemple #20
0
    def test_numpy(self):
        # Docstring taken from Napoleon's example.
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            Parameters
            ----------
            arg1 : int
                Description of `arg1`
            arg2 : str
                Description of `arg2`
            Returns
            -------
            str
                Description of return value.
            """
        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #21
0
    def test_numpy(self):
        # Docstring taken from Napoleon's example.
        def func(arg1, arg2):
            """One line summary.

            Extended description.

            Parameters
            ----------
            arg1 : int
                Description of `arg1`
            arg2 : str
                Description of `arg2`
            Returns
            -------
            str
                Description of return value.
            """

        doc = defopt._parse_doc(func)
        self._check_doc(doc)
Exemple #22
0
 def test_no_doc(self):
     def test(param):
         pass
     doc = defopt._parse_doc(test)
     self.assertEqual(doc.text, '')
     self.assertEqual(doc.params, {})
Exemple #23
0
 def test_implicit_role(self):
     def test():
         """start `int` end"""
     doc = defopt._parse_doc(test)
     self.assertEqual(doc.text, 'start int end')
Exemple #24
0
 def test_explicit_role_desired(self):
     """Desired output for issue #1."""
     def test():
         """start :py:class:`int` end"""
     doc = defopt._parse_doc(test)
     self.assertEqual(doc.text, 'start int end')
Exemple #25
0
 def test_explicit_role_actual(self):
     """Workaround output for issue #1."""
     def test():
         """start :py:class:`int` end"""
     doc = defopt._parse_doc(test)
     self.assertEqual(doc.text, 'start :py:class:`int` end')
Exemple #26
0
    def test_implicit_role(self):
        def test():
            """start `int` end"""

        doc = defopt._parse_doc(test)
        self.assertEqual(doc.text, 'start int end')