def test_parse_md_docstring(self): def test_function_with_fancy_docstring(arg): """Function with a fancy docstring. And a bunch of references: @{tf.reference}, another @{tf.reference}, a member @{tf.reference.foo}, and a @{tf.third}. Args: arg: An argument. Raises: an exception Returns: arg: the input, and arg: the input, again. @compatibility(numpy) NumPy has nothing as awesome as this function. @end_compatibility @compatibility(theano) Theano has nothing as awesome as this function. Check it out. @end_compatibility """ return arg, arg class HasOneMember(object): def foo(self): pass duplicate_of = {'tf.third': 'tf.fourth'} index = { 'tf.fancy': test_function_with_fancy_docstring, 'tf.reference': HasOneMember, 'tf.reference.foo': HasOneMember.foo, 'tf.third': HasOneMember, 'tf.fourth': HasOneMember } reference_resolver = parser.ReferenceResolver( duplicate_of=duplicate_of, doc_index={}, index=index, py_module_names=['tf']) doc_info = parser._parse_md_docstring(test_function_with_fancy_docstring, '../..', reference_resolver) self.assertNotIn('@', doc_info.docstring) self.assertNotIn('compatibility', doc_info.docstring) self.assertNotIn('Raises:', doc_info.docstring) self.assertEqual(len(doc_info.function_details), 3) self.assertEqual(set(doc_info.compatibility.keys()), {'numpy', 'theano'}) self.assertEqual(doc_info.compatibility['numpy'], 'NumPy has nothing as awesome as this function.\n')