summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sauer <ensonic@users.sf.net>2019-04-08 21:53:35 +0200
committerStefan Sauer <ensonic@users.sf.net>2019-04-08 21:53:35 +0200
commitf0e7d623c9af948f54c505c5c8bbc461a7998571 (patch)
tree2f031065dab91bb40522eb1d47ed17d48a5815af
parent22d33eb31961f973ed1be9feeae5b4bc97711e1f (diff)
downloadgtk-doc-f0e7d623c9af948f54c505c5c8bbc461a7998571.tar.gz
mkdb: add test for the section block
Also refactor the test suites a bit before we copy this more often.
-rw-r--r--gtkdoc/mkdb.py2
-rwxr-xr-xtests/mkdb.py51
2 files changed, 45 insertions, 8 deletions
diff --git a/gtkdoc/mkdb.py b/gtkdoc/mkdb.py
index 4f90f50..fff9de6 100644
--- a/gtkdoc/mkdb.py
+++ b/gtkdoc/mkdb.py
@@ -3950,6 +3950,8 @@ def ParseCommentBlockSegments(symbol, segments, params, line_number=0, ifile='')
SourceSymbolSourceFile[key] = ifile
SourceSymbolSourceLine[key] = line_number
+ # TODO(ensonic): we need to track these somehow and output the files
+ # later, see comment in Run()
section_id = SourceSymbolDocs.get(real_symbol + ":section_id")
if section_id and section_id.strip() != '':
# Remove trailing blanks and use as is
diff --git a/tests/mkdb.py b/tests/mkdb.py
index 7ee4873..9af1803 100755
--- a/tests/mkdb.py
+++ b/tests/mkdb.py
@@ -24,10 +24,15 @@ import unittest
from gtkdoc import mkdb
-class ScanSourceContent(unittest.TestCase):
+class ScanSourceContentTestCase(unittest.TestCase):
+ """Baseclass for the source scanner tests."""
def setUp(self):
mkdb.MODULE = 'test'
+ mkdb.SymbolDocs = {}
+
+
+class ScanSourceContent(ScanSourceContentTestCase):
def test_EmptyInput(self):
blocks = mkdb.ScanSourceContent([])
@@ -47,10 +52,7 @@ class ScanSourceContent(unittest.TestCase):
self.assertEqual(1, len(blocks))
-class ParseCommentBlock(unittest.TestCase):
-
- def setUp(self):
- mkdb.MODULE = 'test'
+class ParseCommentBlock(ScanSourceContentTestCase):
def test_EmptyInput(self):
mkdb.ParseCommentBlock([])
@@ -126,10 +128,43 @@ class ParseCommentBlock(unittest.TestCase):
self.assertEqual({'symbol': '&lt; &amp; &gt;.\n'}, mkdb.SourceSymbolDocs)
-class ScanSourceContentAnnotations(unittest.TestCase):
+class ParseSectionCommentBlock(ScanSourceContentTestCase):
- def setUp(self):
- mkdb.MODULE = 'test'
+ 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'])
+
+ # TODO(ensonic): we need to refactor the code first (see comment there)
+ # def test_FindsProgramBlock(self):
+ # mkdb.ParseCommentBlock(textwrap.dedent("""\
+ # PROGRAM:symbol
+ # @short_description: short program description
+ # @synopsis: test-program [*OPTIONS*...] --arg1 *arg* *FILE*
+ # @see_also: test(1)
+ # @--arg1 *arg*: set arg1 to *arg*
+ # @-v, --version: Print the version number
+ # @-h, --help: Print the help message
+ #
+ # Program description.
+ # """).splitlines(keepends=True))
+ # self.assertIn('symbol:short_description', mkdb.SourceSymbolDocs)
+ # self.assertEqual('short program description\n', mkdb.SourceSymbolDocs['symbol:short_description'])
+ # self.assertIn('symbol:long_description', mkdb.SourceSymbolDocs)
+ # self.assertEqual('Program description.\n', mkdb.SourceSymbolDocs['symbol:long_description'])
+
+
+class ScanSourceContentAnnotations(ScanSourceContentTestCase):
def test_ParamAnnotation(self):
mkdb.ParseCommentBlock(textwrap.dedent("""\