Skip to content

Commit 6106edd

Browse files
committed
Swift: add INTERNAL doc marker to ql.internal classes
1 parent b22da25 commit 6106edd

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

swift/codegen/lib/ql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def last_base(self) -> str:
131131

132132
@property
133133
def has_doc(self) -> bool:
134-
return bool(self.doc)
134+
return bool(self.doc) or self.ql_internal
135135

136136

137137
@dataclass

swift/codegen/templates/ql_class.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ module Generated {
1111
{{#doc}}
1212
* {{.}}
1313
{{/doc}}
14+
{{#ql_internal}}
15+
* INTERNAL: Do not use.
16+
{{/ql_internal}}
1417
*/
1518
{{/has_doc}}
1619
class {{name}} extends Synth::T{{name}}{{#bases}}, {{.}}{{/bases}} {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// generated by {{generator}}, remove this comment if you wish to edit this file
22
private import {{base_import}}
33

4+
{{#ql_internal}}
5+
/**
6+
* INTERNAL: Do not use.
7+
*/
8+
{{/ql_internal}}
49
class {{name}} extends Generated::{{name}} {}

swift/codegen/test/test_ql.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,16 @@ def test_class_with_children():
127127
assert cls.has_children is True
128128

129129

130-
def test_class_with_doc():
131-
cls = ql.Class("Class", doc=["foo", "bar"])
132-
assert cls.has_doc is True
133-
134-
135-
def test_class_without_doc():
136-
cls = ql.Class("Class", doc=[])
137-
assert cls.has_doc is False
130+
@pytest.mark.parametrize("doc,ql_internal,expected",
131+
[
132+
(["foo", "bar"], False, True),
133+
(["foo", "bar"], True, True),
134+
([], False, False),
135+
([], True, True),
136+
])
137+
def test_has_doc(doc, ql_internal, expected):
138+
cls = ql.Class("Class", doc=doc, ql_internal=ql_internal)
139+
assert cls.has_doc is expected
138140

139141

140142
def test_property_with_description():

0 commit comments

Comments
 (0)