File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
templates/python/package/services Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,17 @@ public function __construct(Language $language, Spec $spec)
210
210
$ this ->twig ->addFilter (new TwigFilter ('capitalizeFirst ' , function ($ value ) {
211
211
return ucfirst ($ value );
212
212
}));
213
+ $ this ->twig ->addFilter (new TwigFilter ('caseSnakeExceptFirstDot ' , function ($ value ) {
214
+ $ parts = explode ('. ' , $ value , 2 );
215
+ $ toSnake = function ($ str ) {
216
+ preg_match_all ('!([A-Za-z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)! ' , $ str , $ matches );
217
+ return implode ('_ ' , array_map (function ($ m ) {
218
+ return $ m === strtoupper ($ m ) ? strtolower ($ m ) : lcfirst ($ m );
219
+ }, $ matches [0 ]));
220
+ };
221
+ if (count ($ parts ) < 2 ) return $ toSnake ($ value );
222
+ return $ parts [0 ] . '. ' . $ toSnake ($ parts [1 ]);
223
+ }));
213
224
}
214
225
215
226
/**
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ class {{ service.name | caseUcfirst }}(Service):
34
34
35
35
{% if method .parameters .all | length > 0 or ' multipart/form-data' in method .consumes %}
36
36
37
+ {% if method .deprecated %}
38
+ .. deprecated::
39
+ This API is deprecated and uses outdated terminologies.{% if method .replaceWith %} Please use `{{ method .replaceWith | caseSnakeExceptFirstDot }}` instead.{% endif %}
40
+ {% endif %}
41
+
37
42
Parameters
38
43
----------
39
44
{% for parameter in method .parameters .all %}{{ parameter .name | escapeKeyword | caseSnake }} : {{ parameter | getPropertyType(method ) | raw }}
You can’t perform that action at this time.
0 commit comments