docstodev 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/analyzer.d.ts +3 -0
- package/dist/ai/analyzer.d.ts.map +1 -0
- package/dist/ai/analyzer.js +45 -0
- package/dist/ai/analyzer.js.map +1 -0
- package/dist/analyzers/languageAnalyzer.d.ts +20 -0
- package/dist/analyzers/languageAnalyzer.d.ts.map +1 -0
- package/dist/analyzers/languageAnalyzer.js +513 -0
- package/dist/analyzers/languageAnalyzer.js.map +1 -0
- package/dist/cache/cacheManager.d.ts +38 -0
- package/dist/cache/cacheManager.d.ts.map +1 -0
- package/dist/cache/cacheManager.js +141 -0
- package/dist/cache/cacheManager.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +316 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/generateSummary.d.ts +18 -0
- package/dist/commands/generateSummary.d.ts.map +1 -0
- package/dist/commands/generateSummary.js +116 -0
- package/dist/commands/generateSummary.js.map +1 -0
- package/dist/commands/run.d.ts +5 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +326 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/exporters/html.d.ts +6 -0
- package/dist/exporters/html.d.ts.map +1 -0
- package/dist/exporters/html.js +596 -0
- package/dist/exporters/html.js.map +1 -0
- package/docs/docs-to-dev.md +240 -0
- package/docs/report.html +633 -0
- package/docs/report.pdf +0 -0
- package/docs/summary.md +16 -0
- package/package.json +1 -1
- package/src/ai/analyzer.ts +258 -19
- package/src/commands/run.ts +149 -83
- package/src/exporters/html.ts +302 -48
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function exportToHTML(docsDir, markdownContent, mermaidGraph, lang = "fr", fileTree) {
|
|
4
|
+
const lines = markdownContent.split("\n");
|
|
5
|
+
let htmlResult = "";
|
|
6
|
+
let inTable = false;
|
|
7
|
+
let inSection = false;
|
|
8
|
+
const formatText = (text) => text
|
|
9
|
+
.replace(/`(.*?)`/g, "<code>$1</code>")
|
|
10
|
+
.replace(/\*\*(.*?)\*\*/g, "$1")
|
|
11
|
+
.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>');
|
|
12
|
+
for (const line of lines) {
|
|
13
|
+
const processed = line.trim();
|
|
14
|
+
/* ================= TABLES ================= */
|
|
15
|
+
if (processed.startsWith("|")) {
|
|
16
|
+
if (!inTable) {
|
|
17
|
+
htmlResult += `<div class="table-container"><table>`;
|
|
18
|
+
inTable = true;
|
|
19
|
+
}
|
|
20
|
+
if (processed.includes("---"))
|
|
21
|
+
continue;
|
|
22
|
+
const cells = processed.split("|").filter(c => c.trim());
|
|
23
|
+
const isHeader = processed.includes("Module") || processed.includes("Type");
|
|
24
|
+
htmlResult += `<tr>${cells.map(c => isHeader
|
|
25
|
+
? `<th>${formatText(c.trim())}</th>`
|
|
26
|
+
: `<td>${formatText(c.trim())}</td>`).join("")}</tr>`;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
else if (inTable) {
|
|
30
|
+
htmlResult += "</table></div>";
|
|
31
|
+
inTable = false;
|
|
32
|
+
}
|
|
33
|
+
/* ================= TREE VIEW ================= */
|
|
34
|
+
if (processed.match(/^[│├└─\s]+/) ||
|
|
35
|
+
processed.includes("/") ||
|
|
36
|
+
processed.match(/\.(ts|js|py|java|cs|go|rs|tsx|jsx|html|css|php|rb|sql)$/)) {
|
|
37
|
+
const hasFile = processed.match(/\.(ts|js|py|java|cs|go|rs|tsx|jsx|html|css|php|rb|sql)$/);
|
|
38
|
+
const fileMatch = hasFile ? processed.match(/([\w-]+\.(ts|js|py|java|cs|go|rs|tsx|jsx|html|css|php|rb|sql))/)?.[0] : null;
|
|
39
|
+
let treeLine = line
|
|
40
|
+
.replace(/├─/g, '<span class="branch">├─</span>')
|
|
41
|
+
.replace(/└─/g, '<span class="branch">└─</span>')
|
|
42
|
+
.replace(/│/g, '<span class="pipe">│</span>');
|
|
43
|
+
if (fileMatch) {
|
|
44
|
+
treeLine = treeLine.replace(fileMatch, `<span class="file-badge">${fileMatch}</span>`);
|
|
45
|
+
}
|
|
46
|
+
htmlResult += `<div class="tree-line">${formatText(treeLine)}</div>`;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
/* ================= HEADERS ================= */
|
|
50
|
+
if (processed.startsWith("# ")) {
|
|
51
|
+
htmlResult += `<h1>${processed.slice(2)}</h1>`;
|
|
52
|
+
}
|
|
53
|
+
else if (processed.startsWith("## ")) {
|
|
54
|
+
if (inSection) {
|
|
55
|
+
htmlResult += "</section>";
|
|
56
|
+
inSection = false;
|
|
57
|
+
}
|
|
58
|
+
htmlResult += `<h2>${processed.slice(3)}</h2>`;
|
|
59
|
+
}
|
|
60
|
+
else if (processed.startsWith("### ")) {
|
|
61
|
+
if (inSection)
|
|
62
|
+
htmlResult += "</section>";
|
|
63
|
+
htmlResult += `<section class="component"><h3>${formatText(processed.slice(4))}</h3>`;
|
|
64
|
+
inSection = true;
|
|
65
|
+
}
|
|
66
|
+
/* ================= LISTS ================= */
|
|
67
|
+
else if (/^[-*•]\s+/.test(processed)) {
|
|
68
|
+
htmlResult += `<div class="list-item">${formatText(processed.replace(/^[-*•]\s+/, ""))}</div>`;
|
|
69
|
+
}
|
|
70
|
+
/* ================= PARAGRAPHS ================= */
|
|
71
|
+
else if (processed.length > 0) {
|
|
72
|
+
htmlResult += `<p>${formatText(processed)}</p>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (inSection)
|
|
76
|
+
htmlResult += "</section>";
|
|
77
|
+
// Nettoyer et valider les graphes Mermaid
|
|
78
|
+
const cleanMermaidGraph = sanitizeMermaidGraph(mermaidGraph || "graph TD\n Root[Projet]");
|
|
79
|
+
const hierarchyGraph = fileTree ? generateHierarchyGraph(fileTree) : getDefaultHierarchyGraph();
|
|
80
|
+
const dataFlowGraph = generateDataFlowGraph();
|
|
81
|
+
const html = `<!DOCTYPE html>
|
|
82
|
+
<html lang="${lang}" data-theme="dark">
|
|
83
|
+
<head>
|
|
84
|
+
<meta charset="UTF-8">
|
|
85
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
86
|
+
<title>DocsToDev – ${lang === 'fr' ? 'Rapport Technique' : 'Technical Report'}</title>
|
|
87
|
+
|
|
88
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400&family=Fira+Code&display=swap" rel="stylesheet">
|
|
89
|
+
<script type="module">
|
|
90
|
+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
|
|
91
|
+
|
|
92
|
+
mermaid.initialize({
|
|
93
|
+
startOnLoad: true,
|
|
94
|
+
theme: document.documentElement.dataset.theme === "dark" ? "dark" : "default",
|
|
95
|
+
securityLevel: 'loose',
|
|
96
|
+
logLevel: 'error',
|
|
97
|
+
themeVariables: {
|
|
98
|
+
darkMode: document.documentElement.dataset.theme === "dark",
|
|
99
|
+
background: "transparent",
|
|
100
|
+
primaryColor: "#58a6ff",
|
|
101
|
+
primaryTextColor: "#c9d1d9",
|
|
102
|
+
primaryBorderColor: "#30363d",
|
|
103
|
+
lineColor: "#8b949e",
|
|
104
|
+
secondaryColor: "#161b22",
|
|
105
|
+
tertiaryColor: "#0d1117",
|
|
106
|
+
fontSize: "14px",
|
|
107
|
+
fontFamily: "Inter, sans-serif"
|
|
108
|
+
},
|
|
109
|
+
flowchart: {
|
|
110
|
+
useMaxWidth: true,
|
|
111
|
+
htmlLabels: true,
|
|
112
|
+
curve: 'basis'
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
window.mermaid = mermaid;
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<style>
|
|
120
|
+
:root[data-theme="dark"] {
|
|
121
|
+
--bg: #0d1117;
|
|
122
|
+
--card: #161b22;
|
|
123
|
+
--text: #c9d1d9;
|
|
124
|
+
--muted: #8b949e;
|
|
125
|
+
--border: #30363d;
|
|
126
|
+
--accent: #58a6ff;
|
|
127
|
+
--code-bg: #1f2428;
|
|
128
|
+
--file-badge-bg: rgba(248, 81, 73, 0.15);
|
|
129
|
+
--file-badge-text: #f85149;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:root[data-theme="light"] {
|
|
133
|
+
--bg: #ffffff;
|
|
134
|
+
--card: #f6f8fa;
|
|
135
|
+
--text: #24292f;
|
|
136
|
+
--muted: #57606a;
|
|
137
|
+
--border: #d0d7de;
|
|
138
|
+
--accent: #0969da;
|
|
139
|
+
--code-bg: #eaeef2;
|
|
140
|
+
--file-badge-bg: rgba(218, 54, 51, 0.15);
|
|
141
|
+
--file-badge-text: #da3633;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
* {
|
|
145
|
+
margin: 0;
|
|
146
|
+
padding: 0;
|
|
147
|
+
box-sizing: border-box;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
body {
|
|
151
|
+
font-family: Inter, sans-serif;
|
|
152
|
+
background: var(--bg);
|
|
153
|
+
color: var(--text);
|
|
154
|
+
line-height: 1.6;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.container {
|
|
158
|
+
max-width: 1400px;
|
|
159
|
+
margin: 0 auto;
|
|
160
|
+
padding: 2rem;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.controls {
|
|
164
|
+
position: sticky;
|
|
165
|
+
top: 0;
|
|
166
|
+
background: var(--bg);
|
|
167
|
+
padding: 1rem 0;
|
|
168
|
+
display: flex;
|
|
169
|
+
gap: 0.75rem;
|
|
170
|
+
z-index: 100;
|
|
171
|
+
border-bottom: 1px solid var(--border);
|
|
172
|
+
margin-bottom: 2rem;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#search {
|
|
176
|
+
flex: 1;
|
|
177
|
+
padding: 0.6rem 1rem;
|
|
178
|
+
border: 1px solid var(--border);
|
|
179
|
+
background: var(--card);
|
|
180
|
+
color: var(--text);
|
|
181
|
+
font-size: 0.95rem;
|
|
182
|
+
font-family: Inter, sans-serif;
|
|
183
|
+
transition: border-color 0.2s;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
#search:focus {
|
|
187
|
+
outline: none;
|
|
188
|
+
border-color: var(--accent);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
button {
|
|
192
|
+
padding: 0.6rem 1.2rem;
|
|
193
|
+
border: 1px solid var(--border);
|
|
194
|
+
background: var(--card);
|
|
195
|
+
color: var(--text);
|
|
196
|
+
cursor: pointer;
|
|
197
|
+
font-size: 0.95rem;
|
|
198
|
+
font-family: Inter, sans-serif;
|
|
199
|
+
transition: all 0.2s;
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
gap: 0.5rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
button:hover {
|
|
206
|
+
background: var(--border);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
button svg {
|
|
210
|
+
width: 16px;
|
|
211
|
+
height: 16px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
h1 {
|
|
215
|
+
font-size: 2.5rem;
|
|
216
|
+
color: var(--accent);
|
|
217
|
+
margin-bottom: 3rem;
|
|
218
|
+
font-weight: 400;
|
|
219
|
+
letter-spacing: -0.02em;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
h2 {
|
|
223
|
+
font-size: 1.5rem;
|
|
224
|
+
margin: 3rem 0 1.5rem 0;
|
|
225
|
+
padding-bottom: 0.75rem;
|
|
226
|
+
border-bottom: 1px solid var(--border);
|
|
227
|
+
font-weight: 400;
|
|
228
|
+
color: var(--text);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
h3 {
|
|
232
|
+
font-size: 1.1rem;
|
|
233
|
+
margin-bottom: 1rem;
|
|
234
|
+
color: var(--accent);
|
|
235
|
+
font-weight: 400;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.graphs-grid {
|
|
239
|
+
display: grid;
|
|
240
|
+
grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
|
|
241
|
+
gap: 2rem;
|
|
242
|
+
margin: 2rem 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.graph-container {
|
|
246
|
+
border: 1px solid var(--border);
|
|
247
|
+
background: var(--card);
|
|
248
|
+
padding: 1.5rem;
|
|
249
|
+
min-height: 300px;
|
|
250
|
+
position: relative;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.graph-title {
|
|
254
|
+
font-size: 1rem;
|
|
255
|
+
color: var(--muted);
|
|
256
|
+
margin-bottom: 1rem;
|
|
257
|
+
text-transform: uppercase;
|
|
258
|
+
letter-spacing: 0.05em;
|
|
259
|
+
font-size: 0.85rem;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.mermaid-wrapper {
|
|
263
|
+
width: 100%;
|
|
264
|
+
overflow-x: auto;
|
|
265
|
+
overflow-y: hidden;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.component {
|
|
269
|
+
border: 1px solid var(--border);
|
|
270
|
+
background: var(--card);
|
|
271
|
+
padding: 1.5rem;
|
|
272
|
+
margin-bottom: 1.5rem;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.tree-line {
|
|
276
|
+
font-family: "Fira Code", monospace;
|
|
277
|
+
font-size: 0.85rem;
|
|
278
|
+
white-space: pre;
|
|
279
|
+
color: var(--muted);
|
|
280
|
+
line-height: 1.8;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.branch {
|
|
284
|
+
color: var(--accent);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.pipe {
|
|
288
|
+
color: var(--border);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.file-badge {
|
|
292
|
+
background: var(--file-badge-bg);
|
|
293
|
+
color: var(--file-badge-text);
|
|
294
|
+
padding: 0.15rem 0.5rem;
|
|
295
|
+
font-size: 0.8rem;
|
|
296
|
+
font-family: "Fira Code", monospace;
|
|
297
|
+
display: inline-block;
|
|
298
|
+
margin-left: 0.25rem;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.table-container {
|
|
302
|
+
border: 1px solid var(--border);
|
|
303
|
+
margin: 1.5rem 0;
|
|
304
|
+
overflow-x: auto;
|
|
305
|
+
background: var(--card);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
table {
|
|
309
|
+
width: 100%;
|
|
310
|
+
border-collapse: collapse;
|
|
311
|
+
font-size: 0.9rem;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
th, td {
|
|
315
|
+
border-bottom: 1px solid var(--border);
|
|
316
|
+
padding: 0.75rem 1rem;
|
|
317
|
+
text-align: left;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
th {
|
|
321
|
+
background: var(--bg);
|
|
322
|
+
color: var(--muted);
|
|
323
|
+
text-transform: uppercase;
|
|
324
|
+
font-size: 0.8rem;
|
|
325
|
+
letter-spacing: 0.05em;
|
|
326
|
+
font-weight: 400;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
tr:last-child td {
|
|
330
|
+
border-bottom: none;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
code {
|
|
334
|
+
font-family: "Fira Code", monospace;
|
|
335
|
+
background: var(--code-bg);
|
|
336
|
+
padding: 0.2rem 0.4rem;
|
|
337
|
+
font-size: 0.9em;
|
|
338
|
+
color: var(--accent);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.list-item {
|
|
342
|
+
margin-bottom: 0.5rem;
|
|
343
|
+
padding-left: 1.5rem;
|
|
344
|
+
position: relative;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.list-item::before {
|
|
348
|
+
content: "";
|
|
349
|
+
position: absolute;
|
|
350
|
+
left: 0.5rem;
|
|
351
|
+
top: 0.7rem;
|
|
352
|
+
width: 4px;
|
|
353
|
+
height: 4px;
|
|
354
|
+
background: var(--accent);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
p {
|
|
358
|
+
margin-bottom: 1rem;
|
|
359
|
+
color: var(--muted);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
a {
|
|
363
|
+
color: var(--accent);
|
|
364
|
+
text-decoration: none;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
a:hover {
|
|
368
|
+
text-decoration: underline;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
mark {
|
|
372
|
+
background: #ffd33d;
|
|
373
|
+
color: #000;
|
|
374
|
+
padding: 0.1rem 0.3rem;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.mermaid {
|
|
378
|
+
background: transparent;
|
|
379
|
+
display: flex;
|
|
380
|
+
justify-content: center;
|
|
381
|
+
align-items: center;
|
|
382
|
+
min-height: 200px;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.mermaid svg {
|
|
386
|
+
max-width: 100%;
|
|
387
|
+
height: auto;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.error-message {
|
|
391
|
+
color: #f85149;
|
|
392
|
+
padding: 1rem;
|
|
393
|
+
background: rgba(248, 81, 73, 0.1);
|
|
394
|
+
border: 1px solid rgba(248, 81, 73, 0.3);
|
|
395
|
+
border-radius: 4px;
|
|
396
|
+
font-family: "Fira Code", monospace;
|
|
397
|
+
font-size: 0.9rem;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@media print {
|
|
401
|
+
.controls {
|
|
402
|
+
display: none;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
.container {
|
|
406
|
+
max-width: 100%;
|
|
407
|
+
padding: 0;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.component {
|
|
411
|
+
page-break-inside: avoid;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@media (max-width: 768px) {
|
|
416
|
+
.graphs-grid {
|
|
417
|
+
grid-template-columns: 1fr;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.controls {
|
|
421
|
+
flex-direction: column;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
</style>
|
|
425
|
+
</head>
|
|
426
|
+
|
|
427
|
+
<body>
|
|
428
|
+
<div class="container">
|
|
429
|
+
|
|
430
|
+
<div class="controls">
|
|
431
|
+
<input id="search" placeholder="${lang === 'fr' ? 'Rechercher dans la documentation...' : 'Search in documentation...'}" type="text">
|
|
432
|
+
<button onclick="toggleTheme()">
|
|
433
|
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
434
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
|
|
435
|
+
</svg>
|
|
436
|
+
${lang === 'fr' ? 'Thème' : 'Theme'}
|
|
437
|
+
</button>
|
|
438
|
+
<button onclick="window.print()">
|
|
439
|
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
440
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"/>
|
|
441
|
+
</svg>
|
|
442
|
+
${lang === 'fr' ? 'Exporter PDF' : 'Export PDF'}
|
|
443
|
+
</button>
|
|
444
|
+
</div>
|
|
445
|
+
|
|
446
|
+
<h2>${lang === 'fr' ? 'Architecture du projet' : 'Project Architecture'}</h2>
|
|
447
|
+
<div class="graphs-grid">
|
|
448
|
+
<div class="graph-container">
|
|
449
|
+
<div class="graph-title">${lang === 'fr' ? 'Graphe des dépendances' : 'Dependency Graph'}</div>
|
|
450
|
+
<div class="mermaid-wrapper">
|
|
451
|
+
<pre class="mermaid">
|
|
452
|
+
${cleanMermaidGraph}
|
|
453
|
+
</pre>
|
|
454
|
+
</div>
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
<div class="graph-container">
|
|
458
|
+
<div class="graph-title">${lang === 'fr' ? 'Structure du projet' : 'Project Structure'}</div>
|
|
459
|
+
<div class="mermaid-wrapper">
|
|
460
|
+
<pre class="mermaid">
|
|
461
|
+
${hierarchyGraph}
|
|
462
|
+
</pre>
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<div class="graph-container" style="margin-bottom: 3rem;">
|
|
468
|
+
<div class="graph-title">${lang === 'fr' ? 'Flux de données' : 'Data Flow'}</div>
|
|
469
|
+
<div class="mermaid-wrapper">
|
|
470
|
+
<pre class="mermaid">
|
|
471
|
+
${dataFlowGraph}
|
|
472
|
+
</pre>
|
|
473
|
+
</div>
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
<div id="content-area">${htmlResult}</div>
|
|
477
|
+
|
|
478
|
+
</div>
|
|
479
|
+
|
|
480
|
+
<script>
|
|
481
|
+
function toggleTheme() {
|
|
482
|
+
const root = document.documentElement;
|
|
483
|
+
const next = root.dataset.theme === "dark" ? "light" : "dark";
|
|
484
|
+
root.dataset.theme = next;
|
|
485
|
+
localStorage.setItem("theme", next);
|
|
486
|
+
location.reload();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
document.documentElement.dataset.theme = localStorage.getItem("theme") || "dark";
|
|
490
|
+
|
|
491
|
+
const originalHTML = document.getElementById("content-area").innerHTML;
|
|
492
|
+
|
|
493
|
+
document.getElementById("search").addEventListener("input", e => {
|
|
494
|
+
const term = e.target.value.trim();
|
|
495
|
+
const container = document.getElementById("content-area");
|
|
496
|
+
|
|
497
|
+
if (!term) {
|
|
498
|
+
container.innerHTML = originalHTML;
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const regex = new RegExp("(" + term.replace(/[.*+?^\${}()|[\\]\\\\]/g, "\\\\$&") + ")", "gi");
|
|
503
|
+
container.innerHTML = originalHTML.replace(regex, "<mark>$1</mark>");
|
|
504
|
+
|
|
505
|
+
const first = container.querySelector("mark");
|
|
506
|
+
if (first) first.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// Gestion d'erreur Mermaid
|
|
510
|
+
window.addEventListener('load', () => {
|
|
511
|
+
setTimeout(() => {
|
|
512
|
+
document.querySelectorAll('.mermaid').forEach(el => {
|
|
513
|
+
if (!el.querySelector('svg') && !el.querySelector('.error-message')) {
|
|
514
|
+
const errorMsg = document.createElement('div');
|
|
515
|
+
errorMsg.className = 'error-message';
|
|
516
|
+
errorMsg.textContent = '${lang === 'fr' ? 'Erreur de rendu du graphe' : 'Graph rendering error'}';
|
|
517
|
+
el.appendChild(errorMsg);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}, 3000);
|
|
521
|
+
});
|
|
522
|
+
</script>
|
|
523
|
+
|
|
524
|
+
</body>
|
|
525
|
+
</html>`;
|
|
526
|
+
writeFileSync(path.join(docsDir, "report.html"), html);
|
|
527
|
+
}
|
|
528
|
+
function sanitizeMermaidGraph(graph) {
|
|
529
|
+
// Nettoyer les caractères problématiques
|
|
530
|
+
let cleaned = graph
|
|
531
|
+
.replace(/[""]/g, '"')
|
|
532
|
+
.replace(/['']/g, "'")
|
|
533
|
+
.replace(/\u00A0/g, ' ') // Espaces insécables
|
|
534
|
+
.trim();
|
|
535
|
+
// Vérifier que le graphe a une déclaration valide
|
|
536
|
+
if (!cleaned.match(/^(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|gantt|pie|erDiagram)/)) {
|
|
537
|
+
cleaned = "graph TD\n " + cleaned;
|
|
538
|
+
}
|
|
539
|
+
// Limiter la complexité si trop de nœuds
|
|
540
|
+
const lines = cleaned.split('\n');
|
|
541
|
+
if (lines.length > 50) {
|
|
542
|
+
cleaned = lines.slice(0, 50).join('\n') + '\n More["..."]';
|
|
543
|
+
}
|
|
544
|
+
return cleaned;
|
|
545
|
+
}
|
|
546
|
+
function generateHierarchyGraph(tree, maxDepth = 3) {
|
|
547
|
+
let graph = "graph TD\n";
|
|
548
|
+
let nodeId = 0;
|
|
549
|
+
const nodeMap = new Map();
|
|
550
|
+
function sanitizeLabel(label) {
|
|
551
|
+
return label.replace(/["\[\]]/g, '');
|
|
552
|
+
}
|
|
553
|
+
function traverse(obj, parentId, depth, prefix = "") {
|
|
554
|
+
if (depth > maxDepth)
|
|
555
|
+
return;
|
|
556
|
+
const entries = Object.entries(obj).slice(0, 10); // Limiter pour lisibilité
|
|
557
|
+
entries.forEach(([key, value]) => {
|
|
558
|
+
const currentId = `node${nodeId++}`;
|
|
559
|
+
const isFolder = value && typeof value === 'object' && Object.keys(value).length > 0;
|
|
560
|
+
const label = sanitizeLabel(isFolder ? `${key}/` : key);
|
|
561
|
+
nodeMap.set(currentId, label);
|
|
562
|
+
graph += ` ${currentId}["${label}"]\n`;
|
|
563
|
+
if (parentId) {
|
|
564
|
+
graph += ` ${parentId} --> ${currentId}\n`;
|
|
565
|
+
}
|
|
566
|
+
if (isFolder && value && depth < maxDepth) {
|
|
567
|
+
traverse(value, currentId, depth + 1, prefix + key + "/");
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
try {
|
|
572
|
+
traverse(tree, null, 0);
|
|
573
|
+
return graph || getDefaultHierarchyGraph();
|
|
574
|
+
}
|
|
575
|
+
catch (e) {
|
|
576
|
+
console.error("Error generating hierarchy graph:", e);
|
|
577
|
+
return getDefaultHierarchyGraph();
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function getDefaultHierarchyGraph() {
|
|
581
|
+
return `graph TD
|
|
582
|
+
A["Root"] --> B["src"]
|
|
583
|
+
A --> C["config"]
|
|
584
|
+
B --> D["components"]
|
|
585
|
+
B --> E["utils"]
|
|
586
|
+
B --> F["services"]`;
|
|
587
|
+
}
|
|
588
|
+
function generateDataFlowGraph() {
|
|
589
|
+
return `graph LR
|
|
590
|
+
A["Input"] --> B["Analyzer"]
|
|
591
|
+
B --> C["Parser"]
|
|
592
|
+
C --> D["Generator"]
|
|
593
|
+
D --> E["Exporter"]
|
|
594
|
+
E --> F["Output"]`;
|
|
595
|
+
}
|
|
596
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/exporters/html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,MAAM,UAAU,YAAY,CACxB,OAAe,EACf,eAAuB,EACvB,YAAoB,EACpB,OAAoB,IAAI,EACxB,QAAwB;IAExB,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE1C,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI;SACC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC;SACtC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC;SAC/B,OAAO,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;IAE/D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAE9B,gDAAgD;QAChD,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,UAAU,IAAI,sCAAsC,CAAC;gBACrD,OAAO,GAAG,I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