Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
assert o.brief == ['the brief']
assert o.description == ['the description', 'continues {@link http://qt.io}', 'continued description']
assert o.deprecated is True
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}', 'continued description']
def run(src, dst):
log.debug('run {0} {1}'.format(src, dst))
system = FileSystem.parse(src)
generator = Generator(search_path=here / 'templates')
generator.register_filter('returnType', Filters.returnType)
generator.register_filter('parameterType', Filters.parameterType)
generator.register_filter('defaultValue', Filters.defaultValue)
generator.register_filter('parameters', Filters.parameters)
generator.register_filter('parse_doc', parse_doc)
ctx = {'dst': dst}
for module in system.modules:
log.debug('generate code for module %s', module)
ctx.update({'module': module})
dst = generator.apply('{{dst}}/{{module|lower|replace(".", "-")}}', ctx)
generator.destination = dst
generator.write('.qmake.conf', 'qmake.conf', ctx)
generator.write('{{module|lower|replace(".", "-")}}.pro', 'plugin.pro', ctx, preserve=True)
generator.write('CMakeLists.txt', 'CMakeLists.txt', ctx)
generator.write('plugin.cpp', 'plugin.cpp', ctx, preserve=True)
generator.write('plugin.h', 'plugin.h', ctx, preserve=True)
generator.write('qmldir', 'qmldir', ctx, preserve=True)
generator.write('generated/generated.pri', 'generated/generated.pri', ctx)
generator.write('generated/qml{{module.module_name|lower}}module.h', 'generated/module.h', ctx)
generator.write('generated/qml{{module.module_name|lower}}module.cpp', 'generated/module.cpp', ctx)
generator.write('generated/qmlvariantmodel.h', 'generated/variantmodel.h', ctx)
def module_info(text):
system = FileSystem.parse_text(text)
module = list(system.modules)[0]
return {
'title': module.name,
'brief': " ".join(doc.parse_doc(module.comment).brief)
}