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

Use collection's issue tracker URL instead of collection URL when suggesting to file a bug with the collection #29

Merged
merged 4 commits into from
Aug 24, 2022
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
2 changes: 2 additions & 0 deletions changelogs/fragments/29-issue-tracker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "When generating plugin error pages, or showing non-fatal errors in plugins or roles, link to the collection's issue tracker instead of the collection's URL if available (https://github.com/ansible-community/antsibull-docs/pull/29)."
10 changes: 10 additions & 0 deletions src/antsibull_docs/collection_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def extract(key: str, desc: str,
return result


def _extract_issue_tracker(data: t.Dict) -> t.Optional[str]:
url = data.get('issues')
return url if url and isinstance(url, str) else None


def load(links_data: t.Optional[t.Dict], galaxy_data: t.Optional[t.Dict],
manifest_data: t.Optional[t.Dict]) -> CollectionLinks:
if links_data:
Expand All @@ -114,16 +119,21 @@ def load(links_data: t.Optional[t.Dict], galaxy_data: t.Optional[t.Dict],
result = CollectionLinks.parse_obj({})

# Parse MANIFEST or galaxy data
issue_tracker = None
if isinstance(manifest_data, dict):
collection_info = manifest_data.get('collection_info')
if isinstance(collection_info, dict):
result.authors = _extract_authors(collection_info)
result.description = _extract_description(collection_info)
result.links.extend(_extract_galaxy_links(collection_info))
issue_tracker = _extract_issue_tracker(collection_info)
elif isinstance(galaxy_data, dict):
result.authors = _extract_authors(galaxy_data)
result.description = _extract_description(galaxy_data)
result.links.extend(_extract_galaxy_links(galaxy_data))
issue_tracker = _extract_issue_tracker(galaxy_data)
if issue_tracker and not result.issue_tracker:
result.issue_tracker = issue_tracker

result.links.extend(result.extra_links)

Expand Down
4 changes: 2 additions & 2 deletions src/antsibull_docs/data/docsite/plugin-error.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ The errors were:
{% for error in nonfatal_errors %}
* ::

@{ error | indent(width=8, first=True) }@
@{ error | indent(width=8, first=True) }@

{% endfor %}

File a bug with the `@{ collection }@ collection <@{ collection | collection_url }@>`_ in order to have it corrected.
File a bug with the `@{ collection }@ collection <@{ collection_issue_tracker or (collection | collection_url) }@>`_ in order to have it corrected.
8 changes: 4 additions & 4 deletions src/antsibull_docs/data/docsite/plugin.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ Collection links
.. Parsing errors

{% if nonfatal_errors %}
There were some errors parsing the documentation for this plugin. Please file a bug with the collection.
There were some errors parsing the documentation for this plugin. Please file a bug with the `@{ collection }@ collection <@{ collection_issue_tracker or (collection | collection_url) }@>`_.

The errors were:

{% for error in nonfatal_errors %}
{% for error in nonfatal_errors %}
* ::

@{ error | indent(width=8, first=True) }@
@{ error | indent(width=8, first=True) }@

{% endfor %}
{% endfor %}
{% endif %}
2 changes: 1 addition & 1 deletion src/antsibull_docs/data/docsite/role.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Collection links
.. Parsing errors

{% if nonfatal_errors %}
There were some errors parsing the documentation for this role. Please file a bug with the collection.
There were some errors parsing the documentation for this role. Please file a bug with the `@{ collection }@ collection <@{ collection_issue_tracker or (collection | collection_url) }@>`_.

The errors were:

Expand Down
1 change: 1 addition & 0 deletions src/antsibull_docs/schemas/collection_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class CollectionLinks(p.BaseModel):
edit_on_github: t.Optional[CollectionEditOnGitHub] = None
authors: t.List[str] = []
description: t.Optional[str]
issue_tracker: t.Optional[str] = None
links: t.List[Link] = []
extra_links: t.List[Link] = []
communication: Communication = Communication()
3 changes: 3 additions & 0 deletions src/antsibull_docs/write_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def create_plugin_rst(collection_name: str,
edit_on_github_url=edit_on_github_url,
collection_links=collection_links.links,
collection_communication=collection_links.communication,
collection_issue_tracker=collection_links.issue_tracker,
for_official_docsite=for_official_docsite,
)
else:
Expand All @@ -190,6 +191,7 @@ def create_plugin_rst(collection_name: str,
edit_on_github_url=edit_on_github_url,
collection_links=collection_links.links,
collection_communication=collection_links.communication,
collection_issue_tracker=collection_links.issue_tracker,
for_official_docsite=for_official_docsite,
)
else:
Expand All @@ -208,6 +210,7 @@ def create_plugin_rst(collection_name: str,
edit_on_github_url=edit_on_github_url,
collection_links=collection_links.links,
collection_communication=collection_links.communication,
collection_issue_tracker=collection_links.issue_tracker,
for_official_docsite=for_official_docsite,
)

Expand Down