Skip to content

Commit 492d5ae

Browse files
committed
Swift: rename doc to description in properties
1 parent 861377f commit 492d5ae

File tree

8 files changed

+27
-26
lines changed

8 files changed

+27
-26
lines changed

swift/codegen/generators/qlgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, prev_child: str =
6767
prev_child=prev_child if prop.is_child else None,
6868
is_optional=prop.is_optional,
6969
is_predicate=prop.is_predicate,
70-
doc=prop.doc,
70+
description=prop.description,
7171
)
7272
if prop.is_single:
7373
args.update(

swift/codegen/lib/ql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Property:
3838
is_predicate: bool = False
3939
prev_child: Optional[str] = None
4040
qltest_skip: bool = False
41-
doc: List[str] = field(default_factory=list)
41+
description: List[str] = field(default_factory=list)
4242
doc_name: Optional[str] = None
4343
doc_name_plural: Optional[str] = None
4444

@@ -74,8 +74,8 @@ def is_child(self):
7474
return self.prev_child is not None
7575

7676
@property
77-
def has_doc(self) -> bool:
78-
return bool(self.doc)
77+
def has_description(self) -> bool:
78+
return bool(self.description)
7979

8080

8181
@dataclass

swift/codegen/lib/schema/defs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class _DescModifier(_schema.PropertyModifier):
2626
description: str
2727

2828
def modify(self, prop: _schema.Property):
29-
prop.doc = _schema.split_doc(self.description)
29+
prop.description = _schema.split_doc(self.description)
3030

3131

3232
def include(source: str):

swift/codegen/lib/schema/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Kind(Enum):
3737
is_child: bool = False
3838
pragmas: List[str] = field(default_factory=list)
3939
doc_name: Optional[str] = None
40-
doc: List[str] = field(default_factory=list)
40+
description: List[str] = field(default_factory=list)
4141

4242
@property
4343
def is_single(self) -> bool:

swift/codegen/templates/ql_class.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ module Generated {
7171
}
7272

7373
/**
74-
* {{>ql_property_doc}}{{#has_doc}}{{#doc}} * {{.}}
75-
{{/doc}}
76-
{{/has_doc}}
74+
* {{>ql_property_doc}}{{#has_description}}{{#description}} * {{.}}
75+
{{/description}}
76+
{{/has_description}}
7777
*/
7878
final {{type}} {{getter}}({{#is_repeated}}int index{{/is_repeated}}) {
7979
result = getImmediate{{singular}}({{#is_repeated}}index{{/is_repeated}}).resolve()
@@ -83,9 +83,9 @@ module Generated {
8383
{{^type_is_class}}
8484
{{^is_predicate}}
8585
/**
86-
* {{>ql_property_doc}}{{#has_doc}}{{#doc}} * {{.}}
87-
{{/doc}}
88-
{{/has_doc}}
86+
* {{>ql_property_doc}}{{#has_description}}{{#description}} * {{.}}
87+
{{/description}}
88+
{{/has_description}}
8989
*/
9090
{{/is_predicate}}
9191
{{#is_predicate}}

swift/codegen/test/test_ql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ def test_class_without_doc():
137137
assert cls.has_doc is False
138138

139139

140-
def test_property_with_doc():
141-
prop = ql.Property("X", "int", doc=["foo", "bar"])
142-
assert prop.has_doc is True
140+
def test_property_with_description():
141+
prop = ql.Property("X", "int", description=["foo", "bar"])
142+
assert prop.has_description is True
143143

144144

145-
def test_class_without_doc():
145+
def test_class_without_description():
146146
prop = ql.Property("X", "int")
147-
assert prop.has_doc is False
147+
assert prop.has_description is False
148148

149149

150150
if __name__ == '__main__':

swift/codegen/test/test_qlgen.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,18 +633,19 @@ def test_test_class_hierarchy_uncollapse_at_final(opts, generate_tests):
633633
}
634634

635635

636-
def test_property_doc(generate_classes):
637-
doc = ["Lorem", "Ipsum"]
636+
def test_property_description(generate_classes):
637+
description = ["Lorem", "Ipsum"]
638638
assert generate_classes([
639639
schema.Class("MyObject", properties=[
640-
schema.SingleProperty("foo", "bar", doc=doc),
640+
schema.SingleProperty("foo", "bar", description=description),
641641
]),
642642
]) == {
643643
"MyObject.qll": (ql.Stub(name="MyObject", base_import=gen_import_prefix + "MyObject"),
644644
ql.Class(name="MyObject", final=True,
645645
properties=[
646646
ql.Property(singular="Foo", type="bar", tablename="my_objects",
647-
tableparams=["this", "result"], doc_name="foo", doc=doc),
647+
tableparams=["this", "result"], doc_name="foo",
648+
description=description),
648649
])),
649650
}
650651

swift/codegen/test/test_schema.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class A:
428428
x: int | defs.desc("very important property.")
429429

430430
assert data.classes == {
431-
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important property."])])
431+
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important property."])])
432432
}
433433

434434

@@ -452,7 +452,7 @@ class A:
452452
property.""")
453453

454454
assert data.classes == {
455-
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important", "property."])])
455+
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important", "property."])])
456456
}
457457

458458

@@ -482,7 +482,7 @@ class A:
482482
""")
483483

484484
assert data.classes == {
485-
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important property."])])
485+
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important property."])])
486486
}
487487

488488

@@ -509,7 +509,7 @@ class A:
509509

510510
assert data.classes == {
511511
'A': schema.Class('A', properties=[
512-
schema.SingleProperty('x', 'int', doc=["very important property.", "", "Very very important."])])
512+
schema.SingleProperty('x', 'int', description=["very important property.", "", "Very very important."])])
513513
}
514514

515515

@@ -538,7 +538,7 @@ class A:
538538

539539
assert data.classes == {
540540
'A': schema.Class('A', properties=[
541-
schema.SingleProperty('x', 'int', doc=["very important property.", " Very very important."])])
541+
schema.SingleProperty('x', 'int', description=["very important property.", " Very very important."])])
542542
}
543543

544544

0 commit comments

Comments
 (0)