Template
mirror of
https://github.com/MorpheApp/morphe-patches-template.git
synced 2026-12-01 00:19:34 +00:00
chore: Include package name in readme generator
This commit is contained in:
1 parent
ab428a05c5
commit
0392b51264
1 file changed
+6
-4
@@ -60,7 +60,7 @@ def pkg_label(name, form_factor):
|
|||||||
# The same package name can be used by different apps for each form factor.
|
# The same package name can be used by different apps for each form factor.
|
||||||
# JSON structure: compatiblePackages is a list of objects with
|
# JSON structure: compatiblePackages is a list of objects with
|
||||||
# { packageName, name, formFactor, targets: [{ version, isExperimental, description }] }
|
# { packageName, name, formFactor, targets: [{ version, isExperimental, description }] }
|
||||||
by_pkg = {} # (packageName, formFactor) -> { name, emoji, patches, targets }
|
by_pkg = {} # (packageName, formFactor) -> { name, package, emoji, patches, targets }
|
||||||
universal = {}
|
universal = {}
|
||||||
|
|
||||||
for patch in data["patches"]:
|
for patch in data["patches"]:
|
||||||
@@ -78,6 +78,7 @@ for patch in data["patches"]:
|
|||||||
if key not in by_pkg:
|
if key not in by_pkg:
|
||||||
by_pkg[key] = {
|
by_pkg[key] = {
|
||||||
"name": pkg_label(name, form_factor),
|
"name": pkg_label(name, form_factor),
|
||||||
|
"package": pkg,
|
||||||
"emoji": pkg_emoji(form_factor),
|
"emoji": pkg_emoji(form_factor),
|
||||||
"patches": {},
|
"patches": {},
|
||||||
"targets": pkg_entry.get("targets", []),
|
"targets": pkg_entry.get("targets", []),
|
||||||
@@ -143,19 +144,20 @@ def versions_table(targets):
|
|||||||
return "\n".join(rows)
|
return "\n".join(rows)
|
||||||
|
|
||||||
|
|
||||||
def spoiler(label, count, targets, tbl, expanded=False):
|
def spoiler(label, package, count, targets, tbl, expanded=False):
|
||||||
"""Wrap a patches table in a <details> spoiler with a versions sub-table.
|
"""Wrap a patches table in a <details> spoiler with a versions sub-table.
|
||||||
If expanded=True, the spoiler is open by default (for repos with few patches).
|
If expanded=True, the spoiler is open by default (for repos with few patches).
|
||||||
"""
|
"""
|
||||||
noun = "patch" if count == 1 else "patches"
|
noun = "patch" if count == 1 else "patches"
|
||||||
vtbl = versions_table(targets)
|
vtbl = versions_table(targets)
|
||||||
|
package_line = f"**Package name:** `{package}`\n\n"
|
||||||
versions_section = f"**🎯 Supported versions:**\n\n{vtbl}\n\n" if vtbl else ""
|
versions_section = f"**🎯 Supported versions:**\n\n{vtbl}\n\n" if vtbl else ""
|
||||||
tag = "<details open>" if expanded else "<details>"
|
tag = "<details open>" if expanded else "<details>"
|
||||||
return f"""{tag}
|
return f"""{tag}
|
||||||
<summary>{label} • {count} {noun}</summary>
|
<summary>{label} • {count} {noun}</summary>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
{versions_section}{tbl}
|
{package_line}{versions_section}{tbl}
|
||||||
|
|
||||||
</details>"""
|
</details>"""
|
||||||
|
|
||||||
@@ -172,7 +174,7 @@ def build_content(expanded=False):
|
|||||||
for entry in by_pkg.values():
|
for entry in by_pkg.values():
|
||||||
patches = list(entry["patches"].values())
|
patches = list(entry["patches"].values())
|
||||||
label = f"{entry['emoji']} {entry['name']}"
|
label = f"{entry['emoji']} {entry['name']}"
|
||||||
lines.append(spoiler(label, len(patches), entry["targets"], patches_table(patches), expanded))
|
lines.append(spoiler(label, entry["package"], len(patches), entry["targets"], patches_table(patches), expanded))
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
# Universal patches (no specific app)
|
# Universal patches (no specific app)
|
||||||
|
|||||||
Reference in new issue
Block a user