@knowcode/doc-builder 1.4.2 → 1.4.4
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/.claude/settings.local.json +15 -0
- package/CHANGELOG.md +20 -0
- package/CLAUDE.md +317 -0
- package/html/README.html +101 -0
- package/html/css/notion-style.css +1914 -0
- package/html/index.html +101 -0
- package/html/js/auth.js +67 -0
- package/html/js/main.js +1331 -0
- package/knowcode-doc-builder-1.4.4.tgz +0 -0
- package/lib/core-builder.js +47 -10
- package/package/CACHE-BUSTING-GUIDE.md +82 -0
- package/package/CHANGELOG.md +902 -0
- package/package/README.md +248 -0
- package/package/assets/css/notion-style.css +1914 -0
- package/package/assets/js/auth.js +67 -0
- package/package/assets/js/main.js +1331 -0
- package/package/cli.js +764 -0
- package/package/index.js +38 -0
- package/package/lib/builder.js +32 -0
- package/package/lib/config.js +278 -0
- package/package/lib/core-builder.js +957 -0
- package/package/lib/deploy.js +497 -0
- package/package/lib/dev-server.js +96 -0
- package/package/package.json +34 -0
- package/package/scripts/npx-runner.js +27 -0
- package/package/scripts/setup.js +56 -0
- package/package/test-cache-bust.sh +43 -0
- package/package.json +1 -1
- package/screenshot.png +0 -0
- package/knowcode-doc-builder-1.4.2.tgz +0 -0
- /package/{knowcode-doc-builder-1.3.15.tgz → package/knowcode-doc-builder-1.3.15.tgz} +0 -0
|
Binary file
|
package/lib/core-builder.js
CHANGED
|
@@ -24,6 +24,36 @@ function escapeHtml(text) {
|
|
|
24
24
|
return text.replace(/[&<>"']/g, m => map[m]);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// Extract summary from markdown content for tooltips
|
|
28
|
+
function extractSummary(content, maxLength = 150) {
|
|
29
|
+
// Remove front matter
|
|
30
|
+
content = content.replace(/^---[\s\S]*?---\n/, '');
|
|
31
|
+
|
|
32
|
+
// Remove headers
|
|
33
|
+
content = content.replace(/^#+\s+.+$/gm, '');
|
|
34
|
+
|
|
35
|
+
// Remove code blocks
|
|
36
|
+
content = content.replace(/```[\s\S]*?```/g, '');
|
|
37
|
+
content = content.replace(/`[^`]+`/g, '');
|
|
38
|
+
|
|
39
|
+
// Remove images and links
|
|
40
|
+
content = content.replace(/!\[[^\]]*\]\([^)]*\)/g, '');
|
|
41
|
+
content = content.replace(/\[[^\]]*\]\([^)]*\)/g, '');
|
|
42
|
+
|
|
43
|
+
// Remove HTML tags
|
|
44
|
+
content = content.replace(/<[^>]+>/g, '');
|
|
45
|
+
|
|
46
|
+
// Remove extra whitespace
|
|
47
|
+
content = content.trim().replace(/\s+/g, ' ');
|
|
48
|
+
|
|
49
|
+
// Truncate if needed
|
|
50
|
+
if (content.length > maxLength) {
|
|
51
|
+
content = content.substring(0, maxLength).trim() + '...';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return content || 'No description available';
|
|
55
|
+
}
|
|
56
|
+
|
|
27
57
|
// Process markdown content
|
|
28
58
|
function processMarkdownContent(content) {
|
|
29
59
|
// Convert mermaid code blocks to mermaid divs with titles
|
|
@@ -64,6 +94,10 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
64
94
|
const siteName = config.siteName || 'Documentation';
|
|
65
95
|
const siteDescription = config.siteDescription || 'Documentation site';
|
|
66
96
|
|
|
97
|
+
// Get doc-builder version from package.json
|
|
98
|
+
const packageJson = require('../package.json');
|
|
99
|
+
const docBuilderVersion = packageJson.version;
|
|
100
|
+
|
|
67
101
|
return `<!DOCTYPE html>
|
|
68
102
|
<html lang="en">
|
|
69
103
|
<head>
|
|
@@ -96,7 +130,7 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
96
130
|
|
|
97
131
|
<div class="header-actions">
|
|
98
132
|
<div class="deployment-info">
|
|
99
|
-
<span class="deployment-date">Last updated: ${new Date().toLocaleDateString('en-US', {
|
|
133
|
+
<span class="deployment-date" title="Built with doc-builder v${docBuilderVersion}">Last updated: ${new Date().toLocaleDateString('en-US', {
|
|
100
134
|
year: 'numeric',
|
|
101
135
|
month: 'short',
|
|
102
136
|
day: 'numeric',
|
|
@@ -144,12 +178,6 @@ function generateHTML(title, content, navigation, currentPath = '', config = {})
|
|
|
144
178
|
<!-- Sidebar -->
|
|
145
179
|
<aside class="sidebar">
|
|
146
180
|
<div class="sidebar-header">
|
|
147
|
-
<div class="sidebar-breadcrumbs">
|
|
148
|
-
<a href="/index.html" class="sidebar-home-link">
|
|
149
|
-
<i class="fas fa-home"></i>
|
|
150
|
-
<span>Home</span>
|
|
151
|
-
</a>
|
|
152
|
-
</div>
|
|
153
181
|
<div class="filter-box">
|
|
154
182
|
<input type="text" placeholder="Filter items..." class="filter-input" id="nav-filter">
|
|
155
183
|
<i class="fas fa-search filter-icon"></i>
|
|
@@ -321,9 +349,10 @@ function buildNavigationStructure(files, currentFile) {
|
|
|
321
349
|
}
|
|
322
350
|
|
|
323
351
|
const linkPath = '/' + file.urlPath;
|
|
352
|
+
const tooltip = file.summary ? ` data-tooltip="${escapeHtml(file.summary)}"` : '';
|
|
324
353
|
|
|
325
354
|
html += `
|
|
326
|
-
<a href="${linkPath}" class="nav-item${isActive}"><i class="fas fa-file-alt"></i> ${title}</a>`;
|
|
355
|
+
<a href="${linkPath}" class="nav-item${isActive}"${tooltip}><i class="fas fa-file-alt"></i> ${title}</a>`;
|
|
327
356
|
});
|
|
328
357
|
|
|
329
358
|
html += `</div></div>`;
|
|
@@ -402,6 +431,9 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config) {
|
|
|
402
431
|
const titleMatch = content.match(/^#\s+(.+)$/m);
|
|
403
432
|
const title = titleMatch ? titleMatch[1] : fileName;
|
|
404
433
|
|
|
434
|
+
// Extract summary for tooltip
|
|
435
|
+
const summary = extractSummary(content);
|
|
436
|
+
|
|
405
437
|
// Process content
|
|
406
438
|
const htmlContent = processMarkdownContent(content);
|
|
407
439
|
|
|
@@ -415,7 +447,7 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config) {
|
|
|
415
447
|
await fs.ensureDir(path.dirname(outputPath));
|
|
416
448
|
await fs.writeFile(outputPath, html);
|
|
417
449
|
|
|
418
|
-
return { title, urlPath };
|
|
450
|
+
return { title, urlPath, summary };
|
|
419
451
|
}
|
|
420
452
|
|
|
421
453
|
// Get all markdown files
|
|
@@ -437,11 +469,16 @@ async function getAllMarkdownFiles(dir, baseDir = dir) {
|
|
|
437
469
|
.replace(/[-_]/g, ' ')
|
|
438
470
|
.replace(/\b\w/g, l => l.toUpperCase());
|
|
439
471
|
|
|
472
|
+
// Read file to extract summary
|
|
473
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
474
|
+
const summary = extractSummary(content);
|
|
475
|
+
|
|
440
476
|
files.push({
|
|
441
477
|
path: fullPath,
|
|
442
478
|
relativePath,
|
|
443
479
|
urlPath,
|
|
444
|
-
displayName
|
|
480
|
+
displayName,
|
|
481
|
+
summary
|
|
445
482
|
});
|
|
446
483
|
}
|
|
447
484
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Cache Busting Guide for @knowcode/doc-builder
|
|
2
|
+
|
|
3
|
+
If you're not seeing updates after upgrading to a new version, it's likely due to caching. Follow these steps:
|
|
4
|
+
|
|
5
|
+
## 1. Clean Everything Locally
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Remove old build artifacts
|
|
9
|
+
rm -rf html/
|
|
10
|
+
|
|
11
|
+
# Clear npm cache
|
|
12
|
+
npm cache clean --force
|
|
13
|
+
|
|
14
|
+
# Remove node_modules and reinstall
|
|
15
|
+
rm -rf node_modules
|
|
16
|
+
npm install
|
|
17
|
+
|
|
18
|
+
# Make sure you have the latest version
|
|
19
|
+
npm install @knowcode/doc-builder@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. Rebuild with Fresh Files
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Build fresh documentation
|
|
26
|
+
npx @knowcode/doc-builder build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 3. Deploy with Force Flag
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Force Vercel to ignore cache
|
|
33
|
+
vercel --prod --force
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 4. Clear Browser Cache
|
|
37
|
+
|
|
38
|
+
- **Chrome/Edge**: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
|
|
39
|
+
- **Firefox**: Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
|
|
40
|
+
- **Safari**: Cmd+Option+R
|
|
41
|
+
- Or use Incognito/Private browsing mode
|
|
42
|
+
|
|
43
|
+
## 5. Clear Vercel/CDN Cache (if applicable)
|
|
44
|
+
|
|
45
|
+
If using Vercel:
|
|
46
|
+
1. Go to your project dashboard
|
|
47
|
+
2. Settings → Functions → Purge Cache
|
|
48
|
+
3. Or redeploy with a different domain temporarily
|
|
49
|
+
|
|
50
|
+
## 6. Add Cache Busting to Your Build
|
|
51
|
+
|
|
52
|
+
Edit your `doc-builder.config.js` to add version query strings:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
module.exports = {
|
|
56
|
+
// ... other config
|
|
57
|
+
cacheBust: true, // This will add ?v=timestamp to CSS/JS files
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Common Issues
|
|
62
|
+
|
|
63
|
+
- **"I updated but nothing changed"** - It's cache. Follow all steps above.
|
|
64
|
+
- **"Tooltips still don't work"** - Clear browser cache and check console for errors
|
|
65
|
+
- **"Spacing is still wrong"** - The CSS is cached. Hard refresh the page.
|
|
66
|
+
|
|
67
|
+
## Verify You Have The Right Version
|
|
68
|
+
|
|
69
|
+
Check the version in your package.json:
|
|
70
|
+
```bash
|
|
71
|
+
npm list @knowcode/doc-builder
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Should show: `@knowcode/doc-builder@1.3.13` or higher.
|
|
75
|
+
|
|
76
|
+
## Still Not Working?
|
|
77
|
+
|
|
78
|
+
1. Open browser DevTools
|
|
79
|
+
2. Go to Network tab
|
|
80
|
+
3. Check "Disable cache" checkbox
|
|
81
|
+
4. Refresh the page
|
|
82
|
+
5. Look at the CSS/JS files being loaded - they should not show "(from cache)"
|