-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-docs.py
More file actions
370 lines (318 loc) · 18.8 KB
/
generate-docs.py
File metadata and controls
370 lines (318 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#!/usr/bin/env python3
"""
Documentation generator for PKI open-source website
Converts Markdown files to HTML with navigation and styling
"""
import os
import re
import markdown
from pathlib import Path
from datetime import datetime
# Configuration
PKIAAS_DOCS_PATH = "/home/rdem/git/pkiaas/docs"
OUTPUT_PATH = "/home/rdem/git/pki-opensource/docs"
TEMPLATE_PATH = "/home/rdem/git/pki-opensource"
# HTML Template
HTML_TEMPLATE = """<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{title} - PKI Documentation</title>
<meta name="description" content="{description}">
<link rel="canonical" href="https://pki.rdem-systems.com/docs/{canonical_path}">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {{
theme: {{
extend: {{
colors: {{
primary: {{
50: '#EEF2FF',
100: '#E0E7FF',
200: '#C7D2FE',
300: '#A5B4FC',
400: '#818CF8',
500: '#1E3A8A',
600: '#1E40AF',
700: '#1E3A8A',
800: '#1E3A8A',
900: '#1E3A8A'
}}
}}
}}
}}
}}
</script>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@600;700&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
<!-- Prism.js for syntax highlighting -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet">
<!-- Funnel Tracking -->
<script async src="https://funnel.rdem-systems.com/tracker.js"
data-site="pkios"></script>
<style>
body {{ font-family: 'Inter', sans-serif; }}
h1, h2, h3, h4 {{ font-family: 'Poppins', sans-serif; }}
code, pre {{ font-family: 'Fira Code', monospace; }}
.prose h1 {{ @apply text-4xl font-bold text-gray-900 mb-6 mt-8; }}
.prose h2 {{ @apply text-3xl font-bold text-gray-900 mb-4 mt-6; }}
.prose h3 {{ @apply text-2xl font-bold text-gray-900 mb-3 mt-5; }}
.prose h4 {{ @apply text-xl font-semibold text-gray-900 mb-2 mt-4; }}
.prose p {{ @apply text-gray-700 mb-4 leading-relaxed; }}
.prose ul {{ @apply list-disc list-inside mb-4 text-gray-700; }}
.prose ol {{ @apply list-decimal list-inside mb-4 text-gray-700; }}
.prose li {{ @apply mb-2; }}
.prose a {{ @apply text-primary-700 hover:text-primary-900 underline; }}
.prose code {{ @apply bg-gray-100 px-2 py-1 rounded text-sm text-gray-800; }}
.prose pre {{ @apply bg-gray-900 p-4 rounded-lg overflow-x-auto mb-4; }}
.prose pre code {{ @apply bg-transparent px-0 py-0 text-gray-100; }}
.prose blockquote {{ @apply border-l-4 border-primary-500 pl-4 italic text-gray-700 mb-4; }}
.prose table {{ @apply w-full border-collapse mb-4; }}
.prose th {{ @apply bg-primary-100 text-primary-900 font-semibold p-2 border border-gray-300; }}
.prose td {{ @apply p-2 border border-gray-300; }}
/* Sidebar active link */
.nav-link.active {{ @apply bg-primary-100 text-primary-900 font-semibold; }}
</style>
</head>
<body class="bg-gray-50">
<!-- Top Navigation -->
<nav class="bg-white shadow-md sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16 items-center">
<div class="flex items-center space-x-3">
<a href="/index.html" class="flex items-center space-x-3">
<svg class="h-8 w-8 text-primary-700" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 2L2 7v10c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V7l-10-5z"/>
</svg>
<span class="text-2xl font-bold text-primary-700">PKI</span>
</a>
</div>
<div class="hidden md:flex space-x-8">
<a href="/index.html" class="text-gray-700 hover:text-primary-700">Home</a>
<a href="/docs/README.html" class="text-gray-700 hover:text-primary-700">Documentation</a>
<a href="https://github.com/rdemsystems/pki" target="_blank" class="text-gray-700 hover:text-primary-700">GitHub</a>
<a href="https://www.rdem-systems.com/contact" class="bg-primary-700 text-white px-4 py-2 rounded-md hover:bg-primary-800">Support</a>
</div>
</div>
</div>
</nav>
<div class="flex">
<!-- Sidebar Navigation -->
<aside class="w-64 bg-white shadow-lg min-h-screen sticky top-16 overflow-y-auto">
<div class="p-6">
<h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-4">Documentation</h3>
<nav class="space-y-1">
{navigation}
</nav>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 p-8 max-w-4xl">
<div class="prose">
{content}
</div>
<!-- PKIaaS CTA -->
<div class="mt-12 p-6 bg-gradient-to-r from-primary-700 to-primary-900 rounded-lg text-white text-center">
<p class="text-lg font-semibold mb-2">Vous n'avez pas envie de la manager ?</p>
<a href="https://pkiaas.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="inline-block bg-white text-primary-700 px-6 py-2 rounded-md font-semibold hover:bg-gray-100 transition">Découvrir notre offre PKI As A Service</a>
</div>
<!-- Footer -->
<footer class="mt-8 pt-8 border-t border-gray-200 text-sm text-gray-600">
<p>Last updated: {date}</p>
<p class="mt-2">
<a href="https://github.com/rdemsystems/pki" target="_blank" class="text-primary-700 hover:text-primary-900">Edit this page on GitHub</a>
<span class="mx-2">|</span>
<a href="https://pki.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-primary-700 hover:text-primary-900 font-semibold">Notre logiciel PKI</a>
<span class="mx-2">|</span>
<a href="https://pkiaas.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-primary-700 hover:text-primary-900 font-semibold">Notre PKI manag\u00e9e</a>
</p>
<div class="flex flex-wrap justify-center gap-x-4 gap-y-1 mt-4 text-xs">
<a href="https://www.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Qui sommes nous?</a>
<a href="https://managed-services.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Infog\u00e9rance serveur 24/7</a>
<a href="https://proxmox.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Virtualisation Proxmox infog\u00e9r\u00e9e</a>
<a href="https://nimbus.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Sauvegarde Proxmox NimbusBackup</a>
<a href="https://as206014.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">R\u00e9seau BGP AS206014</a>
<a href="https://mariadb.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">MariaDB</a>
<a href="https://ntp.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors" title="Synchronisation temporelle Stratum 1">Infrastructure NTP Stratum 1</a>
<a href="https://pki.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Notre logiciel PKI</a>
<a href="https://pkiaas.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Notre PKI manag\u00e9e</a>
<a href="https://ivvq.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Tests et validations</a>
<a href="https://use-cases.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Cas d'usage</a>
<a href="https://referral.rdem-systems.com" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Apporteurs d'affaires</a>
</div>
<div class="flex justify-center gap-4 mt-3 text-xs">
<a href="https://www.rdem-systems.com/mentions-legales/" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Mentions l\u00e9gales</a>
<span class="text-gray-400">|</span>
<a href="https://www.rdem-systems.com/cgv/" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">CGV</a>
<span class="text-gray-400">|</span>
<a href="https://www.rdem-systems.com/privacy" target="_blank" rel="noopener noreferrer" class="text-gray-500 hover:text-primary-700 transition-colors">Politique de confidentialit\u00e9</a>
<span class="text-gray-400">|</span>
<a href="#" onclick="resetCookieConsent();return false;" class="text-gray-500 hover:text-primary-700 transition-colors">G\u00e9rer les cookies</a>
</div>
</footer>
</main>
</div>
<!-- Prism.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-bash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-php.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-javascript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-yaml.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-json.min.js"></script>
<!-- Cookie Consent Banner -->
<div id="cookie-banner" style="position:fixed;bottom:0;left:0;right:0;background:#1e293b;color:#e2e8f0;padding:1rem;z-index:9999;">
<div style="max-width:800px;margin:0 auto;">
<p style="margin:0 0 0.75rem 0;">
Ce site et les autres services RDEM Systems utilisent des cookies
pour mesurer l'audience et qualifier nos campagnes publicitaires.
<a href="https://www.rdem-systems.com/privacy" style="color:#60a5fa;">En savoir plus</a>
</p>
<div style="display:flex;flex-direction:column;gap:0.5rem;margin-bottom:0.75rem;">
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
<input type="checkbox" id="consent-rdem" checked>
Suivi d'audience RDEM Systems (cookie de suivi cross-visite)
</label>
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
<input type="checkbox" id="consent-ga4">
Google Analytics (mesure d'audience avanc\u00e9e)
</label>
<label style="display:flex;align-items:center;gap:0.5rem;cursor:pointer;">
<input type="checkbox" id="consent-meta">
Meta Pixel (qualification d'audience publicitaire)
</label>
</div>
<div style="display:flex;gap:0.5rem;flex-wrap:wrap;">
<button onclick="setConsents(0,0,0);document.getElementById('cookie-banner').remove();"
style="padding:0.5rem 1rem;background:transparent;border:1px solid #94a3b8;color:#e2e8f0;border-radius:6px;cursor:pointer;">
Tout refuser
</button>
<button onclick="setConsents(
document.getElementById('consent-rdem').checked?1:0,
document.getElementById('consent-ga4').checked?1:0,
document.getElementById('consent-meta').checked?1:0
);document.getElementById('cookie-banner').remove();"
style="padding:0.5rem 1rem;background:#475569;border:none;color:white;border-radius:6px;cursor:pointer;">
Accepter la s\u00e9lection
</button>
<button onclick="setConsents(1,1,1);document.getElementById('cookie-banner').remove();"
style="padding:0.5rem 1rem;background:#3b82f6;border:none;color:white;border-radius:6px;cursor:pointer;">
Tout accepter
</button>
</div>
</div>
</div>
<script>
function setConsents(funnel, ga, meta) {{
var opts = '; Path=/; Max-Age=34560000; Secure; SameSite=Lax; Domain=.rdem-systems.com';
document.cookie = 'funnel_consent=' + funnel + opts;
document.cookie = 'ga_consent=' + ga + opts;
document.cookie = 'meta_consent=' + meta + opts;
}}
function resetCookieConsent() {{
var del = '; Path=/; Max-Age=0; Secure; SameSite=Lax; Domain=.rdem-systems.com';
document.cookie = 'funnel_consent=0' + del;
document.cookie = 'ga_consent=0' + del;
document.cookie = 'meta_consent=0' + del;
location.reload();
}}
if (document.cookie.indexOf('funnel_consent=') !== -1 &&
document.cookie.indexOf('ga_consent=') !== -1 &&
document.cookie.indexOf('meta_consent=') !== -1) {{
var b = document.getElementById('cookie-banner');
if (b) b.remove();
}}
</script>
</body>
</html>
"""
def generate_navigation(docs_structure, current_path=""):
"""Generate sidebar navigation HTML"""
nav_html = []
for category, items in docs_structure.items():
nav_html.append(f'<div class="mb-4">')
nav_html.append(f'<h4 class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2">{category}</h4>')
for item in items:
active_class = "active" if item['path'] == current_path else ""
nav_html.append(f'<a href="{item["path"]}" class="nav-link block px-3 py-2 rounded-md text-sm text-gray-700 hover:bg-gray-100 {active_class}">{item["title"]}</a>')
nav_html.append('</div>')
return '\n'.join(nav_html)
def convert_markdown_to_html(md_file_path, output_html_path, docs_structure):
"""Convert a single markdown file to HTML"""
# Read markdown content
with open(md_file_path, 'r', encoding='utf-8') as f:
md_content = f.read()
# Extract title from first H1
title_match = re.search(r'^#\s+(.+)$', md_content, re.MULTILINE)
title = title_match.group(1) if title_match else "PKI Documentation"
# Extract first paragraph for description
desc_match = re.search(r'^(?!#)(.+)$', md_content, re.MULTILINE)
description = desc_match.group(1)[:150] if desc_match else "PKI open-source documentation"
# Convert markdown to HTML
md = markdown.Markdown(extensions=['extra', 'codehilite', 'toc', 'tables', 'fenced_code'])
html_content = md.convert(md_content)
# Replace .md links with .html links
html_content = re.sub(r'href="([^"]+)\.md"', r'href="\1.html"', html_content)
html_content = re.sub(r'href="([^"]+)\.md#', r'href="\1.html#', html_content)
# Generate navigation
relative_path = os.path.relpath(output_html_path, OUTPUT_PATH)
navigation = generate_navigation(docs_structure, relative_path)
# Fill template
final_html = HTML_TEMPLATE.format(
title=title,
description=description,
canonical_path=relative_path,
navigation=navigation,
content=html_content,
date=datetime.now().strftime("%Y-%m-%d")
)
# Write HTML file
os.makedirs(os.path.dirname(output_html_path), exist_ok=True)
with open(output_html_path, 'w', encoding='utf-8') as f:
f.write(final_html)
print(f"✅ Generated: {output_html_path}")
def scan_documentation():
"""Scan documentation directory and build structure"""
docs_structure = {}
file_mapping = []
for root, dirs, files in os.walk(PKIAAS_DOCS_PATH):
# Skip security directory (private documentation)
dirs[:] = [d for d in dirs if d not in ['security', 'AUDIT']]
for file in files:
if file.endswith('.md'):
md_path = os.path.join(root, file)
relative_path = os.path.relpath(md_path, PKIAAS_DOCS_PATH)
# Convert path to HTML
html_relative = relative_path.replace('.md', '.html')
html_path = os.path.join(OUTPUT_PATH, html_relative)
# Extract category from directory
parts = relative_path.split(os.sep)
category = parts[0] if len(parts) > 1 else "General"
# Get title from filename
title = file.replace('.md', '').replace('-', ' ').replace('_', ' ').title()
if category not in docs_structure:
docs_structure[category] = []
docs_structure[category].append({
'title': title,
'path': '/docs/' + html_relative
})
file_mapping.append((md_path, html_path))
return docs_structure, file_mapping
def main():
"""Main generation function"""
print("🔨 PKI Documentation Generator")
print("=" * 50)
# Scan documentation
print("\n📂 Scanning documentation...")
docs_structure, file_mapping = scan_documentation()
print(f"Found {len(file_mapping)} markdown files")
# Generate HTML files
print("\n🔄 Converting markdown to HTML...")
for md_path, html_path in file_mapping:
convert_markdown_to_html(md_path, html_path, docs_structure)
print(f"\n✅ Generated {len(file_mapping)} HTML pages")
print(f"📁 Output directory: {OUTPUT_PATH}")
print("\n🚀 Ready to deploy!")
if __name__ == "__main__":
main()