Swift: add INTERNAL doc marker to ql.internal classes

This commit is contained in:
Paolo Tranquilli
2023-01-17 10:30:59 +01:00
parent b22da25e05
commit 6106edd5e2
4 changed files with 19 additions and 9 deletions

View File

@@ -131,7 +131,7 @@ class Class:
@property
def has_doc(self) -> bool:
return bool(self.doc)
return bool(self.doc) or self.ql_internal
@dataclass

View File

@@ -11,6 +11,9 @@ module Generated {
{{#doc}}
* {{.}}
{{/doc}}
{{#ql_internal}}
* INTERNAL: Do not use.
{{/ql_internal}}
*/
{{/has_doc}}
class {{name}} extends Synth::T{{name}}{{#bases}}, {{.}}{{/bases}} {

View File

@@ -1,4 +1,9 @@
// generated by {{generator}}, remove this comment if you wish to edit this file
private import {{base_import}}
{{#ql_internal}}
/**
* INTERNAL: Do not use.
*/
{{/ql_internal}}
class {{name}} extends Generated::{{name}} {}

View File

@@ -127,14 +127,16 @@ def test_class_with_children():
assert cls.has_children is True
def test_class_with_doc():
cls = ql.Class("Class", doc=["foo", "bar"])
assert cls.has_doc is True
def test_class_without_doc():
cls = ql.Class("Class", doc=[])
assert cls.has_doc is False
@pytest.mark.parametrize("doc,ql_internal,expected",
[
(["foo", "bar"], False, True),
(["foo", "bar"], True, True),
([], False, False),
([], True, True),
])
def test_has_doc(doc, ql_internal, expected):
cls = ql.Class("Class", doc=doc, ql_internal=ql_internal)
assert cls.has_doc is expected
def test_property_with_description():