Spaces:
Runtime error
Runtime error
Create docgen.py
Browse files- utils/docgen.py +13 -0
utils/docgen.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
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 |
+
return f"""# {name}
|
| 10 |
+
**Path:** {path}
|
| 11 |
+
**SHA1:** {sha1}
|
| 12 |
+
|
| 13 |
+
## Preview
|