Skip to content

Commit 67051ac

Browse files
author
Sreeparna Deb
committed
added plugin description from readme
1 parent 8a7f8ec commit 67051ac

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

scripts/update_plugininfo.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
if GITHUB_TOKEN:
1616
HEADERS["Authorization"] = f"Bearer {GITHUB_TOKEN}"
1717

18+
# ---------- Fetch base info ----------
1819
def fetch_plugin_info():
1920
url = f"https://raw.githubusercontent.com/{ORG}/{REPO}/master/PluginInfo.json"
2021
r = requests.get(url)
@@ -27,7 +28,34 @@ def fetch_contributors():
2728
r.raise_for_status()
2829
return [user["login"] for user in r.json()]
2930

30-
def write_markdown(info, authors):
31+
32+
# ---------- Fetch README content ----------
33+
def fetch_readme_excerpt(max_lines=5):
34+
"""
35+
Fetch the README content and return the first few non-empty lines as a string.
36+
Falls back gracefully if README not found.
37+
"""
38+
url = f"https://raw.githubusercontent.com/{ORG}/{REPO}/master/README.md"
39+
r = requests.get(url)
40+
if r.status_code != 200:
41+
print("⚠️ No README.md found or couldn't fetch it.")
42+
return None
43+
44+
lines = r.text.splitlines()
45+
excerpt = []
46+
for line in lines:
47+
clean = line.strip()
48+
if clean: # skip empty lines
49+
excerpt.append(clean)
50+
if len(excerpt) >= max_lines:
51+
break
52+
53+
if not excerpt:
54+
return None
55+
return " ".join(excerpt)
56+
57+
# ---------- Write output markdown ----------
58+
def write_markdown(info, authors, longdescription=None):
3159
metadata = {
3260
"layout": "plugin",
3361
"name": info["name"],
@@ -39,17 +67,23 @@ def write_markdown(info, authors):
3967
"organization": "ManiVault",
4068
"organization-link": "https://www.manivault.studio",
4169
"authors": authors,
42-
"shortdescription": f"{info['type']} plugin with dependencies: {', '.join(info.get('dependencies', []))}"
70+
"shortdescription": f"{info['type']} plugin with dependencies: {', '.join(info.get('dependencies', []))}",
4371
}
4472

73+
if longdescription:
74+
metadata["longdescription"] = longdescription
75+
4576
with open(OUTPUT_PATH, "w") as f:
4677
f.write("---\n")
4778
yaml.dump(metadata, f, sort_keys=False)
4879
f.write("---\n")
4980

5081
print(f"✅ Updated {OUTPUT_PATH}")
82+
if longdescription:
83+
print("📝 Added longdescription from README.md")
5184

5285
if __name__ == "__main__":
5386
info = fetch_plugin_info()
5487
authors = fetch_contributors()
55-
write_markdown(info, authors)
88+
readme_excerpt = fetch_readme_excerpt(max_lines=5)
89+
write_markdown(info, authors, longdescription=readme_excerpt)

0 commit comments

Comments
 (0)