Skip to content
Merged
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
8 changes: 8 additions & 0 deletions compile-partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ if (fs.existsSync(helpersDir)) {
});
}

/**
* Reads and parses a JSON file from the specified path.
*
* If the file cannot be read or parsed, returns an empty object.
*
* @param {string} filepath - Path to the JSON file.
* @returns {Object} The parsed JSON object, or an empty object if reading or parsing fails.
*/
function readJson(filepath) {
try {
return JSON.parse(fs.readFileSync(filepath, 'utf8'));
Expand Down
12 changes: 12 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const glob = {
const rapidocSrc = 'node_modules/rapidoc/dist/rapidoc-min.js'
const rapidocDest = path.join(srcDir, 'static')

/**
* Compiles Handlebars partial templates by executing a Node.js script for each specified partial.
*
* @param {Function} cb - Callback to signal task completion or failure.
*
* @throws {Error} If any partial compilation fails, the callback is invoked with an error.
*/
function compileWidgets (cb) {
const partialsToCompile = [
{ name: 'header-content', context: 'context/header-content.json' },
Expand All @@ -50,6 +57,11 @@ function compileWidgets (cb) {
}
}

/**
* Copies the Rapidoc JavaScript file from the source location to the static assets directory.
*
* @returns {Stream} A Gulp stream representing the copy operation.
*/
function copyRapidoc () {
return gulp.src(rapidocSrc)
.pipe(gulp.dest(rapidocDest))
Expand Down