Skip to content

Commit 6060d49

Browse files
kartbenfabiobaltieri
authored andcommitted
doc: _extensions: Use github form to report documentation errors
This change makes the "Report an issue" button in the documentation actually pre-fill the bug template as opposed to just opening a "plain" issue. The required "Describe the bug" field is not pre-filled at all, making it mandatory for folks to put in effort into their report where before they would have been able to just hit "Submit" :) Fixes #93654 Signed-off-by: Benjamin Cabé <[email protected]>
1 parent f8d5577 commit 6060d49

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

doc/_extensions/zephyr/gh_utils.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@
4040
from datetime import datetime
4141
from functools import partial
4242
from pathlib import Path
43-
from textwrap import dedent
4443
from typing import Final
45-
from urllib.parse import quote
44+
from urllib.parse import urlencode
4645

4746
from sphinx.application import Sphinx
4847
from sphinx.util.i18n import format_date
@@ -117,12 +116,12 @@ def gh_link_get_url(app: Sphinx, pagename: str, mode: str = "blob") -> str | Non
117116

118117

119118
def gh_link_get_open_issue_url(app: Sphinx, pagename: str, sha1: str) -> str | None:
120-
"""Link to open a new Github issue regarding "pagename" with title, body, and
121-
labels already pre-filled with useful information.
119+
"""Link to open a new Github issue regarding "pagename" using the bug report template.
122120
123121
Args:
124122
app: Sphinx instance.
125123
pagename: Page name (path).
124+
sha1: SHA1 of the last commit to the page.
126125
127126
Returns:
128127
URL to open a new issue if applicable, None otherwise.
@@ -138,29 +137,32 @@ def gh_link_get_open_issue_url(app: Sphinx, pagename: str, sha1: str) -> str | N
138137
app.env.doc2path(pagename, False),
139138
)
140139

141-
title = quote(f"doc: Documentation issue in '{pagename}'")
142-
labels = quote("area: Documentation")
140+
form_data = {
141+
"template": "001_bug_report.yml",
142+
"title": f"doc: Documentation issue in '{pagename}'",
143+
"labels": [
144+
"bug",
145+
"area: Documentation"
146+
],
147+
"env": (
148+
f"- Page: {pagename}\n"
149+
f"- Version: {app.config.gh_link_version}\n"
150+
f"- SHA-1: {sha1}"
151+
),
152+
"context": (
153+
"This issue was reported from the online documentation page using the "
154+
"'Report an issue' button."
155+
),
156+
}
157+
143158
areas = MAINTAINERS.path2areas(rel_path)
144159
if areas:
145-
labels += "," + ",".join([label for area in areas for label in area.labels])
146-
body = quote(
147-
dedent(
148-
f"""\
149-
**Describe the bug**
150-
151-
<< Please describe the issue here >>
152-
<< You may also want to update the automatically generated issue title above. >>
153-
154-
**Environment**
155-
156-
* Page: `{pagename}`
157-
* Version: {app.config.gh_link_version}
158-
* SHA-1: {sha1}
159-
"""
160-
)
161-
)
160+
for area in areas:
161+
form_data["labels"].extend(area.labels)
162+
form_data["labels"] = ",".join(form_data.get("labels", []))
162163

163-
return f"{app.config.gh_link_base_url}/issues/new?title={title}&labels={labels}&body={body}"
164+
base_url = f"{app.config.gh_link_base_url}/issues/new"
165+
return f"{base_url}?{urlencode(form_data)}"
164166

165167

166168
def git_info_filter(app: Sphinx, pagename) -> tuple[str, str] | None:

0 commit comments

Comments
 (0)