Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC spec generator no longer generates unused SDLRPCParameterNames #1917

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions generator/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def test_process_function_name(self):
structs = {
'SoftButton': Struct(name='SoftButton', members={
'image': Param(name='image', param_type=String(), since='1.0.0', description=['image description']),
'ignore': Param(name='ignore', param_type=Struct(name='ignore'))}),
'dayColorScheme': Param(name='dayColorScheme', param_type=Struct(name='TemplateColorScheme', description=[
'\nA color scheme for all display layout templates.\n']))}),
'PresetBankCapabilities': Struct(name='PresetBankCapabilities', members={
'availableHdChannelsAvailable': Param(name='availableHdChannelsAvailable', param_type=Boolean(),
since='2.0.0',
Expand All @@ -89,11 +90,8 @@ def test_process_function_name(self):
self.producer.common_names(description=['availableHDChannelsAvailable description'],
since='2.0.0', name='AvailableHdChannelsAvailable',
origin='availableHdChannelsAvailable'),
self.producer.common_names(description=[], name='Ignore', origin='ignore', since=None),
self.producer.common_names(description=[], name='DayColorScheme', origin='dayColorScheme', since=None),
self.producer.common_names(description=['image description'], name='Image', origin='image', since='1.0.0'),
self.producer.common_names(description=[], name='PresetBankCapabilities', origin='PresetBankCapabilities',
since=None),
self.producer.common_names(description=[], name='SoftButton', origin='SoftButton', since=None),
self.producer.common_names(description=['syncMsgVersion description'], name='SdlMsgVersion',
origin='syncMsgVersion', since='3.5.0')]
actual = self.producer.get_simple_params(functions, structs)
Expand Down
6 changes: 2 additions & 4 deletions generator/transformers/functions_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,15 @@ def evaluate(self, element) -> dict:
"""
origin = element.name
name = self._replace_sync(element.name)
# if isinstance(element.param_type, (Integer, Float, Boolean, String)):
return {name: self.common_names(**{
'name': self.title(name),
'origin': origin,
'description': self.extract_description(element.description),
'since': element.since})}
# return OrderedDict()

def get_simple_params(self, functions: dict, structs: dict) -> dict:
"""
Standalone method used for preparing SDLRPCParameterNames collection ready to be applied to Jinja2 template
Creates a list of all parameter names used in functions and structs. This list is used by a Jinja2 template to generate the SDLRPCParameterNames class.
:param functions: collection with all functions from initial Model
:param structs: collection with all structs from initial Model
:return: collection with transformed element ready to be applied to Jinja2 template
Expand All @@ -110,8 +108,8 @@ def get_simple_params(self, functions: dict, structs: dict) -> dict:
render.update(self.evaluate(param))

for struct in structs.values():
render.update(self.evaluate(struct))
for param in struct.members.values():
render.update(self.evaluate(param))

unique = dict(zip(list(map(lambda l: l.name, render.values())), render.values()))
return {'params': sorted(unique.values(), key=lambda a: a.name)}