Skip to content

Commit a91a315

Browse files
garnaatElad Ben-Israel
authored andcommitted
fix(python): parameter names in docstrings should be snake_case, not camelCase (#539)
1 parent 8c826c1 commit a91a315

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

packages/jsii-pacmak/lib/targets/python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ function emitDocString(code: CodeMaker, docs: spec.Docs | undefined, options: {
17701770
for (const param of options.arguments) {
17711771
// Add a line for every argument. Even if there is no description, we need
17721772
// the docstring so that the Sphinx extension can add the type annotations.
1773-
lines.push(` ${param.name}: ${onelineDescription(param.docs)}`);
1773+
lines.push(` ${toPythonParameterName(param.name)}: ${onelineDescription(param.docs)}`);
17741774
}
17751775
brk();
17761776
}

packages/jsii-pacmak/test/expected.jsii-calc/python/src/jsii_calc/__init__.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def get_foo(self, with_param: str) -> str:
414414
"""getXxx() is not allowed (see negatives), but getXxx(a, ...) is okay.
415415
416416
Arguments:
417-
withParam: -
417+
with_param: -
418418
419419
Stability:
420420
experimental
@@ -869,8 +869,8 @@ class DeprecatedClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.DeprecatedCl
869869
def __init__(self, readonly_string: str, mutable_number: typing.Optional[jsii.Number]=None) -> None:
870870
"""
871871
Arguments:
872-
readonlyString: -
873-
mutableNumber: -
872+
readonly_string: -
873+
mutable_number: -
874874
875875
Deprecated:
876876
this constructor is "just" okay
@@ -1054,7 +1054,7 @@ def __init__(self) -> None:
10541054
def change_private_property_value(self, new_value: str) -> None:
10551055
"""
10561056
Arguments:
1057-
newValue: -
1057+
new_value: -
10581058
10591059
Stability:
10601060
experimental
@@ -1091,9 +1091,9 @@ def __init__(self) -> None:
10911091
def method(self, _required_any: typing.Any, _optional_any: typing.Any=None, _optional_string: typing.Optional[str]=None) -> None:
10921092
"""
10931093
Arguments:
1094-
_requiredAny: -
1095-
_optionalAny: -
1096-
_optionalString: -
1094+
_required_any: -
1095+
_optional_any: -
1096+
_optional_string: -
10971097
10981098
Stability:
10991099
experimental
@@ -1242,8 +1242,8 @@ class ExperimentalClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Experiment
12421242
def __init__(self, readonly_string: str, mutable_number: typing.Optional[jsii.Number]=None) -> None:
12431243
"""
12441244
Arguments:
1245-
readonlyString: -
1246-
mutableNumber: -
1245+
readonly_string: -
1246+
mutable_number: -
12471247
12481248
Stability:
12491249
experimental
@@ -1367,15 +1367,15 @@ def derived_to_first(self, *, another_required: datetime.datetime, bool: bool, n
13671367
13681368
Arguments:
13691369
derived: -
1370-
anotherRequired:
1370+
another_required:
13711371
bool:
1372-
nonPrimitive: An example of a non primitive property.
1373-
anotherOptional: This is optional.
1374-
optionalAny:
1375-
optionalArray:
1372+
non_primitive: An example of a non primitive property.
1373+
another_optional: This is optional.
1374+
optional_any:
1375+
optional_array:
13761376
anumber: An awesome number value.
13771377
astring: A string value.
1378-
firstOptional:
1378+
first_optional:
13791379
13801380
Stability:
13811381
experimental
@@ -1402,15 +1402,15 @@ def read_derived_non_primitive(self, *, another_required: datetime.datetime, boo
14021402
14031403
Arguments:
14041404
derived: -
1405-
anotherRequired:
1405+
another_required:
14061406
bool:
1407-
nonPrimitive: An example of a non primitive property.
1408-
anotherOptional: This is optional.
1409-
optionalAny:
1410-
optionalArray:
1407+
non_primitive: An example of a non primitive property.
1408+
another_optional: This is optional.
1409+
optional_any:
1410+
optional_array:
14111411
anumber: An awesome number value.
14121412
astring: A string value.
1413-
firstOptional:
1413+
first_optional:
14141414
14151415
Stability:
14161416
experimental
@@ -1439,7 +1439,7 @@ def read_first_number(self, *, anumber: jsii.Number, astring: str, first_optiona
14391439
first: -
14401440
anumber: An awesome number value.
14411441
astring: A string value.
1442-
firstOptional:
1442+
first_optional:
14431443
14441444
Stability:
14451445
experimental
@@ -2140,8 +2140,8 @@ class ClassWithPrivateConstructorAndAutomaticProperties(metaclass=jsii.JSIIMeta,
21402140
def create(cls, read_only_string: str, read_write_string: str) -> "ClassWithPrivateConstructorAndAutomaticProperties":
21412141
"""
21422142
Arguments:
2143-
readOnlyString: -
2144-
readWriteString: -
2143+
read_only_string: -
2144+
read_write_string: -
21452145
21462146
Stability:
21472147
experimental
@@ -3936,8 +3936,8 @@ def give_me_undefined_inside_an_object(self, *, array_with_three_elements_and_un
39363936
"""
39373937
Arguments:
39383938
input: -
3939-
arrayWithThreeElementsAndUndefinedAsSecondArgument:
3940-
thisShouldBeUndefined:
3939+
array_with_three_elements_and_undefined_as_second_argument:
3940+
this_should_be_undefined:
39413941
39423942
Stability:
39433943
experimental
@@ -4161,7 +4161,7 @@ class OptionalStructConsumer(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.Optio
41614161
def __init__(self, *, field: typing.Optional[str]=None) -> None:
41624162
"""
41634163
Arguments:
4164-
optionalStruct: -
4164+
optional_struct: -
41654165
field:
41664166
41674167
Stability:
@@ -4794,8 +4794,8 @@ class StableClass(metaclass=jsii.JSIIMeta, jsii_type="jsii-calc.StableClass"):
47944794
def __init__(self, readonly_string: str, mutable_number: typing.Optional[jsii.Number]=None) -> None:
47954795
"""
47964796
Arguments:
4797-
readonlyString: -
4798-
mutableNumber: -
4797+
readonly_string: -
4798+
mutable_number: -
47994799
48004800
Stability:
48014801
stable
@@ -5603,7 +5603,7 @@ class WithPrivatePropertyInConstructor(metaclass=jsii.JSIIMeta, jsii_type="jsii-
56035603
def __init__(self, private_field: typing.Optional[str]=None) -> None:
56045604
"""
56055605
Arguments:
5606-
privateField: -
5606+
private_field: -
56075607
56085608
Stability:
56095609
experimental
@@ -5751,8 +5751,8 @@ def __init__(self, *, initial_value: typing.Optional[jsii.Number]=None, maximum_
57515751
57525752
Arguments:
57535753
props: Initialization properties.
5754-
initialValue:
5755-
maximumValue:
5754+
initial_value:
5755+
maximum_value:
57565756
57575757
Stability:
57585758
experimental

0 commit comments

Comments
 (0)