Skip to content

Commit

Permalink
fix: provide description and meaning to parameters in markdown (#1423)
Browse files Browse the repository at this point in the history
* fix: provide description and meaning to parameters in markdown

Signed-off-by: Alejandro Jose Leiva Palomo <alejandro.leiva.palomo@ibm.com>

* fix: undo unneded removal to pass test cases

Signed-off-by: Alejandro Jose Leiva Palomo <alejandro.leiva.palomo@ibm.com>

* fix: ordering list of parameter values displayed in markdown

Signed-off-by: Alejandro Jose Leiva Palomo <alejandro.leiva.palomo@ibm.com>

---------

Signed-off-by: Alejandro Jose Leiva Palomo <alejandro.leiva.palomo@ibm.com>
  • Loading branch information
AleJo2995 committed Jul 11, 2023
1 parent 4f90258 commit 266f67b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions trestle/common/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@

VALUES = 'values'

GUIDELINES = 'guidelines'

LABEL = 'label'

SECTIONS_TAG = TRESTLE_TAG + 'sections'

EDITABLE_CONTENT = 'Editable Content'
Expand Down
2 changes: 1 addition & 1 deletion trestle/common/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def _parameter_to_dict_recurse(obj: Union[OscalBaseModel, str], partial: bool) -
Returns:
The converted parameter as dictionary
"""
main_fields = ['id', 'label', 'values', 'select', 'choice', 'how_many']
main_fields = ['id', 'label', 'values', 'select', 'choice', 'how_many', 'guidelines', 'prose']
if isinstance(obj, common.Remarks):
return obj.__root__
if isinstance(obj, common.HowMany):
Expand Down
5 changes: 4 additions & 1 deletion trestle/core/catalog/catalog_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def _construct_set_parameters_dict(
# pull only the values from the actual control dict
# all the other elements are from the profile set_param
new_dict[const.VALUES] = orig_dict.get(const.VALUES, None)
new_dict[const.GUIDELINES] = orig_dict.get(const.GUIDELINES, None)
else:
# if the profile doesnt change this param at all, show it in the header with values
tmp_dict = ModelUtils.parameter_to_dict(param_dict, True)
Expand All @@ -181,7 +182,9 @@ def _construct_set_parameters_dict(
new_dict.pop('id', None)
if display_name:
new_dict[const.DISPLAY_NAME] = display_name
set_param_dict[param_id] = new_dict
key_order = (const.LABEL, const.GUIDELINES, const.PROFILE_VALUES, const.VALUES, const.DISPLAY_NAME)
ordered_dict = {k: new_dict[k] for k in key_order if k in new_dict.keys()}
set_param_dict[param_id] = ordered_dict

return set_param_dict

Expand Down

0 comments on commit 266f67b

Please sign in to comment.