diff --git a/.changelog/4735.yml b/.changelog/4735.yml new file mode 100644 index 00000000000..4b355a20cdc --- /dev/null +++ b/.changelog/4735.yml @@ -0,0 +1,6 @@ +changes: +- description: | + The command "update-release-notes" will now add Markdown formatting to the release notes + of new playbooks that follow the new playbook description template. + type: feature +pr_number: 4735 diff --git a/demisto_sdk/commands/update_release_notes/tests/update_rn_test.py b/demisto_sdk/commands/update_release_notes/tests/update_rn_test.py index d695a712146..b79b09a01b0 100644 --- a/demisto_sdk/commands/update_release_notes/tests/update_rn_test.py +++ b/demisto_sdk/commands/update_release_notes/tests/update_rn_test.py @@ -234,10 +234,6 @@ def test_build_rn_template_playbook_new_file(self, mock_master): Then: - return a markdown string """ - expected_result = ( - "\n#### Playbooks\n\n##### New: Hello World Playbook\n\n" - "- New: Hello World Playbook description\n" - ) from demisto_sdk.commands.update_release_notes.update_rn import UpdateRN mock_master.return_value = "1.0.0" @@ -249,12 +245,21 @@ def test_build_rn_template_playbook_new_file(self, mock_master): ) changed_items = { ("Hello World Playbook", FileType.PLAYBOOK): { - "description": "Hello World Playbook description", + "description": ( + "This playbook addresses the following alerts:\n" + "Playbook Stages:\nRequirements:\nTriage:\n" + "Early Containment:\nInvestigation:\nContainment:\n" + ), "is_new_file": True, }, } release_notes = update_rn.build_rn_template(changed_items) - assert expected_result == release_notes + assert release_notes == ( + "\n#### Playbooks\n\n##### New: Hello World Playbook\n\n" + "##### This playbook addresses the following alerts:\n" + "##### Playbook Stages:\n##### Requirements:\n###### Triage:\n" + "###### Early Containment:\n###### Investigation:\n###### Containment:\n\n" + ) @mock.patch.object(UpdateRN, "get_master_version") def test_build_rn_template_markdown_valid(self, mock_master, mocker): diff --git a/demisto_sdk/commands/update_release_notes/update_rn.py b/demisto_sdk/commands/update_release_notes/update_rn.py index 56e19522af1..dcafa50e30f 100644 --- a/demisto_sdk/commands/update_release_notes/update_rn.py +++ b/demisto_sdk/commands/update_release_notes/update_rn.py @@ -754,7 +754,10 @@ def build_rn_desc( if is_new_file: rn_desc = f"##### New: {content_name}\n\n" if desc: - rn_desc += f"- New: {desc}" + if _type == FileType.PLAYBOOK: + rn_desc += format_playbook_description(desc) + else: + rn_desc += f"- New: {desc}" if _type in SIEM_ONLY_ENTITIES or content_name.replace( " ", "" ).lower().endswith(EVENT_COLLECTOR.lower()): @@ -1125,3 +1128,28 @@ def get_from_version_at_update_rn(path: str) -> Optional[str]: ) return None return get_from_version(path) + + +def format_playbook_description(desc: str) -> str: + """Format a playbook description for RN. + + :param: + desc (str): The description to format. + + :rtype: ``str`` + :return: + The formatted description. + """ + desc = f"\n{desc}" + key_phrases = ( + (5, "This playbook addresses the following alerts:\n"), + (5, "Playbook Stages:\n"), + (5, "Requirements:\n"), + (6, "Triage:\n"), + (6, "Early Containment:\n"), + (6, "Investigation:\n"), + (6, "Containment:\n"), + ) + for hdr, phrase in key_phrases: + desc = desc.replace(f"\n{phrase}", f'\n{"#" * hdr} {phrase}') + return desc.lstrip("\n")