@knowcode/doc-builder 1.2.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.2.1] - 2025-07-19
9
+
10
+ ### Added
11
+ - **Auto-generated README.md** - System now automatically creates a helpful placeholder README.md when missing
12
+ - Comprehensive placeholder content with getting started guide and documentation standards
13
+ - Clear instructions for users on how to customize their documentation
14
+ - Built-in Mermaid diagram example in generated README
15
+ - Documentation structure recommendations and best practices
16
+
17
+ ### Fixed
18
+ - **Eliminated ugly file listing** on index page when no README exists
19
+ - Improved first-time user experience with welcoming placeholder content
20
+ - Better guidance for documentation creation and organization
21
+
22
+ ### Changed
23
+ - Simplified deployment logic - removed complex HTML file listing generation
24
+ - Build process now checks and creates README.md before scanning files
25
+ - Deploy process simplified since README.html will always exist
26
+
27
+ ### Technical Improvements
28
+ - Added `createPlaceholderReadme()` function to core-builder.js
29
+ - Integrated README generation into main build workflow
30
+ - Enhanced build logging to show when placeholder is generated
31
+ - Exported new function for potential external usage
32
+
8
33
  ## [1.2.0] - 2025-07-19
9
34
 
10
35
  ### Added (MAJOR FEATURE RELEASE)
@@ -448,9 +448,13 @@ async function buildDocumentation(config) {
448
448
  const docsDir = path.join(process.cwd(), config.docsDir);
449
449
  const outputDir = path.join(process.cwd(), config.outputDir);
450
450
 
451
+ // Check and create placeholder README.md if missing
452
+ console.log(chalk.blue('📋 Checking documentation structure...'));
453
+ const readmeGenerated = await createPlaceholderReadme(docsDir, config);
454
+
451
455
  console.log(chalk.blue('📄 Scanning for markdown files...'));
452
456
  const files = await getAllMarkdownFiles(docsDir);
453
- console.log(chalk.green(`✅ Found ${files.length} markdown files`));
457
+ console.log(chalk.green(`✅ Found ${files.length} markdown files${readmeGenerated ? ' (including auto-generated README)' : ''}`));
454
458
 
455
459
  console.log(chalk.blue('📝 Processing files...'));
456
460
  for (const file of files) {
@@ -489,6 +493,99 @@ async function buildDocumentation(config) {
489
493
  console.log(chalk.green('✅ Documentation build complete!'));
490
494
  }
491
495
 
496
+ // Create placeholder README.md if missing
497
+ async function createPlaceholderReadme(docsDir, config) {
498
+ const readmePath = path.join(docsDir, 'README.md');
499
+
500
+ // Check if README.md already exists
501
+ if (fs.existsSync(readmePath)) {
502
+ return false; // README already exists, no need to create
503
+ }
504
+
505
+ const siteName = config.siteName || 'Documentation';
506
+ const currentDate = new Date().toISOString().split('T')[0];
507
+
508
+ const placeholderContent = `# Welcome to ${siteName}
509
+
510
+ **Generated**: ${currentDate} UTC
511
+ **Status**: Placeholder - Ready for customization
512
+ **Verified**: ❓ (Auto-generated content)
513
+
514
+ ## Overview
515
+
516
+ This documentation site was built with @knowcode/doc-builder. This is an auto-generated placeholder to help you get started.
517
+
518
+ ## Getting Started
519
+
520
+ 1. **Replace this file**: Edit \`docs/README.md\` with your project's actual documentation
521
+ 2. **Add content**: Create additional markdown files in the \`docs/\` directory
522
+ 3. **Organize with folders**: Use subfolders to structure your documentation
523
+ 4. **Rebuild**: Run \`npx @knowcode/doc-builder build\` to regenerate the site
524
+
525
+ ## Documentation Structure
526
+
527
+ Your documentation can include:
528
+
529
+ - **Overview**: Main project description (this file)
530
+ - **Guides**: Step-by-step tutorials
531
+ - **API Reference**: Technical documentation
532
+ - **Examples**: Code samples and usage
533
+ - **Architecture**: System design and technical details
534
+
535
+ ## Next Steps
536
+
537
+ 1. Edit this README.md file with your project information
538
+ 2. Create additional markdown files for your content
539
+ 3. Organize files into logical folders
540
+ 4. Use Mermaid diagrams for visual explanations
541
+ 5. Deploy with \`npx @knowcode/doc-builder deploy\`
542
+
543
+ ## Documentation Standards
544
+
545
+ This project follows structured documentation conventions:
546
+
547
+ ### File Organization
548
+ - Use descriptive filenames with hyphens (e.g., \`user-guide.md\`)
549
+ - Organize related content in folders
550
+ - Include a README.md in each major folder
551
+
552
+ ### Content Format
553
+ - Start each document with metadata (Generated date, Status, Verified status)
554
+ - Use clear headings and consistent structure
555
+ - Include diagrams where helpful to explain concepts
556
+ - Mark information as verified (✅) or speculated (❓)
557
+
558
+ ### Mermaid Diagrams
559
+ Include visual diagrams to explain complex concepts:
560
+
561
+ \`\`\`mermaid
562
+ graph TD
563
+ A[Start Documentation] --> B{Have Content?}
564
+ B -->|Yes| C[Edit README.md]
565
+ B -->|No| D[Create Content Files]
566
+ C --> E[Build & Deploy]
567
+ D --> E
568
+ E --> F[Share Documentation]
569
+ \`\`\`
570
+
571
+ ## Support
572
+
573
+ For help with @knowcode/doc-builder:
574
+ - Check the documentation at your package source
575
+ - Use \`npx @knowcode/doc-builder --help\` for CLI options
576
+ - Review the generated configuration guide if available
577
+ `;
578
+
579
+ try {
580
+ await fs.writeFile(readmePath, placeholderContent);
581
+ console.log(chalk.yellow('📄 Auto-generated placeholder README.md - please customize it!'));
582
+ return true; // Successfully created placeholder
583
+ } catch (error) {
584
+ console.warn(chalk.yellow(`Warning: Could not create placeholder README.md: ${error.message}`));
585
+ return false;
586
+ }
587
+ }
588
+
492
589
  // Create login/logout pages
493
590
  async function createAuthPages(outputDir, config) {
494
591
  // Login page
@@ -570,5 +667,6 @@ async function createAuthPages(outputDir, config) {
570
667
  module.exports = {
571
668
  buildDocumentation,
572
669
  processMarkdownContent,
573
- generateHTML
670
+ generateHTML,
671
+ createPlaceholderReadme
574
672
  };
package/lib/deploy.js CHANGED
@@ -365,72 +365,29 @@ async function prepareDeployment(config) {
365
365
  fs.writeFileSync(indexPath, redirectHtml);
366
366
  console.log(chalk.green('✅ Created index.html redirect to README.html'));
367
367
  } else {
368
- // If no README.html, create a basic index listing all HTML files
369
- const htmlFiles = fs.readdirSync(outputDir)
370
- .filter(file => file.endsWith('.html') && file !== 'index.html')
371
- .sort();
372
-
373
- if (htmlFiles.length > 0) {
374
- const indexHtml = `<!DOCTYPE html>
368
+ // If no README.html, create a simple redirect to home
369
+ // This should rarely happen since build process now auto-generates README.md
370
+ const simpleIndex = `<!DOCTYPE html>
375
371
  <html>
376
372
  <head>
377
373
  <meta charset="UTF-8">
378
374
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
379
- <title>Documentation</title>
380
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
375
+ <meta http-equiv="refresh" content="0; url=./">
376
+ <title>${config.siteName || 'Documentation'}</title>
381
377
  <link rel="stylesheet" href="/css/style.css">
382
378
  <link rel="stylesheet" href="/css/notion-style.css">
383
379
  </head>
384
380
  <body>
385
- <div class="navigation">
386
- <div class="nav-header">
387
- <h2>${config.siteName || 'Documentation'}</h2>
388
- </div>
389
- <nav>
390
- <ul>
391
- ${htmlFiles.map(file => {
392
- const name = file.replace('.html', '').replace(/-/g, ' ');
393
- const capitalizedName = name.split(' ').map(word =>
394
- word.charAt(0).toUpperCase() + word.slice(1)
395
- ).join(' ');
396
- return `<li><a href="${file}"><i class="fas fa-file"></i> ${capitalizedName}</a></li>`;
397
- }).join('\n ')}
398
- </ul>
399
- </nav>
400
- </div>
401
- <div class="content">
402
- <div class="header">
403
- <h1 style="text-align: center; margin: 50px 0;">📚 Documentation</h1>
404
- </div>
405
- <div class="main-content">
406
- <div class="doc-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; padding: 20px;">
407
- ${htmlFiles.map(file => {
408
- const name = file.replace('.html', '').replace(/-/g, ' ');
409
- const capitalizedName = name.split(' ').map(word =>
410
- word.charAt(0).toUpperCase() + word.slice(1)
411
- ).join(' ');
412
- return `
413
- <a href="${file}" class="doc-card" style="display: block; padding: 20px; border: 1px solid #e1e4e8; border-radius: 8px; text-decoration: none; color: inherit; transition: all 0.2s;">
414
- <h3 style="margin: 0 0 10px 0; color: #0366d6;"><i class="fas fa-file-alt"></i> ${capitalizedName}</h3>
415
- <p style="margin: 0; color: #586069; font-size: 14px;">Click to view this documentation</p>
416
- </a>`;
417
- }).join('')}
418
- </div>
419
- </div>
381
+ <div style="text-align: center; margin-top: 50px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
382
+ <h1>📚 ${config.siteName || 'Documentation'}</h1>
383
+ <p>Loading documentation...</p>
384
+ <p><a href="./" style="color: #0366d6;">Click here if not redirected automatically</a></p>
420
385
  </div>
421
- <script src="/js/main.js"></script>
422
- <style>
423
- .doc-card:hover {
424
- box-shadow: 0 4px 12px rgba(0,0,0,0.1);
425
- transform: translateY(-2px);
426
- }
427
- </style>
428
386
  </body>
429
387
  </html>`;
430
- fs.writeFileSync(indexPath, indexHtml);
431
- console.log(chalk.green('✅ Created index.html with file listing'));
432
- console.log(chalk.yellow('📌 Remember to rebuild before deploying to see styling!'));
433
- }
388
+ fs.writeFileSync(indexPath, simpleIndex);
389
+ console.log(chalk.green('✅ Created index.html redirect'));
390
+ console.log(chalk.yellow('📌 Note: Consider running build to ensure README.md exists'));
434
391
  }
435
392
  }
436
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,69 @@
1
+ # Welcome to Documentation
2
+
3
+ **Generated**: 2025-07-19 UTC
4
+ **Status**: Placeholder - Ready for customization
5
+ **Verified**: ❓ (Auto-generated content)
6
+
7
+ ## Overview
8
+
9
+ This documentation site was built with @knowcode/doc-builder. This is an auto-generated placeholder to help you get started.
10
+
11
+ ## Getting Started
12
+
13
+ 1. **Replace this file**: Edit `docs/README.md` with your project's actual documentation
14
+ 2. **Add content**: Create additional markdown files in the `docs/` directory
15
+ 3. **Organize with folders**: Use subfolders to structure your documentation
16
+ 4. **Rebuild**: Run `npx @knowcode/doc-builder build` to regenerate the site
17
+
18
+ ## Documentation Structure
19
+
20
+ Your documentation can include:
21
+
22
+ - **Overview**: Main project description (this file)
23
+ - **Guides**: Step-by-step tutorials
24
+ - **API Reference**: Technical documentation
25
+ - **Examples**: Code samples and usage
26
+ - **Architecture**: System design and technical details
27
+
28
+ ## Next Steps
29
+
30
+ 1. Edit this README.md file with your project information
31
+ 2. Create additional markdown files for your content
32
+ 3. Organize files into logical folders
33
+ 4. Use Mermaid diagrams for visual explanations
34
+ 5. Deploy with `npx @knowcode/doc-builder deploy`
35
+
36
+ ## Documentation Standards
37
+
38
+ This project follows structured documentation conventions:
39
+
40
+ ### File Organization
41
+ - Use descriptive filenames with hyphens (e.g., `user-guide.md`)
42
+ - Organize related content in folders
43
+ - Include a README.md in each major folder
44
+
45
+ ### Content Format
46
+ - Start each document with metadata (Generated date, Status, Verified status)
47
+ - Use clear headings and consistent structure
48
+ - Include diagrams where helpful to explain concepts
49
+ - Mark information as verified (✅) or speculated (❓)
50
+
51
+ ### Mermaid Diagrams
52
+ Include visual diagrams to explain complex concepts:
53
+
54
+ ```mermaid
55
+ graph TD
56
+ A[Start Documentation] --> B{Have Content?}
57
+ B -->|Yes| C[Edit README.md]
58
+ B -->|No| D[Create Content Files]
59
+ C --> E[Build & Deploy]
60
+ D --> E
61
+ E --> F[Share Documentation]
62
+ ```
63
+
64
+ ## Support
65
+
66
+ For help with @knowcode/doc-builder:
67
+ - Check the documentation at your package source
68
+ - Use `npx @knowcode/doc-builder --help` for CLI options
69
+ - Review the generated configuration guide if available
@@ -0,0 +1 @@
1
+ # Test File
@@ -0,0 +1,164 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="description" content="Documentation site built with @knowcode/doc-builder">
7
+ <title>Welcome to Documentation - Documentation</title>
8
+
9
+ <!-- Fonts -->
10
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
11
+
12
+ <!-- Icons -->
13
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
14
+
15
+ <!-- Mermaid -->
16
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
17
+
18
+ <!-- Styles -->
19
+ <link rel="stylesheet" href="/css/notion-style.css">
20
+ <link rel="stylesheet" href="/css/style.css">
21
+
22
+ <!-- Favicon -->
23
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>">
24
+ </head>
25
+ <body>
26
+ <!-- Header -->
27
+ <header class="header">
28
+ <div class="header-content">
29
+ <a href="/index.html" class="logo">Documentation</a>
30
+
31
+ <div class="header-actions">
32
+ <div class="deployment-info">
33
+ <span class="deployment-date">Last updated: Jul 19, 2025, 11:59 AM UTC</span>
34
+ </div>
35
+
36
+
37
+
38
+ <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
39
+ <i class="fas fa-moon"></i>
40
+ </button>
41
+
42
+ <button id="menu-toggle" class="menu-toggle" aria-label="Toggle menu">
43
+ <i class="fas fa-bars"></i>
44
+ </button>
45
+ </div>
46
+ </div>
47
+ </header>
48
+
49
+ <!-- Preview Banner -->
50
+ <div id="preview-banner" class="preview-banner">
51
+ <div class="banner-content">
52
+ <i class="fas fa-exclamation-triangle banner-icon"></i>
53
+ <span class="banner-text">This documentation is a preview version - some content may be incomplete</span>
54
+ <button id="dismiss-banner" class="banner-dismiss" aria-label="Dismiss banner">
55
+ <i class="fas fa-times"></i>
56
+ </button>
57
+ </div>
58
+ </div>
59
+
60
+ <!-- Breadcrumbs -->
61
+ <nav class="breadcrumbs" id="breadcrumbs">
62
+ <!-- Breadcrumbs will be generated by JavaScript -->
63
+ </nav>
64
+
65
+ <!-- Main Content -->
66
+ <div class="main-wrapper">
67
+ <!-- Sidebar -->
68
+ <aside class="sidebar">
69
+ <div class="sidebar-header">
70
+ <div class="filter-box">
71
+ <input type="text" placeholder="Filter items..." class="filter-input" id="nav-filter">
72
+ <i class="fas fa-search filter-icon"></i>
73
+ </div>
74
+ </div>
75
+ <nav class="navigation">
76
+
77
+ <div class="nav-section" data-level="0">
78
+ <a class="nav-title expanded" href="/README.html" >
79
+ <i class="fas fa-home"></i> Documentation
80
+ </a>
81
+ <div class="nav-content" >
82
+ <a href="/README.html" class="nav-item active"><i class="fas fa-file-alt"></i> Overview</a>
83
+ <a href="/test-file.html" class="nav-item"><i class="fas fa-file-alt"></i> Test File</a></div></div>
84
+ </nav>
85
+ <div class="resize-handle"></div>
86
+ </aside>
87
+
88
+ <!-- Content Area -->
89
+ <main class="content">
90
+ <div class="content-inner">
91
+ <h1>Welcome to Documentation</h1>
92
+ <p><strong>Generated</strong>: 2025-07-19 UTC<br><strong>Status</strong>: Placeholder - Ready for customization<br><strong>Verified</strong>: ❓ (Auto-generated content)</p>
93
+ <h2>Overview</h2>
94
+ <p>This documentation site was built with @knowcode/doc-builder. This is an auto-generated placeholder to help you get started.</p>
95
+ <h2>Getting Started</h2>
96
+ <ol>
97
+ <li><strong>Replace this file</strong>: Edit <code>docs/README.md</code> with your project&#39;s actual documentation</li>
98
+ <li><strong>Add content</strong>: Create additional markdown files in the <code>docs/</code> directory</li>
99
+ <li><strong>Organize with folders</strong>: Use subfolders to structure your documentation</li>
100
+ <li><strong>Rebuild</strong>: Run <code>npx @knowcode/doc-builder build</code> to regenerate the site</li>
101
+ </ol>
102
+ <h2>Documentation Structure</h2>
103
+ <p>Your documentation can include:</p>
104
+ <ul>
105
+ <li><strong>Overview</strong>: Main project description (this file)</li>
106
+ <li><strong>Guides</strong>: Step-by-step tutorials</li>
107
+ <li><strong>API Reference</strong>: Technical documentation</li>
108
+ <li><strong>Examples</strong>: Code samples and usage</li>
109
+ <li><strong>Architecture</strong>: System design and technical details</li>
110
+ </ul>
111
+ <h2>Next Steps</h2>
112
+ <ol>
113
+ <li>Edit this README.md file with your project information</li>
114
+ <li>Create additional markdown files for your content</li>
115
+ <li>Organize files into logical folders</li>
116
+ <li>Use Mermaid diagrams for visual explanations</li>
117
+ <li>Deploy with <code>npx @knowcode/doc-builder deploy</code></li>
118
+ </ol>
119
+ <h2>Documentation Standards</h2>
120
+ <p>This project follows structured documentation conventions:</p>
121
+ <h3>File Organization</h3>
122
+ <ul>
123
+ <li>Use descriptive filenames with hyphens (e.g., <code>user-guide.md</code>)</li>
124
+ <li>Organize related content in folders</li>
125
+ <li>Include a README.md in each major folder</li>
126
+ </ul>
127
+ <h3>Content Format</h3>
128
+ <ul>
129
+ <li>Start each document with metadata (Generated date, Status, Verified status)</li>
130
+ <li>Use clear headings and consistent structure</li>
131
+ <li>Include diagrams where helpful to explain concepts</li>
132
+ <li>Mark information as verified (✅) or speculated (❓)</li>
133
+ </ul>
134
+ <h3>Mermaid Diagrams</h3>
135
+ <p>Include visual diagrams to explain complex concepts:</p>
136
+ <div class="mermaid-wrapper">
137
+ <div class="mermaid-title">Diagram</div>
138
+ <div class="mermaid">graph TD
139
+ A[Start Documentation] --&gt; B{Have Content?}
140
+ B --&gt;|Yes| C[Edit README.md]
141
+ B --&gt;|No| D[Create Content Files]
142
+ C --&gt; E[Build &amp; Deploy]
143
+ D --&gt; E
144
+ E --&gt; F[Share Documentation]
145
+ </div>
146
+ </div>
147
+
148
+ <h2>Support</h2>
149
+ <p>For help with @knowcode/doc-builder:</p>
150
+ <ul>
151
+ <li>Check the documentation at your package source</li>
152
+ <li>Use <code>npx @knowcode/doc-builder --help</code> for CLI options</li>
153
+ <li>Review the generated configuration guide if available</li>
154
+ </ul>
155
+
156
+ </div>
157
+ </main>
158
+ </div>
159
+
160
+ <!-- Scripts -->
161
+ <script src="/js/main.js"></script>
162
+
163
+ </body>
164
+ </html>