Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvianen committed Sep 8, 2024
1 parent 65c6cda commit 167ff99
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 43 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.62
0.0.63
6 changes: 3 additions & 3 deletions dist/js/javascript/DocumentationGenerator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ declare class DocumentationGenerator {
/**
* Initializes a new instance of the DocumentationGenerator.
*
* @param sourcePath Path to the source files for which documentation should be generated.
* @param outputPath Path where the generated documentation will be placed.
* @param generatorCommand The command-line tool used for generating documentation (e.g., "jsdoc").
* @param sourcePath - Path to the source files for which documentation should be generated.
* @param outputPath - Path where the generated documentation will be placed.
* @param generatorCommand - The command-line tool used for generating documentation (e.g., "jsdoc").
*/
constructor(sourcePath: string, outputPath: string, generatorCommand: string);
/**
Expand Down
25 changes: 13 additions & 12 deletions dist/js/javascript/DocumentationGenerator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use strict";
// ============================================================================
// Import
// ============================================================================
// class/DocumentationGenerator.ts
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
Expand All @@ -15,12 +13,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// ============================================================================
// Imports
// ============================================================================
const child_process_1 = require("child_process");
const util_1 = __importDefault(require("util"));
// ============================================================================
// Constants
// ============================================================================
const execAsync = util_1.default.promisify(child_process_1.exec);
const execFileAsync = util_1.default.promisify(child_process_1.execFile);
// ============================================================================
// Classes
// ============================================================================
Expand All @@ -33,9 +34,9 @@ class DocumentationGenerator {
/**
* Initializes a new instance of the DocumentationGenerator.
*
* @param sourcePath Path to the source files for which documentation should be generated.
* @param outputPath Path where the generated documentation will be placed.
* @param generatorCommand The command-line tool used for generating documentation (e.g., "jsdoc").
* @param sourcePath - Path to the source files for which documentation should be generated.
* @param outputPath - Path where the generated documentation will be placed.
* @param generatorCommand - The command-line tool used for generating documentation (e.g., "jsdoc").
*/
constructor(sourcePath, outputPath, generatorCommand) {
this.sourcePath = sourcePath;
Expand All @@ -53,15 +54,15 @@ class DocumentationGenerator {
generate() {
return __awaiter(this, void 0, void 0, function* () {
try {
// Here, you can add any pre-generation logic if necessary
// Execute the documentation generation command
const { stdout, stderr } = yield execAsync(`${this.generatorCommand} -c ${this.sourcePath} -o ${this.outputPath}`);
// Prepare command arguments safely
const args = ['-c', this.sourcePath, '-o', this.outputPath];
// Execute the documentation generation command safely without shell interpolation
const { stdout, stderr } = yield execFileAsync(this.generatorCommand, args);
if (stderr) {
throw new Error(`Documentation generation failed: ${stderr}`);
}
console.log(stdout);
console.log("Documentation generated successfully.");
// Here, you can add any post-generation logic if necessary
}
catch (error) {
console.error("Error occurred while generating documentation:", error);
Expand All @@ -75,7 +76,7 @@ class DocumentationGenerator {
// ============================================================================
exports.default = DocumentationGenerator;
// ============================================================================
// Example
// Example Usage
// ============================================================================
// import DocumentationGenerator from "./DocumentationGenerator";
// const sourcePath = "./src";
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pack.gl",
"version": "0.0.62",
"version": "0.0.63",
"description": "Package Builder.",
"keywords": [
"pack.gl",
Expand Down
37 changes: 14 additions & 23 deletions dist/ts/javascript/DocumentationGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// class/DocumentationGenerator.ts

// ============================================================================
// Import
// Imports
// ============================================================================

import { exec } from "child_process";
import { execFile } from "child_process";
import util from "util";


// ============================================================================
// Constants
// ============================================================================

const execAsync = util.promisify(exec);

const execFileAsync = util.promisify(execFile);

// ============================================================================
// Classes
Expand All @@ -23,17 +23,16 @@ const execAsync = util.promisify(exec);
* and the specific documentation generation command to be used.
*/
class DocumentationGenerator {

private sourcePath: string;
private outputPath: string;
private generatorCommand: string;

/**
* Initializes a new instance of the DocumentationGenerator.
*
* @param sourcePath Path to the source files for which documentation should be generated.
* @param outputPath Path where the generated documentation will be placed.
* @param generatorCommand The command-line tool used for generating documentation (e.g., "jsdoc").
* @param sourcePath - Path to the source files for which documentation should be generated.
* @param outputPath - Path where the generated documentation will be placed.
* @param generatorCommand - The command-line tool used for generating documentation (e.g., "jsdoc").
*/
constructor(sourcePath: string, outputPath: string, generatorCommand: string) {
this.sourcePath = sourcePath;
Expand All @@ -51,41 +50,33 @@ class DocumentationGenerator {
*/
async generate(): Promise<void> {
try {
// Here, you can add any pre-generation logic if necessary
// Prepare command arguments safely
const args = ['-c', this.sourcePath, '-o', this.outputPath];

// Execute the documentation generation command
const { stdout, stderr } = await execAsync(
`${this.generatorCommand} -c ${this.sourcePath} -o ${this.outputPath}`
);
// Execute the documentation generation command safely without shell interpolation
const { stdout, stderr } = await execFileAsync(this.generatorCommand, args);

if (stderr) {
throw new Error(`Documentation generation failed: ${stderr}`);
}

console.log(stdout);
console.log("Documentation generated successfully.");

// Here, you can add any post-generation logic if necessary
} catch (error) {
console.error(
"Error occurred while generating documentation:",
error
);
console.error("Error occurred while generating documentation:", error);
throw error;
}
}
}


// ============================================================================
// Export
// ============================================================================

export default DocumentationGenerator;


// ============================================================================
// Example
// Example Usage
// ============================================================================

// import DocumentationGenerator from "./DocumentationGenerator";
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pack.gl",
"description": "Package Builder.",
"version": "0.0.62",
"version": "0.0.63",
"config": {
"version_short": "0.0"
},
Expand Down

0 comments on commit 167ff99

Please sign in to comment.