-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-73-README-Structure-Analyzer.html
More file actions
392 lines (323 loc) · 15.6 KB
/
tool-73-README-Structure-Analyzer.html
File metadata and controls
392 lines (323 loc) · 15.6 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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 73 - README Structure Analyzer - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
.split-view {
display: grid;
grid-template-columns: 1fr;
gap: 1.5rem;
margin-bottom: 2rem;
margin-top: 1rem;
}
@media (min-width: 900px) {
.split-view { grid-template-columns: 1fr 1fr; }
}
.controls-panel {
background: rgba(0,0,0,0.4);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
height: 600px;
}
.code-area {
flex: 1;
background: var(--bg-main);
color: #7ee787;
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
padding: 1rem;
font-family: var(--font-mono);
font-size: 0.85rem;
resize: none;
outline: none;
white-space: pre;
}
.btn-action {
background: var(--primary-color);
color: #000; border: none; padding: 1rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: bold; font-size: 1rem; width: 100%;
transition: all 0.2s;
}
.btn-action:hover { opacity: 0.9; transform: translateY(-2px); }
.result-panel {
background: rgba(86,182,194,0.05);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 1.5rem;
display: flex;
flex-direction: column;
gap: 1rem;
height: 600px;
overflow-y: auto;
}
.score-circle {
width: 80px; height: 80px;
border-radius: 50%;
background: rgba(0,0,0,0.5);
border: 4px solid var(--primary-color);
display: flex; align-items: center; justify-content: center;
font-size: 1.8rem; font-weight: bold; color: var(--primary-color);
margin: 0 auto;
}
.stat-grid {
display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; text-align: center;
}
.stat-box { background: rgba(0,0,0,0.3); border: 1px solid var(--border-color); padding: 0.5rem; border-radius: 4px; }
.stat-val { font-weight: bold; font-size: 1.2rem; color: #fff; }
.stat-lbl { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; }
.section-header { margin-top: 1rem; margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--text-secondary); border-bottom: 1px solid #333; padding-bottom: 0.2rem;}
.check-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.check-item {
background: rgba(0,0,0,0.2); border: 1px solid var(--border-color); padding: 0.8rem; border-radius: 4px; display: flex; align-items: flex-start; gap: 1rem; font-size: 0.85rem;
}
.check-item.pass { border-left: 4px solid #7ee787; }
.check-item.fail { border-left: 4px solid #ff5555; }
.check-icon { font-weight: bold; font-size: 1rem; margin-top: -2px;}
.pass .check-icon { color: #7ee787; content: '✓'; }
.fail .check-icon { color: #ff5555; content: '✗'; }
/* 3D Canvas wrapper */
.graph-container {
background: #000;
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
height: 250px;
position: relative;
overflow: hidden;
box-shadow: inset 0 0 50px rgba(0,0,0,0.8);
margin-top: 1rem;
flex-shrink: 0;
}
</style>
</head>
<body class="theme-dark">
<main class="main-content" style="padding-top:2rem;">
<div class="container" style="max-width: 1400px;">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>73. README Structure Analyzer</h1>
</div>
<div>
<select id="theme-select" aria-label="Select Theme">
<option value="dark">Dark Theme</option>
<option value="light">Light Theme</option>
<option value="solarized">Solarized</option>
<option value="neon">Neon Glow</option>
<option value="highcontrast">High Contrast</option>
</select>
</div>
</div>
<div class="glass-panel">
<div class="split-view">
<!-- Left: Input -->
<div class="controls-panel">
<h3 style="margin-top:0; color:var(--primary-color);">Paste README.md Content</h3>
<textarea class="code-area" id="readme-input" spellcheck="false"># My Awesome Project
This project does something really cool.
## Features
- Fast
- Secure
## License
MIT
</textarea>
<button class="btn-action" id="btn-analyze">Analyze Structure →</button>
</div>
<!-- Right: Results -->
<div class="result-panel">
<div style="display:flex; justify-content:space-between; align-items:center;">
<div class="score-circle" id="score-display">--</div>
<div class="stat-grid" style="flex:1; margin-left: 2rem;">
<div class="stat-box">
<div class="stat-val" id="stat-words">0</div>
<div class="stat-lbl">Word Count</div>
</div>
<div class="stat-box">
<div class="stat-val" id="stat-headings">0</div>
<div class="stat-lbl">Headings</div>
</div>
<div class="stat-box">
<div class="stat-val" id="stat-links">0</div>
<div class="stat-lbl">Links/Images</div>
</div>
</div>
</div>
<!-- 3D Visualization -->
<div class="graph-container" id="graph-container">
<!-- 3D Book goes here -->
</div>
<div class="section-header">Structure Checklist</div>
<ul class="check-list" id="feedback-list">
<li style="color:var(--text-secondary); text-align:center; padding:1rem;">Click Analyze to see results</li>
</ul>
</div>
</div>
</div>
</div>
</main>
<footer class="global-footer">
<div class="container">
Made with ❤️ by <a href="https://github.com/Aliriyaj007" target="_blank">Aliriyaj007</a>
</div>
</footer>
<script src="assets/core.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script>
const input = document.getElementById('readme-input');
const btnAnalyze = document.getElementById('btn-analyze');
const scoreDisplay = document.getElementById('score-display');
const statWords = document.getElementById('stat-words');
const statHeadings = document.getElementById('stat-headings');
const statLinks = document.getElementById('stat-links');
const feedbackList = document.getElementById('feedback-list');
// Required typical README sections
const bestPractices = [
{ id: 'title', regex: /^#\s+.+/m, name: 'Project Title (H1)', desc: 'Must have a single top-level heading.' },
{ id: 'desc', regex: /(.*)/, name: 'Description', desc: 'A short description right below the title.', custom: checkDesc },
{ id: 'install', regex: /##\s+(Install|Setup|Getting Started)/i, name: 'Installation', desc: 'Instructions on how to install or setup the project.' },
{ id: 'usage', regex: /##\s+(Usage|How to Use|Example)/i, name: 'Usage', desc: 'Code examples or instructions on using the project.' },
{ id: 'api', regex: /##\s+(API|Documentation|Configurarion)/i, name: 'API / Config (Optional)', desc: 'Detailed documentation for developers.', optional: true },
{ id: 'contrib', regex: /##\s+(Contributing|Development)/i, name: 'Contributing', desc: 'How others can help build the project.' },
{ id: 'license', regex: /##\s+(License)/i, name: 'License', desc: 'Licensing information (e.g. MIT, GPL).' }
];
function checkDesc(text, tokens) {
// Description is usually text shortly after H1
let h1Index = tokens.findIndex(t => t.type === 'heading' && t.depth === 1);
if(h1Index === -1) return false;
// Check next few tokens for paragraph
for(let i = h1Index+1; i < Math.min(h1Index+4, tokens.length); i++) {
if(tokens[i].type === 'paragraph' && tokens[i].text.length > 10) return true;
}
return false;
}
let currentAnalysis = [];
function analyze() {
const raw = input.value.trim();
if(!raw) return;
// basic stats
const words = raw.split(/\s+/).filter(w => w.length > 0).length;
const headingsCount = (raw.match(/^#+\s/gm) || []).length;
const linksCount = (raw.match(/\[.*?\]\(.*?\)/g) || []).length;
statWords.textContent = words;
statHeadings.textContent = headingsCount;
statLinks.textContent = linksCount;
const tokens = marked.lexer(raw);
feedbackList.innerHTML = '';
let score = 0;
let totalWeights = 0;
currentAnalysis = [];
bestPractices.forEach(bp => {
let passed = false;
if(bp.custom) {
passed = bp.custom(raw, tokens);
} else {
passed = bp.regex.test(raw);
}
currentAnalysis.push({ id: bp.id, passed: passed, optional: bp.optional });
const w = bp.optional ? 0.5 : 1;
totalWeights += w;
if(passed) score += w;
const cls = passed ? 'pass' : (bp.optional ? 'fail optional' : 'fail');
const icon = passed ? '✓' : '✗';
let optTag = bp.optional ? '<span style="background:#555; padding:2px 4px; border-radius:4px; font-size:0.6rem; color:#fff;">Optional</span>' : '';
feedbackList.innerHTML += `
<li class="check-item ${cls}">
<div class="check-icon">${icon}</div>
<div>
<div style="font-weight:bold; color:var(--text-main); margin-bottom:0.2rem;">${bp.name} ${optTag}</div>
<div style="color:var(--text-secondary); font-size:0.75rem;">${bp.desc}</div>
</div>
</li>
`;
});
const finalScore = Math.round((score / totalWeights) * 100);
scoreDisplay.textContent = finalScore;
if(finalScore > 80) scoreDisplay.style.borderColor = '#7ee787';
else if(finalScore > 50) scoreDisplay.style.borderColor = '#ffaa00';
else scoreDisplay.style.borderColor = '#ff5555';
scoreDisplay.style.color = scoreDisplay.style.borderColor;
trigger3DUpdate();
}
btnAnalyze.addEventListener('click', analyze);
// 3D Visualization (A Book with Chapters)
let scene, camera, renderer, bookGroup;
let pages = [];
function init3D() {
const container = document.getElementById('graph-container');
const cw = container.clientWidth;
const ch = container.clientHeight;
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, cw / ch, 1, 100);
camera.position.set(0, 4, 10);
camera.lookAt(0, 0, 0);
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(cw, ch);
container.appendChild(renderer.domElement);
const light = new THREE.DirectionalLight(0xffffff, 1.2);
light.position.set(5, 10, 5);
scene.add(light);
scene.add(new THREE.AmbientLight(0x404040, 1.5));
bookGroup = new THREE.Group();
scene.add(bookGroup);
// Book spine & cover back
const coverGeo = new THREE.BoxGeometry(4.2, 0.2, 3.2);
const coverMat = new THREE.MeshPhongMaterial({ color: 0x112233 });
const cover = new THREE.Mesh(coverGeo, coverMat);
cover.position.y = -0.1;
bookGroup.add(cover);
// We will create the pages dynamically inside trigger3DUpdate
window.addEventListener('resize', () => {
if(!container) return;
const rw = container.clientWidth;
const rh = container.clientHeight;
camera.aspect = rw / rh;
camera.updateProjectionMatrix();
renderer.setSize(rw, rh);
});
animate3D();
analyze(); // Initial
}
function trigger3DUpdate() {
// Remove old pages
pages.forEach(p => bookGroup.remove(p));
pages = [];
const total = bestPractices.length;
currentAnalysis.forEach((chk, i) => {
// Each check is a "page" or "chapter block"
const pgGeo = new THREE.BoxGeometry(3.8, 0.4, 2.8);
let color = 0xeeeeee; // default white page
if(!chk.passed) {
color = chk.optional ? 0xaa8833 : 0xff5555; // missing page is red or orange
} else {
color = 0x7ee787; // present
}
const pgMat = new THREE.MeshPhongMaterial({ color: color, transparent: !chk.passed, opacity: chk.passed ? 1 : 0.3 });
const mesh = new THREE.Mesh(pgGeo, pgMat);
// Stack them up
mesh.position.y = (i * 0.45) + 0.3;
// Slightly offset missing pages to make them obvious
if(!chk.passed) {
mesh.position.x = 0.5;
mesh.rotation.y = 0.1;
mesh.scale.set(0.9, 0.8, 0.9);
}
bookGroup.add(mesh);
pages.push(mesh);
});
}
function animate3D() {
requestAnimationFrame(animate3D);
bookGroup.rotation.y = Math.sin(Date.now()*0.001) * 0.3;
bookGroup.rotation.x = 0.2 + Math.sin(Date.now()*0.0013) * 0.1;
renderer.render(scene, camera);
}
document.addEventListener('DOMContentLoaded', init3D);
</script>
</body>
</html>