Skip to content

Commit

Permalink
Fix links to check documentation on GitHub Markdown reports
Browse files Browse the repository at this point in the history
(issue #4844)
  • Loading branch information
felipesanches committed Dec 28, 2024
1 parent 553371d commit ccbfdce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Lib/fontbakery/reporters/ghmarkdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@ def template(self, data):
else:
key = "Family checks"

module_parts = check["module"].split(".")
if module_parts[0] == "vendorspecific":
module = module_parts[1]
elif module_parts[0] == "opentype":
module = "opentype"
else:
module = "universal"

check["id"] = check["key"][1].split(":")[1]
check["id"] = check["id"].split(">")[0]
check_id = check["id"].replace("_", "-")
check_id = check_id.replace("/", "-")
check_id = check_id.replace(".", "-")

check["doc_url"] = (
f"https://fontbakery.readthedocs.io/en/"
f"stable/fontbakery/checks/"
f"{module}.html#"
f"{check_id}"
)

if check["result"] == "FATAL":
# These will be reported at the very top.
if key not in fatal_checks:
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontbakery/reporters/templates/markdown/check.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<details>
<summary>{{check.result | emoticon}} <b>{{check.result}}</b> {{check.description}} <a href="https://fontbakery.readthedocs.io/en/stable/fontbakery/checks/{{check.module}}.html#{{check.id | replace("_", "-") | replace("/", "-") | replace(".", "-")}}">{{check.id}}</a></summary>
<summary>{{check.result | emoticon}} <b>{{check.result}}</b> {{check.description}} <a href="{{check.doc_url}}">{{check.id}}</a></summary>
<div>

{% if not succinct and check.rationale %}
Expand Down

0 comments on commit ccbfdce

Please sign in to comment.