Spaces:
Runtime error
Runtime error
Update utils/docgen.py
Browse files- utils/docgen.py +18 -5
utils/docgen.py
CHANGED
|
@@ -2,13 +2,26 @@ import hashlib
|
|
| 2 |
|
| 3 |
def generate_doc(name: str, path: str, content: str) -> str:
|
| 4 |
"""Generate basic README-style documentation for a script."""
|
|
|
|
| 5 |
sha1 = hashlib.sha1(content.encode()).hexdigest()
|
| 6 |
usage = "bash " + name if name.endswith(".sh") else f"python {name}"
|
| 7 |
preview = content[:300]
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
|
|
|
| 2 |
|
| 3 |
def generate_doc(name: str, path: str, content: str) -> str:
|
| 4 |
"""Generate basic README-style documentation for a script."""
|
| 5 |
+
|
| 6 |
sha1 = hashlib.sha1(content.encode()).hexdigest()
|
| 7 |
usage = "bash " + name if name.endswith(".sh") else f"python {name}"
|
| 8 |
preview = content[:300]
|
| 9 |
|
| 10 |
+
# Build output line by line to avoid triple-quote issues
|
| 11 |
+
lines = []
|
| 12 |
+
lines.append(f"# {name}")
|
| 13 |
+
lines.append("")
|
| 14 |
+
lines.append(f"**Path:** `{path}` ")
|
| 15 |
+
lines.append(f"**SHA1:** `{sha1}` ")
|
| 16 |
+
lines.append("")
|
| 17 |
+
lines.append("## Usage")
|
| 18 |
+
lines.append("```")
|
| 19 |
+
lines.append(usage)
|
| 20 |
+
lines.append("```")
|
| 21 |
+
lines.append("")
|
| 22 |
+
lines.append("## Preview (first 300 chars)")
|
| 23 |
+
lines.append("```")
|
| 24 |
+
lines.append(preview)
|
| 25 |
+
lines.append("```")
|
| 26 |
|
| 27 |
+
return "\n".join(lines)
|