summaryrefslogtreecommitdiff
path: root/tests/test_comments.py
blob: 707f7595f8383aa48397a8002a5bf06826ac6fc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from qface.generator import FileSystem
from qface.helper import doc
import logging
import logging.config
from path import Path


# logging.config.fileConfig('logging.ini')
logging.basicConfig()

log = logging.getLogger(__name__)

inputPath = Path('tests/in')


def qdoc_translate(name, value):
    if not value.startswith('http'):
        value = value.replace('.', '::')
    return r'\{0}{{{1}}}'.format(name, value)


# doc.DocObject.translate = translate

def loadEcho():
    path = inputPath / 'org.example.echo.qface'
    return FileSystem.parse_document(path)


def test_comment():
    system = loadEcho()
    doc.translate = None
    module = system.lookup('org.example.echo')
    assert module.comment == '/** module */'
    assert module
    interface = system.lookup('org.example.echo.Echo')
    assert interface
    o = doc.parse_doc(interface.comment)
    # import pdb; pdb.set_trace()
    assert o.brief == 'the brief'
    assert o.description == ['the description', 'continues {@link http://qt.io}']
    assert o.deprecated is True
    # import pdb; pdb.set_trace()
    assert o.see == ['org.example.echo.Echo', 'org.example', 'http://qt.io']


def test_qdoc_translate():
    system = loadEcho()
    module = system.lookup('org.example.echo')
    assert module.comment == '/** module */'
    assert module
    interface = system.lookup('org.example.echo.Echo')
    assert interface
    doc.translate = qdoc_translate
    o = doc.parse_doc(interface.comment)
    assert o.description == ['the description', 'continues \\link{http://qt.io}']