Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"jake docs" fails #3069

Open
bitPankh opened this issue Apr 25, 2024 · 1 comment
Open

"jake docs" fails #3069

bitPankh opened this issue Apr 25, 2024 · 1 comment
Labels
Milestone

Comments

@bitPankh
Copy link

When I do jake docs in a Cappuccino directory which is cloned from GitHub and it is the node version... I get this error:

ReferenceError: FILE is not defined.

I think the FILE is a Narwhal object and the documentation building process is not worked on yet to do it with Node.js...

I modified the jakefile to try my luck and the edited code seems like working but doing jake docs again throws another set of errors which I currently don't know how to solve them:

Using path_to_doxygen for doxygen binary.
Pre-processing source files...
Tools/Documentation/preprocess/001.markdown_readme.sh
Tools/Documentation/preprocess/001.markdown_readme.sh: line 12: /support/processor_setup.sh: No such file or directory
Tools/Documentation/preprocess/001.markdown_readme.sh: line 17: processor_msg: command not found
Tools/Documentation/preprocess/001.markdown_readme.sh: line 18: /README.html: Read-only file system
Build took 51 millseconds

The new Node.js code for the jakefile

I hope that it helps to gain some time when the right time comes to work on this issue:

task("docset", function() {
    generateDocs(true);
    const documentationDir = path.resolve(path.join("Tools", "Documentation"));
    const docsetShell = path.join(documentationDir, "support", "docset.sh");
    
    try {
        childProcess.execSync(`${docsetShell} "${documentationDir}"`, { stdio: 'inherit' });
    } catch (error) {
        console.error("Error occurred while creating docset:", error.message);
    }
});

function generateDocs(noFrame) {
    let doxygen = null;

    try {
        // Check if doxygen executable exists in PATH
        doxygen = childProcess.execSync('which doxygen').toString().trim();
    } catch (error) {
        // Error occurred or doxygen not found
    }

    // If Doxygen not found and on macOS, try to find it using mdfind
    if (!doxygen && process.platform === 'darwin') {
        try {
            const mdfindResult = childProcess.execSync('mdfind "kMDItemContentType == \'com.apple.application-bundle\' && kMDItemCFBundleIdentifier == \'org.doxygen\'"').toString().trim();
            const doxygenApps = mdfindResult.split("\n");
            if (doxygenApps[0]) {
                doxygen = path.join(doxygenApps[0], "Contents/Resources/doxygen");
            }
        } catch (error) {
            // Error occurred or doxygen app not found
        }
    }

    if (!doxygen) {
        console.log("Doxygen not installed, skipping documentation generation.");
        return;
    }

    console.log("Using " + doxygen + " for doxygen binary.");
    console.log("Pre-processing source files...");

    const documentationDir = path.join("Tools", "Documentation");
    const preprocessors = fs.readdirSync(path.join(documentationDir, "preprocess"));

    for (const processor of preprocessors) {
        const processorPath = path.join(documentationDir, "preprocess", processor);
        console.info(processorPath);
        try {
            childProcess.execSync(processorPath, [documentationDir]);
        } catch (error) {
            // Error occurred during pre-processing
            return;
        }
    }

    if (noFrame) {
        // Back up the default settings, turn off the treeview
        try {
            childProcess.execSync(`sed -i '.bak' 's/GENERATE_TREEVIEW.*=.*YES/GENERATE_TREEVIEW = NO/' "${path.join(documentationDir, "Cappuccino.doxygen")}"`);
        } catch (error) {
            // Error occurred during sed command
            return;
        }
    } else if (fs.existsSync(path.join(documentationDir, "Cappuccino.doxygen.bak"))) {
        fs.renameSync(path.join(documentationDir, "Cappuccino.doxygen.bak"), path.join(documentationDir, "Cappuccino.doxygen"));
    }

    const doxygenDidSucceed = !childProcess.execSync(`${doxygen} "${path.join(documentationDir, "Cappuccino.doxygen")}"`);

    // Restore the original doxygen settings
    if (fs.existsSync(path.join(documentationDir, "Cappuccino.doxygen.bak"))) {
        fs.renameSync(path.join(documentationDir, "Cappuccino.doxygen.bak"), path.join(documentationDir, "Cappuccino.doxygen"));
    }

    console.log("Post-processing generated documentation...");

    const postprocessors = fs.readdirSync(path.join(documentationDir, "postprocess"));

    for (const processor of postprocessors) {
        const processorPath = path.join(documentationDir, "postprocess", processor);
        try {
            childProcess.execSync(processorPath, [documentationDir, "Documentation/html"]);
        } catch (error) {
            // Error occurred during post-processing
            fs.rmSync("Documentation", { recursive: true, force: true });
            return;
        }
    }

    if (doxygenDidSucceed) {
        if (!fs.existsSync($BUILD_DIR)) {
            fs.mkdirSync($BUILD_DIR, { recursive: true });
        }

        fs.rmSync($DOCUMENTATION_BUILD, { recursive: true, force: true });
        fs.renameSync("debug.txt", path.join("Documentation", "debug.txt"));
        fs.renameSync("Documentation", $DOCUMENTATION_BUILD);

        // There is a bug in doxygen 1.7.x preventing loading correctly the custom CSS
        // So let's do it manually
        fs.copyFileSync(path.join(documentationDir, "doxygen.css"), path.join($DOCUMENTATION_BUILD, "html", "doxygen.css"));
    }
}
@cappbot cappbot added this to the Someday milestone Apr 25, 2024
@cappbot cappbot added the #new label Apr 25, 2024
@cappbot
Copy link

cappbot commented Apr 25, 2024

Milestone: Someday. Label: #new. What's next? A reviewer should examine this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants