예제 #1
0
    def test_FindsDocComment(self):
        mkdb.ParseCommentBlock(
            textwrap.dedent("""\
             symbol:

             Description.
             """).splitlines(keepends=True))
        self.assertEqual({'symbol': 'Description.\n'}, mkdb.SourceSymbolDocs)
예제 #2
0
    def test_HandlesHTMLEntities(self):
        mkdb.ParseCommentBlock(
            textwrap.dedent("""\
             symbol:

             < & >.
             """).splitlines(keepends=True))
        self.assertEqual({'symbol': '&lt; &amp; &gt;.\n'},
                         mkdb.SourceSymbolDocs)
예제 #3
0
    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'])
예제 #4
0
    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'])
예제 #5
0
    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)
예제 #6
0
    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)
예제 #7
0
    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)
예제 #8
0
    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'])
예제 #9
0
    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'])
예제 #10
0
    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'])
예제 #11
0
    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'])
예제 #12
0
 def test_EmptyInput(self):
     mkdb.ParseCommentBlock([])
     self.assertEqual({}, mkdb.SourceSymbolDocs)