- Introduce `DocRegistry` for managing API documentation - Add automatic discovery of markdown documentation from templates - Implement a new web-based documentation viewer at `/docs` - Include basic markdown to HTML conversion logic - Register core HeroServer API documentation and an example 'comments' API
350 lines
8.5 KiB
HTML
350 lines
8.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>@{title} - HeroServer Documentation</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
line-height: 1.5;
|
|
color: #333;
|
|
background-color: #f8f9fa;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.container {
|
|
display: flex;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.sidebar {
|
|
width: 280px;
|
|
background: #fff;
|
|
border-right: 1px solid #e1e5e9;
|
|
padding: 20px 0;
|
|
overflow-y: auto;
|
|
position: fixed;
|
|
height: 100vh;
|
|
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.sidebar h2 {
|
|
padding: 0 20px 15px;
|
|
font-size: 16px;
|
|
color: #1a1a1a;
|
|
border-bottom: 1px solid #e1e5e9;
|
|
margin-bottom: 15px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.sidebar ul {
|
|
list-style: none;
|
|
}
|
|
|
|
.sidebar li {
|
|
margin: 0;
|
|
}
|
|
|
|
.sidebar a {
|
|
display: block;
|
|
padding: 8px 20px;
|
|
color: #666;
|
|
text-decoration: none;
|
|
transition: all 0.2s ease;
|
|
border-left: 3px solid transparent;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.sidebar a:hover {
|
|
background-color: #f1f3f4;
|
|
color: #1976d2;
|
|
border-left-color: #1976d2;
|
|
}
|
|
|
|
.sidebar a.active {
|
|
background-color: #e3f2fd;
|
|
color: #1976d2;
|
|
border-left-color: #1976d2;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
margin-left: 280px;
|
|
padding: 30px;
|
|
max-width: calc(100% - 280px);
|
|
}
|
|
|
|
.content-wrapper {
|
|
max-width: 900px;
|
|
background: #fff;
|
|
padding: 30px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
h1 {
|
|
color: #1a1a1a;
|
|
margin-bottom: 16px;
|
|
font-size: 28px;
|
|
font-weight: 600;
|
|
line-height: 1.3;
|
|
}
|
|
|
|
h2 {
|
|
color: #1a1a1a;
|
|
margin: 24px 0 12px;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
border-bottom: 1px solid #e1e5e9;
|
|
padding-bottom: 6px;
|
|
}
|
|
|
|
/* Major section headers get stronger dividers */
|
|
h2.major-section {
|
|
border-bottom: 2px solid #e1e5e9;
|
|
}
|
|
|
|
/* Minor section headers get light dividers */
|
|
h2.minor-section {
|
|
border-bottom: 1px solid #f0f0f0;
|
|
}
|
|
|
|
h3 {
|
|
color: #333;
|
|
margin: 20px 0 10px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
h4 {
|
|
color: #333;
|
|
margin: 16px 0 8px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
p {
|
|
margin-bottom: 12px;
|
|
color: #555;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
code {
|
|
background: #f1f3f4;
|
|
padding: 2px 5px;
|
|
border-radius: 3px;
|
|
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
|
font-size: 12px;
|
|
color: #d73a49;
|
|
}
|
|
|
|
pre {
|
|
background: #f8f8f8;
|
|
border: 1px solid #e1e5e9;
|
|
border-radius: 6px;
|
|
padding: 12px;
|
|
overflow-x: auto;
|
|
margin: 12px 0;
|
|
font-size: 12px;
|
|
}
|
|
|
|
pre code {
|
|
background: none;
|
|
padding: 0;
|
|
color: #333;
|
|
font-size: 12px;
|
|
}
|
|
|
|
ul,
|
|
ol {
|
|
margin: 12px 0;
|
|
padding-left: 24px;
|
|
}
|
|
|
|
li {
|
|
margin-bottom: 4px;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
blockquote {
|
|
border-left: 4px solid #1976d2;
|
|
margin: 12px 0;
|
|
padding: 12px 16px;
|
|
background: #f8f9fa;
|
|
color: #555;
|
|
font-size: 14px;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin: 16px 0;
|
|
font-size: 13px;
|
|
}
|
|
|
|
th,
|
|
td {
|
|
border: 1px solid #e1e5e9;
|
|
padding: 8px 10px;
|
|
text-align: left;
|
|
}
|
|
|
|
th {
|
|
background: #f8f9fa;
|
|
font-weight: 600;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.badge {
|
|
display: inline-block;
|
|
padding: 2px 6px;
|
|
background: #1976d2;
|
|
color: white;
|
|
border-radius: 3px;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
margin-left: 6px;
|
|
}
|
|
|
|
.endpoint {
|
|
background: #e8f5e8;
|
|
border: 1px solid #4caf50;
|
|
border-radius: 4px;
|
|
padding: 6px 10px;
|
|
margin: 6px 0;
|
|
font-family: monospace;
|
|
font-weight: 600;
|
|
color: #2e7d32;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.method-post {
|
|
border-color: #ff9800;
|
|
background: #fff3e0;
|
|
color: #f57c00;
|
|
}
|
|
|
|
.method-get {
|
|
border-color: #4caf50;
|
|
background: #e8f5e8;
|
|
color: #2e7d32;
|
|
}
|
|
|
|
.method-put {
|
|
border-color: #2196f3;
|
|
background: #e3f2fd;
|
|
color: #1976d2;
|
|
}
|
|
|
|
.method-delete {
|
|
border-color: #f44336;
|
|
background: #ffebee;
|
|
color: #d32f2f;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.sidebar {
|
|
width: 100%;
|
|
position: relative;
|
|
height: auto;
|
|
}
|
|
|
|
.content {
|
|
margin-left: 0;
|
|
max-width: 100%;
|
|
padding: 15px;
|
|
}
|
|
|
|
.content-wrapper {
|
|
padding: 15px;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 24px;
|
|
}
|
|
|
|
h2 {
|
|
font-size: 18px;
|
|
}
|
|
|
|
h3 {
|
|
font-size: 15px;
|
|
}
|
|
|
|
p,
|
|
li {
|
|
font-size: 13px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<nav class="sidebar">
|
|
<h2>📚 API Documentation</h2>
|
|
<ul>
|
|
@{sidebar_items}
|
|
</ul>
|
|
</nav>
|
|
|
|
<main class="content">
|
|
<div class="content-wrapper">
|
|
<div id="markdown-content">
|
|
@{content}
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
// Add active class to current page
|
|
const currentPath = window.location.pathname;
|
|
const links = document.querySelectorAll('.sidebar a');
|
|
links.forEach(link => {
|
|
if (link.getAttribute('href') === currentPath) {
|
|
link.classList.add('active');
|
|
}
|
|
});
|
|
|
|
// Add method classes to endpoints and manage header dividers
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// Style code blocks for HTTP methods
|
|
const codeBlocks = document.querySelectorAll('code');
|
|
codeBlocks.forEach(code => {
|
|
const text = code.textContent.trim();
|
|
if (text.match(/^(GET|POST|PUT|DELETE|PATCH)\s+\//)) {
|
|
const method = text.split(' ')[0].toLowerCase();
|
|
code.classList.add('endpoint', `method-${method}`);
|
|
}
|
|
});
|
|
|
|
// Manage header dividers - only add to major sections
|
|
const h2Elements = document.querySelectorAll('h2');
|
|
h2Elements.forEach(h2 => {
|
|
const text = h2.textContent.toLowerCase();
|
|
const majorSections = ['overview', 'authentication', 'endpoints', 'api', 'examples', 'error handling', 'rate limiting'];
|
|
|
|
if (majorSections.some(section => text.includes(section))) {
|
|
h2.classList.add('major-section');
|
|
} else {
|
|
// Remove default border for minor sections
|
|
h2.style.borderBottom = 'none';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |