Skip to content

Commit

Permalink
Merge branch 'main' into pretty-changelog-yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
gardar authored May 23, 2024
2 parents decee7e + 2c74360 commit 731597c
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 153 deletions.
156 changes: 86 additions & 70 deletions CHANGELOG.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Ansible Changelog Tool Release Notes

.. contents:: Topics

v0.27.0
=======

Release Summary
---------------

Feature release.

Minor Changes
-------------

- Adds period where needed at end of new plugin short descriptions. Controlled by the ``add_plugin_period`` option in the config file (https://github.com/ansible-community/antsibull-changelog/issues/87, https://github.com/ansible-community/antsibull-changelog/pull/162).

v0.26.0
=======

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
[![Discuss on Matrix at #antsibull:ansible.com](https://img.shields.io/matrix/antsibull:ansible.com.svg?server_fqdn=ansible-accounts.ems.host&label=Discuss%20on%20Matrix%20at%20%23antsibull:ansible.com&logo=matrix)](https://matrix.to/#/#antsibull:ansible.com)
[![Nox badge](https://github.com/ansible-community/antsibull-changelog/workflows/nox/badge.svg?event=push&branch=main)](https://github.com/ansible-community/antsibull-changelog/actions?query=workflow%3A%22nox%22+branch%3Amain)
[![Codecov badge](https://img.shields.io/codecov/c/github/ansible-community/antsibull-changelog)](https://codecov.io/gh/ansible-community/antsibull-changelog)
[![REUSE status](https://api.reuse.software/badge/github.com/ansible-community/antsibull-changelog)](https://api.reuse.software/info/github.com/ansible-community/antsibull-changelog)

A changelog generator used by ansible-core and Ansible collections.

Expand Down
11 changes: 11 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,17 @@ releases:
- 0.26.0.yml
- 153-pymd-improvements.yaml
release_date: '2024-03-17'
0.27.0:
changes:
minor_changes:
- Adds period where needed at end of new plugin short descriptions. Controlled
by the ``add_plugin_period`` option in the config file (https://github.com/ansible-community/antsibull-changelog/issues/87,
https://github.com/ansible-community/antsibull-changelog/pull/162).
release_summary: Feature release.
fragments:
- 0.27.0.yml
- 162-add-plugin-period.yaml
release_date: '2024-05-20'
0.3.0:
changes:
minor_changes:
Expand Down
3 changes: 2 additions & 1 deletion changelogs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ title: Ansible Changelog Tool
output_formats:
- rst
- md
changelog_nice_yaml: false
add_plugin_period: false
changelog_nice_yaml: false
8 changes: 8 additions & 0 deletions docs/changelog-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ This document describes all settings that are supported in

## General options

### `add_plugin_period` (boolean)

The default value is `false` for existing configurations, and `true` for
new configurations.

If set to `false`, the plugin short description is used. If set to `true`, a period is added to the end of the plugin short description if no other end punctuation is present. Setting to `true` complies with the [Ansible changelog format](https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to-format).


### `always_refresh` (string)

Allowed values are `none`, `full`, or a comma-separated combination of
Expand Down
2 changes: 1 addition & 1 deletion src/antsibull_changelog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
Ansible Changelog Tool.
"""

__version__ = "0.26.0.post0"
__version__ = "0.27.0.post0"

__all__ = ("__version__",)
3 changes: 3 additions & 0 deletions src/antsibull_changelog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ def _do_refresh( # pylint: disable=too-many-arguments
version=changes.latest_version,
force_reload=args.reload_plugins,
use_ansible_doc=args.use_ansible_doc,
add_plugin_period=config.add_plugin_period,
)
allow_removals = refresh_plugins == "allow-removal"

Expand Down Expand Up @@ -665,6 +666,7 @@ def command_release(args: Any) -> int:
version=version,
force_reload=args.reload_plugins,
use_ansible_doc=args.use_ansible_doc,
add_plugin_period=config.add_plugin_period,
)
fragments = load_fragments(paths, config)
lint_rc = lint_fragments(config, fragments, [])
Expand Down Expand Up @@ -749,6 +751,7 @@ def command_generate(args: Any) -> int: # pylint: disable=too-many-locals
collection_details=collection_details,
version=changes.latest_version,
force_reload=args.reload_plugins,
add_plugin_period=config.add_plugin_period,
)
if output and len(config.output_formats) > 1 and not output_format:
print(
Expand Down
7 changes: 7 additions & 0 deletions src/antsibull_changelog/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class ChangelogConfig:
is_other_project: bool
sections: Mapping[str, str]
output_formats: set[TextFormat]
add_plugin_period: bool
changelog_nice_yaml: bool

def __init__(
Expand Down Expand Up @@ -466,6 +467,8 @@ def __init__(
f"Found unknown extension in output_formats: {exc}"
) from exc

self.add_plugin_period = self.config.get("add_plugin_period", False)

self.changelog_nice_yaml = self.config.get("changelog_nice_yaml", False)

self._validate_config(ignore_is_other_project)
Expand Down Expand Up @@ -517,7 +520,9 @@ def store(self) -> None: # noqa: C901
"trivial_section_name": self.trivial_section_name,
"ignore_other_fragment_extensions": self.ignore_other_fragment_extensions,
"sanitize_changelog": self.sanitize_changelog,
"add_plugin_period": self.add_plugin_period,
"changelog_nice_yaml": self.changelog_nice_yaml,

}
if not self.is_collection:
if self.use_semantic_versioning:
Expand Down Expand Up @@ -596,7 +601,9 @@ def default(
"use_fqcn": True,
"ignore_other_fragment_extensions": True,
"sanitize_changelog": True,
"add_plugin_period": True,
"changelog_nice_yaml": False,

}
if title is not None:
config["title"] = title
Expand Down
27 changes: 22 additions & 5 deletions src/antsibull_changelog/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def __init__(

@staticmethod
def from_dict(
data: dict[str, dict[str, dict[str, Any]]], category: str = "plugin"
data: dict[str, dict[str, dict[str, Any]]],
category: str = "plugin",
add_plugin_period: bool = False,
) -> list[PluginDescription]:
"""
Return a list of ``PluginDescription`` objects from the given data.
Expand All @@ -79,12 +81,19 @@ def from_dict(

for plugin_type, plugin_data in data.items():
for plugin_name, plugin_details in plugin_data.items():
description = plugin_details["description"]
if (
add_plugin_period
and description
and not description.endswith((".", ",", "!", "?"))
):
description += "."
plugins.append(
PluginDescription(
plugin_type=plugin_type,
name=plugin_name,
namespace=plugin_details.get("namespace"),
description=plugin_details["description"],
description=description,
version_added=plugin_details["version_added"],
category=category,
)
Expand Down Expand Up @@ -543,12 +552,13 @@ def _refresh_plugin_cache(
return plugins_data


def load_plugins(
def load_plugins( # pylint: disable=too-many-arguments
paths: PathsConfig,
collection_details: CollectionDetails,
version: str,
force_reload: bool = False,
use_ansible_doc: bool = False,
add_plugin_period: bool = False,
) -> list[PluginDescription]:
"""
Load plugins from ansible-doc.
Expand Down Expand Up @@ -582,10 +592,17 @@ def load_plugins(
)
store_yaml(plugin_cache_path, plugins_data)

plugins = PluginDescription.from_dict(plugins_data["plugins"])
plugins = PluginDescription.from_dict(
plugins_data["plugins"],
add_plugin_period=add_plugin_period,
)
if "objects" in plugins_data:
plugins.extend(
PluginDescription.from_dict(plugins_data["objects"], category="object")
PluginDescription.from_dict(
plugins_data["objects"],
category="object",
add_plugin_period=add_plugin_period,
)
)

return plugins
36 changes: 19 additions & 17 deletions tests/functional/test_changelog_basic_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
notesdir: fragments
prelude_section_name: release_summary
new_plugins_after_name: removed_features
add_plugin_period: true
sections:
- ['major_changes', 'Major Changes']
- ['minor_changes', 'Minor Changes']
Expand Down Expand Up @@ -264,15 +265,15 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
assert changelog["releases"]["2.10"]["modules"] == [
{
"name": "test",
"description": "This is a test module",
"description": "This is a test module.",
"namespace": "",
},
]
assert changelog["releases"]["2.10"]["plugins"] == {
"lookup": [
{
"name": "bar",
"description": "A foo bar lookup",
"description": "A foo bar lookup.",
"namespace": None,
},
],
Expand Down Expand Up @@ -308,12 +309,12 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
Lookup
~~~~~~
- bar - A foo bar lookup
- bar - A foo bar lookup.
New Modules
-----------
- test - This is a test module
- test - This is a test module.
"""
)

Expand Down Expand Up @@ -399,15 +400,15 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
assert changelog["releases"]["2.10"]["modules"] == [
{
"name": "test",
"description": "This is a TEST module",
"description": "This is a TEST module.",
"namespace": "",
},
]
assert changelog["releases"]["2.10"]["plugins"] == {
"lookup": [
{
"name": "bar",
"description": "A foo_bar lookup",
"description": "A foo_bar lookup.",
"namespace": None,
},
],
Expand Down Expand Up @@ -441,12 +442,12 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
Lookup
~~~~~~
- bar - A foo_bar lookup
- bar - A foo_bar lookup.
New Modules
-----------
- test - This is a TEST module
- test - This is a TEST module.
"""
)

Expand Down Expand Up @@ -539,7 +540,7 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
assert changelog["releases"]["2.10.1b1"]["modules"] == [
{
"name": "test_new",
"description": "This is ANOTHER test module",
"description": "This is ANOTHER test module.",
"namespace": "",
},
]
Expand Down Expand Up @@ -569,7 +570,7 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
New Modules
-----------
- test_new - This is ANOTHER test module
- test_new - This is ANOTHER test module.
v2.10
=====
Expand All @@ -592,12 +593,12 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
Lookup
~~~~~~
- bar - A foo_bar lookup
- bar - A foo_bar lookup.
New Modules
-----------
- test - This is a TEST module
- test - This is a TEST module.
"""
)

Expand Down Expand Up @@ -706,7 +707,7 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
assert changelog["releases"]["2.10.1"]["modules"] == [
{
"name": "test_new2",
"description": "This is ANOTHER test module!!!11",
"description": "This is ANOTHER test module!!!11.",
"namespace": "",
},
{
Expand Down Expand Up @@ -747,8 +748,8 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
New Modules
-----------
- test_new - This is ANOTHER test module
- test_new2 - This is ANOTHER test module!!!11
- test_new - This is ANOTHER test module.
- test_new2 - This is ANOTHER test module!!!11.
- test_new3 - This is yet another test module.
v2.10
Expand All @@ -772,12 +773,12 @@ def test_changelog_release_ansible_simple( # pylint: disable=redefined-outer-na
Lookup
~~~~~~
- bar - A foo_bar lookup
- bar - A foo_bar lookup.
New Modules
-----------
- test - This is a TEST module
- test - This is a TEST module.
"""
)

Expand Down Expand Up @@ -899,6 +900,7 @@ def test_changelog_release_ansible_plugin_cache( # pylint: disable=redefined-ou
notesdir: fragments
prelude_section_name: release_summary
new_plugins_after_name: removed_features
add_plugin_period: false
sections:
- ['major_changes', 'Major Changes']
- ['minor_changes', 'Minor Changes']
Expand Down
Loading

0 comments on commit 731597c

Please sign in to comment.