Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
054ee7d
1
Parent(s): ea4e72d
backend stabilization
Browse files- main.py +21 -6
- templates/docs.html +34 -0
main.py
CHANGED
|
@@ -276,11 +276,26 @@ def get_docs_list():
|
|
| 276 |
docs = []
|
| 277 |
if not os.path.exists(DOCS_DIR):
|
| 278 |
return docs
|
| 279 |
-
for
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
return sorted(docs, key=lambda x: x["title"])
|
| 285 |
|
| 286 |
@app.get("/docs")
|
|
@@ -294,7 +309,7 @@ async def list_docs(request: Request):
|
|
| 294 |
first_doc = docs[0]["id"]
|
| 295 |
return await show_doc(request, first_doc)
|
| 296 |
|
| 297 |
-
@app.get("/docs/{doc_id}")
|
| 298 |
async def show_doc(request: Request, doc_id: str):
|
| 299 |
docs = get_docs_list()
|
| 300 |
file_path = os.path.join(DOCS_DIR, f"{doc_id}.md")
|
|
|
|
| 276 |
docs = []
|
| 277 |
if not os.path.exists(DOCS_DIR):
|
| 278 |
return docs
|
| 279 |
+
for root, dirs, files in os.walk(DOCS_DIR):
|
| 280 |
+
# Skip archive directory
|
| 281 |
+
if 'archive' in dirs:
|
| 282 |
+
dirs.remove('archive')
|
| 283 |
+
|
| 284 |
+
for f in files:
|
| 285 |
+
if f.endswith(".md") and f.lower() != "readme.md":
|
| 286 |
+
rel_path = os.path.relpath(os.path.join(root, f), DOCS_DIR)
|
| 287 |
+
doc_id = rel_path.replace("\\", "/").replace(".md", "")
|
| 288 |
+
|
| 289 |
+
# Title formatting: handle nested names
|
| 290 |
+
name = os.path.basename(doc_id)
|
| 291 |
+
title = name.replace("_", " ").title()
|
| 292 |
+
|
| 293 |
+
# Add category prefix if in subdirectory
|
| 294 |
+
category = os.path.dirname(doc_id)
|
| 295 |
+
if category:
|
| 296 |
+
title = f"{category.replace('_', ' ').title()}: {title}"
|
| 297 |
+
|
| 298 |
+
docs.append({"id": doc_id, "title": title})
|
| 299 |
return sorted(docs, key=lambda x: x["title"])
|
| 300 |
|
| 301 |
@app.get("/docs")
|
|
|
|
| 309 |
first_doc = docs[0]["id"]
|
| 310 |
return await show_doc(request, first_doc)
|
| 311 |
|
| 312 |
+
@app.get("/docs/{doc_id:path}")
|
| 313 |
async def show_doc(request: Request, doc_id: str):
|
| 314 |
docs = get_docs_list()
|
| 315 |
file_path = os.path.join(DOCS_DIR, f"{doc_id}.md")
|
templates/docs.html
CHANGED
|
@@ -178,6 +178,17 @@
|
|
| 178 |
color: var(--text-main);
|
| 179 |
}
|
| 180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
/* Syntax Highlighting overrides if needed */
|
| 182 |
.codehilite .k { color: #f472b6; } /* keyword */
|
| 183 |
.codehilite .s { color: #34d399; } /* string */
|
|
@@ -221,5 +232,28 @@
|
|
| 221 |
{{ content | safe }}
|
| 222 |
</article>
|
| 223 |
</main>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
</body>
|
| 225 |
</html>
|
|
|
|
| 178 |
color: var(--text-main);
|
| 179 |
}
|
| 180 |
|
| 181 |
+
/* Mermaid Styling */
|
| 182 |
+
.mermaid {
|
| 183 |
+
background: #f8fafc;
|
| 184 |
+
padding: 20px;
|
| 185 |
+
border-radius: 12px;
|
| 186 |
+
border: 1px solid var(--border);
|
| 187 |
+
margin: 24px 0;
|
| 188 |
+
display: flex;
|
| 189 |
+
justify-content: center;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
/* Syntax Highlighting overrides if needed */
|
| 193 |
.codehilite .k { color: #f472b6; } /* keyword */
|
| 194 |
.codehilite .s { color: #34d399; } /* string */
|
|
|
|
| 232 |
{{ content | safe }}
|
| 233 |
</article>
|
| 234 |
</main>
|
| 235 |
+
|
| 236 |
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.9.1/dist/mermaid.min.js"></script>
|
| 237 |
+
<script>
|
| 238 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 239 |
+
// Find all mermaid code blocks and convert them to div.mermaid
|
| 240 |
+
const codeBlocks = document.querySelectorAll('code.language-mermaid');
|
| 241 |
+
codeBlocks.forEach(block => {
|
| 242 |
+
const pre = block.parentElement;
|
| 243 |
+
const div = document.createElement('div');
|
| 244 |
+
div.className = 'mermaid';
|
| 245 |
+
div.textContent = block.textContent;
|
| 246 |
+
pre.replaceWith(div);
|
| 247 |
+
});
|
| 248 |
+
|
| 249 |
+
// Initialize Mermaid
|
| 250 |
+
mermaid.initialize({
|
| 251 |
+
startOnLoad: true,
|
| 252 |
+
theme: 'neutral',
|
| 253 |
+
securityLevel: 'loose',
|
| 254 |
+
fontFamily: 'Inter'
|
| 255 |
+
});
|
| 256 |
+
});
|
| 257 |
+
</script>
|
| 258 |
</body>
|
| 259 |
</html>
|