Skip to content

Commit

Permalink
Support discussion/reason/reason_text override.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Nov 8, 2024
1 parent 46a0a05 commit 45c4172
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions src/antsibull_docs/cli/doc_commands/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ def _compose_redirect_sentence(
def _collect_removal_sentences(
collection: str,
removal: RemovalInformation,
/,
ansible_version: PypiVer | None,
discussion_override: str | None = None,
reason_override: str | None = None,
reason_text_override: str | None = None,
) -> list[str]:
sentences = []
removed_text = (
Expand All @@ -225,15 +229,19 @@ def _collect_removal_sentences(
else f"will be removed from Ansible {removal.major_version}"
)

if removal.reason == "deprecated":
discussion = discussion_override or removal.discussion
reason = reason_override or removal.reason
reason_text = reason_text_override or removal.reason_text

if reason == "deprecated":
sentences.append(
f"The {collection} collection has been deprecated and {removed_text}."
)
if removal.reason == "considered-unmaintained":
if reason == "considered-unmaintained":
sentences.append(
f"The {collection} collection is considered unmaintained and {removed_text}."
)
if removal.reason == "renamed":
if reason == "renamed":
sentences.append(
f"The {collection} collection has been renamed to"
f" R({removal.new_name}, plugins_in_{removal.new_name})"
Expand All @@ -256,20 +264,20 @@ def _collect_removal_sentences(
"When creating new playbooks or roles,"
f" directly use content from {removal.new_name} instead."
)
if removal.reason == "guidelines-violation":
if reason == "guidelines-violation":
sentences.append(
f"The {collection} collection {removed_text}"
" due to violations of the Ansible inclusion requirements."
)
if removal.reason == "other":
if reason == "other":
sentences.append(f"The {collection} collection {removed_text}.")

if removal.reason_text:
sentences.append(removal.reason_text)
if reason_text:
sentences.append(reason_text)

if sentences and removal.discussion:
if sentences and discussion:
sentences.append(
f"See the L(discussion thread, {removal.discussion}) for more information."
f"See the L(discussion thread, {discussion}) for more information."
)

return sentences
Expand All @@ -284,7 +292,25 @@ def _compose_deprecation_info(
if removal is None or not removal.is_deprecated():
return None

sentences = _collect_removal_sentences(collection, removal, ansible_version)
discussion_override = None
reason_override = None
reason_text_override = None
if removal.updates and (
removal.updates[-1].deprecated_version
or removal.updates[-1].redeprecated_version
):
discussion_override = removal.updates[-1].discussion
reason_override = removal.updates[-1].reason
reason_text_override = removal.updates[-1].reason_text

sentences = _collect_removal_sentences(
collection,
removal,
ansible_version=ansible_version,
discussion_override=discussion_override,
reason_override=reason_override,
reason_text_override=reason_text_override,
)
if not sentences:
return None

Expand Down

0 comments on commit 45c4172

Please sign in to comment.