Skip to content

Commit 0c80108

Browse files
author
Robert Henigan
authored
Merge pull request #1453 from smartdevicelink/feature/issue_1448_generate_deprecated_javadoc
Generate @deprecated annotation in JavaDocs when applicable
2 parents 6e93579 + ca572ff commit 0c80108

10 files changed

Lines changed: 57 additions & 48 deletions

generator/templates/base_template.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,21 @@
6363
* <td>{%- for d in param.description %}{{d}}{%- endfor %}</td>
6464
* <td>{%- if param.mandatory is eq true %}Y{%- else %}N{%- endif %}</td>
6565
* <td>{%- for k in param.values %}{{ '{' if loop.first}}"{{k}}": {{param.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}</td>
66-
* <td>{%- if param.since is defined %}SmartDeviceLink {{param.since}}{%- endif %}</td>
66+
{%- if param.since is defined and param.since is not none %}{% set see, deprecated, since, history, spacing = param.see, param.deprecated, param.since, param.history, ' * ' %}
67+
* <td>
68+
{%- include "javadoc_version_info.java" %}
69+
* </td>
70+
{%- else %}
71+
* <td></td>
72+
{%- endif %}
6773
* </tr>
6874
{%- endfor %}
6975
* </table>
7076
{%- endif %}
7177
{%- if description is defined and (see is defined or since is defined) %}
7278
*
73-
{%- endif %}
74-
{%- if deprecated is not none %}
75-
* @deprecated
76-
{%- endif %}
77-
{%- if see is defined %}
78-
* @see {{see}}
79-
{%- endif %}
80-
{%- if since is defined %}
81-
* @since SmartDeviceLink {{since}}
82-
{%- endif %}
79+
{%- endif %}{% set prefix = ' * ' %}
80+
{%- include "javadoc_version_info.java" %}
8381
*/
8482
{%- endif %}
8583
{%- if deprecated is not none %}

generator/templates/enum_template.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ public enum {{class_name}} {
1010
{%- endfor %}{% endif -%}
1111
{%- if param.description is defined and (param.since is defined or param.see is defined) %}
1212
*
13-
{%- endif %}
14-
{%- if param.since is defined %}
15-
* @since SmartDeviceLink {{param.since}}
16-
{%- endif %}
17-
{%- if param.see is defined %}
18-
* @see {{param.see}}
19-
{%- endif %}
13+
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = param.see, param.deprecated, param.since, param.history, ' ', ' * ' %}
14+
{%- include "javadoc_version_info.java" %}
2015
*/
2116
{%- endif %}
2217
{%- if param.deprecated is defined %}

generator/templates/function_template.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,8 @@
33
{%- block params %}
44
{%- if params is defined %}
55
{%- for p in params %}
6-
{%- if p.origin not in ('success', 'resultCode', 'info') or kind != "response" %}
7-
{%- if p.see is defined or p.deprecated is not none %}
8-
/**
9-
{%- if p.deprecated is not none %}
10-
* @deprecated
11-
{%- endif %}
12-
{%- if p.see is defined %}
13-
* @see {{p.see}}
14-
{%- endif %}
15-
*/
16-
{%- endif %}
6+
{%- if p.origin not in ('success', 'resultCode', 'info') or kind != "response" %}{% set see, deprecated, since, history, spacing, begin, end, prefix = p.see, p.deprecated, p.since, p.history, ' ', '/**', ' */', ' * ' %}
7+
{%- include "javadoc_version_info.java" %}
178
{%- if p.deprecated is not none %}
189
@Deprecated
1910
{%- endif %}
@@ -37,6 +28,9 @@
3728
*
3829
{%- include "javadoc_template.java" %}
3930
*/
31+
{%- if p.deprecated is defined and p.deprecated is not none %}
32+
@Deprecated
33+
{%- endif %}
4034
public void set{{p.title}}({% if p.mandatory %}@NonNull {% endif %}{{p.return_type}} {{p.last}}) {
4135
setParameters({{p.key}}, {{p.last}});
4236
}
@@ -49,6 +43,9 @@
4943
{%- if p.SuppressWarnings is defined %}
5044
@SuppressWarnings("{{p.SuppressWarnings}}")
5145
{%- endif %}
46+
{%- if p.deprecated is defined and p.deprecated is not none %}
47+
@Deprecated
48+
{%- endif %}
5249
public {{p.return_type}} get{{p.title}}() {
5350
{%- if p.return_type in ['String', 'Boolean', 'Integer'] %}
5451
return get{{p.return_type}}({{p.key}});

generator/templates/javadoc_return.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
{%- endif %}
1111
{%- if p.values is defined and p.values %}
1212
* {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}
13-
{%- endif %}
14-
{%- if p.since is defined %}
15-
* @since SmartDeviceLink {{p.since}}
16-
{%- endif %}
13+
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = p.see, p.deprecated, p.since, p.history, ' ', ' * ' %}
14+
{%- include "javadoc_version_info.java" %}

generator/templates/javadoc_template.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
{%- endif %}
1111
{%- if p.values is defined and p.values %}
1212
* {%- for k in p.values %}{{ ' {' if loop.first}}"{{k}}": {{p.values[k]}}{{ ', ' if not loop.last else '}'}}{%- endfor %}
13-
{%- endif %}
14-
{%- if p.since is defined %}
15-
* @since SmartDeviceLink {{p.since}}
16-
{%- endif %}
13+
{%- endif %}{% set see, deprecated, since, history, spacing, prefix = p.see, p.deprecated, p.since, p.history, ' ', ' * ' %}
14+
{%- include "javadoc_version_info.java" %}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{%- if since is defined and since is not none %}
2+
{%- if begin is defined %}
3+
{{spacing}}{{begin}}
4+
{%- endif %}
5+
{%- if deprecated is defined and deprecated is not none %}
6+
{{spacing}}{{prefix}}@since SmartDeviceLink {{history[0].since}}
7+
{{spacing}}{{prefix}}@deprecated in SmartDeviceLink {{since}}
8+
{%- elif history is defined and history is not none %}
9+
{{spacing}}{{prefix}}@since SmartDeviceLink {{history[0].since}}
10+
{%- else %}
11+
{{spacing}}{{prefix}}@since SmartDeviceLink {{since}}
12+
{%- endif %}
13+
{%- if see is defined %}
14+
{{spacing}}{{prefix}}@see {{see}}
15+
{%- endif %}
16+
{%- if end is defined %}
17+
{{spacing}}{{end}}
18+
{%- endif %}
19+
{%- endif %}

generator/templates/struct_template.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,8 @@
22

33
{%- block params %}
44
{%- if params is defined %}
5-
{%- for p in params %}
6-
{%- if p.see is defined or p.deprecated is not none %}
7-
/**
8-
{%- if p.deprecated is not none %}
9-
* @deprecated
10-
{%- endif %}
11-
{%- if p.see is defined %}
12-
* @see {{p.see}}
13-
{%- endif %}
14-
*/
15-
{%- endif %}
5+
{%- for p in params %}{% set see, deprecated, since, history, spacing, begin, end, prefix = p.see, p.deprecated, p.since, p.history, ' ', '/**', ' */', ' * ' %}
6+
{%- include "javadoc_version_info.java" %}
167
{%- if p.deprecated is not none %}
178
@Deprecated
189
{%- endif %}
@@ -33,6 +24,9 @@
3324
*
3425
{%- include "javadoc_template.java" %}
3526
*/
27+
{%- if p.deprecated is defined and p.deprecated is not none %}
28+
@Deprecated
29+
{%- endif %}
3630
public void set{{p.title}}({% if p.mandatory %}@NonNull {% endif %}{{p.return_type}} {{p.last}}) {
3731
setValue({{p.key}}, {{p.last}});
3832
}
@@ -45,6 +39,9 @@
4539
{%- if p.SuppressWarnings is defined %}
4640
@SuppressWarnings("{{p.SuppressWarnings}}")
4741
{%- endif %}
42+
{%- if p.deprecated is defined and p.deprecated is not none %}
43+
@Deprecated
44+
{%- endif %}
4845
public {{p.return_type}} get{{p.title}}() {
4946
{%- if p.return_type in ['String', 'Boolean', 'Integer'] %}
5047
return get{{p.return_type}}({{p.key}});

generator/transformers/enums_producer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def transform(self, item: Enum) -> dict:
5959
render['params'] = params
6060
render['since'] = item.since
6161
render['deprecated'] = item.deprecated
62+
render['history'] = item.history
6263

6364
description = self.extract_description(item.description)
6465
if description:
@@ -81,6 +82,8 @@ def extract_param(self, param: EnumElement, kind):
8182
d['since'] = param.since
8283
if getattr(param, 'deprecated', None):
8384
d['deprecated'] = param.deprecated
85+
if getattr(param, 'history', None):
86+
d['history'] = param.history
8487
if getattr(param, 'description', None):
8588
d['description'] = textwrap.wrap(self.extract_description(param.description), 90)
8689
Params = namedtuple('Params', sorted(d))

generator/transformers/functions_producer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def transform(self, item: Function) -> dict:
7373
render['extends_class'] = extends_class
7474
render['since'] = item.since
7575
render['deprecated'] = item.deprecated
76+
render['history'] = item.history
7677

7778
description = self.extract_description(item.description)
7879
if description:
@@ -118,6 +119,7 @@ def extract_param(self, param: Param):
118119
if param.since:
119120
p['since'] = param.since
120121
p['deprecated'] = param.deprecated
122+
p['history'] = param.history
121123
p['origin'] = param.origin
122124
p['values'] = self.extract_values(param)
123125
d = self.extract_description(param.description)

generator/transformers/structs_producer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def transform(self, item: Struct) -> dict:
5858
render['imports'] = imports
5959
render['deprecated'] = item.deprecated
6060
render['since'] = item.since
61+
render['history'] = item.history
6162

6263
description = self.extract_description(item.description)
6364
if description:
@@ -104,6 +105,7 @@ def extract_param(self, param: Param):
104105
if param.since:
105106
p['since'] = param.since
106107
p['deprecated'] = param.deprecated
108+
p['history'] = param.history
107109
p['origin'] = param.origin
108110
p['values'] = self.extract_values(param)
109111
d = self.extract_description(param.description)

0 commit comments

Comments
 (0)