def test_FindsDocComment(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: Description. """).splitlines(keepends=True)) self.assertEqual({'symbol': 'Description.\n'}, mkdb.SourceSymbolDocs)
def test_HandlesHTMLEntities(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: < & >. """).splitlines(keepends=True)) self.assertEqual({'symbol': '< & >.\n'}, mkdb.SourceSymbolDocs)
def test_FindsDocCommentWithStability(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: Stability: stable """).splitlines(keepends=True)) self.assertIn('symbol', mkdb.StabilityLevel) self.assertEqual('Stable', mkdb.StabilityLevel['symbol'])
def test_FindsDocCommentWithSince(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: Since: 0.1 """).splitlines(keepends=True)) self.assertIn('symbol', mkdb.Since) self.assertEqual('0.1', mkdb.Since['symbol'])
def test_FindsDocCommentForProperty(self): mkdb.SourceSymbolDocs = {} mkdb.ParseCommentBlock( textwrap.dedent("""\ Class:property-with-dashes: Description. """).splitlines(keepends=True)) self.assertEqual({'Class:property-with-dashes': 'Description.\n'}, mkdb.SourceSymbolDocs)
def test_RetunsAnnotation(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: description. Returns: (transfer full) result. """).splitlines(keepends=True)) # TODO: we only extract those when outputting docbook, thats silly self.assertEqual({}, mkdb.SymbolAnnotations)
def test_ParamAnnotation(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: @par: (allow-none): value description. """).splitlines(keepends=True)) # TODO: we only extract those when outputting docbook, thats silly # self.assertEqual({'par': 'value\n'}, mkdb.SourceSymbolParams['symbol']) self.assertEqual({}, mkdb.SymbolAnnotations)
def test_FindsDocCommentWithParam(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: @par: value Description. """).splitlines(keepends=True)) self.assertEqual({'symbol': 'Description.\n'}, mkdb.SourceSymbolDocs) self.assertIn('symbol', mkdb.SourceSymbolParams) self.assertEqual({'par': 'value\n'}, mkdb.SourceSymbolParams['symbol'])
def test_FindsDocCommentWithDeprecated(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: Deprecated: use function() instead """).splitlines(keepends=True)) self.assertIn('symbol', mkdb.Deprecated) # TODO: trim whitespace in code self.assertEqual(' use function() instead\n', mkdb.Deprecated['symbol'])
def test_FindsDocCommentWithReturns(self): mkdb.ParseCommentBlock( textwrap.dedent("""\ symbol: Description. Returns: result """).splitlines(keepends=True)) # TODO: trim multiple newlines in code self.assertEqual({'symbol': 'Description.\n\n'}, mkdb.SourceSymbolDocs) self.assertIn('symbol', mkdb.SourceSymbolParams) # TODO: trim whitespace in code self.assertEqual({'Returns': ' result\n'}, mkdb.SourceSymbolParams['symbol'])
def test_FindsSectionBlock(self): # TODO: maybe override common.LogWarning() instead and capture the messages # Suppress: 'Section symbol is not defined in the test-sections.txt file' mkdb.KnownSymbols['symbol:long_description'] = 1 mkdb.ParseCommentBlock( textwrap.dedent("""\ SECTION:symbol @short_description: short module description Module description. """).splitlines(keepends=True)) self.assertIn('symbol:short_description', mkdb.SourceSymbolDocs) self.assertEqual('short module description\n', mkdb.SourceSymbolDocs['symbol:short_description']) self.assertIn('symbol:long_description', mkdb.SourceSymbolDocs) self.assertEqual('Module description.\n', mkdb.SourceSymbolDocs['symbol:long_description'])
def test_EmptyInput(self): mkdb.ParseCommentBlock([]) self.assertEqual({}, mkdb.SourceSymbolDocs)