Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions gulp/helpers/offline-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const fs = require('fs');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs on every build (wired into generate-markdown). For a large doc set, zipping thousands of .md files adds processing time even for local dev builds where the bundle isn't needed. Consider gating it behind an environment variable (e.g. CAMEL_ENV=production) or making it a separate gulp task.

const path = require('path');
const { execFileSync } = require('child_process');

const PUBLIC_DIR = 'public';
const BUNDLE_NAME = 'camel-docs-offline.zip';

/**
* Generates an offline documentation bundle: a single .zip archive of all generated Markdown (.md)
* files plus /llms.txt, preserving the website directory structure. It lets agents (and humans)
* with no or restricted internet access read the Camel docs locally - download, unzip (e.g. into
* /tmp) and read the Markdown from there. See CAMEL-23781.
*
* Must run after the .md files have been generated (see generate-markdown task). Uses the system
* `zip` tool, so no extra dependency is required.
*/
function generateOfflineBundle() {
const bundlePath = path.join(PUBLIC_DIR, BUNDLE_NAME);

if (!fs.existsSync(PUBLIC_DIR)) {
console.error(`Cannot generate ${BUNDLE_NAME}: '${PUBLIC_DIR}' directory not found`);
return;
}

// remove any stale bundle so it is never zipped into itself
if (fs.existsSync(bundlePath)) {
fs.unlinkSync(bundlePath);
}

try {
// run from public/ so paths stay relative to the site root; include only .md files and llms.txt
execFileSync('zip', ['-r', '-q', BUNDLE_NAME, '.', '-i', '*.md', 'llms.txt'], {
cwd: PUBLIC_DIR,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires the system zip binary to be installed. While common on Linux/macOS (and GitHub Actions runners), it's an undocumented dependency. If zip is missing, the error is caught and logged but the build continues silently — which could be confusing when the bundle is expected but missing.

Consider adding a pre-check:

Suggested change
cwd: PUBLIC_DIR,
// verify zip is available
try {
execFileSync('zip', ['--version'], { stdio: 'pipe' });
} catch {
console.warn(`Skipping ${BUNDLE_NAME}: 'zip' command not found`);
return;
}
// run from public/ so paths stay relative to the site root; include only .md files and llms.txt
execFileSync('zip', ['-r', '-q', BUNDLE_NAME, '.', '-i', '*.md', 'llms.txt'], {

stdio: 'inherit'
});

const sizeMb = (fs.statSync(bundlePath).size / (1024 * 1024)).toFixed(1);
console.log(`Generated /${BUNDLE_NAME} (${sizeMb} MB)`);
} catch (error) {
console.error(`Failed to generate ${BUNDLE_NAME}:`, error.message);
}
}

module.exports = {
generateOfflineBundle
};
4 changes: 4 additions & 0 deletions gulp/tasks/generate-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { parse } = require('node-html-parser');
const { createTurndownService } = require('../helpers/turndown-config');
const { generateToonSitemaps } = require('../helpers/toon-format');
const { generateLlmsTxt } = require('../helpers/llms-txt');
const { generateOfflineBundle } = require('../helpers/offline-bundle');
const { generateReleasesIndex, generateBlogIndex } = require('../helpers/rss-feed');
const { generateAllIndexes } = require('../helpers/html-index');

Expand Down Expand Up @@ -106,6 +107,9 @@ async function generateMarkdown(done) {
// Generate llms.txt file
generateLlmsTxt(processedPages);

// Generate the offline documentation bundle (all .md files + llms.txt) as a single .zip
generateOfflineBundle();

// Generate toon format sitemaps
await generateToonSitemaps();

Expand Down
2 changes: 2 additions & 0 deletions llms-txt-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ For example:
- HTML: `https://camel.apache.org/components/next/languages/simple-language.html`
- Markdown: `https://camel.apache.org/components/next/languages/simple-language.md`

For agents or environments with no or restricted internet access, the complete documentation is also available as a single offline archive of all Markdown files, preserving the site structure: `https://camel.apache.org/camel-docs-offline.zip`. Download it once, unzip it locally (for example into `/tmp`) and read the `.md` files from there.

## Key facts

- Apache Camel is a **library**, not a platform — it embeds in your existing Spring Boot or Quarkus application
Expand Down
Loading