mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-10 00:48:45 +00:00
fixed: doc directories are spilled everywhere
This commit is contained in:
1 parent
aeb982c616
commit
4395663cc9
6 files changed
+112
-161
No files matched your search
@@ -3,6 +3,7 @@ require("./common.jake");
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var childProcess = require("child_process");
|
||||
var os = require('os');
|
||||
|
||||
const term = ObjectiveJ.term;
|
||||
const utilsFile = ObjectiveJ.utils.file;
|
||||
@@ -137,7 +138,6 @@ task ("docset", function()
|
||||
var docsetShell = path.join(documentationDir, "support", "docset.sh");
|
||||
|
||||
try {
|
||||
// Enquote paths to handle spaces
|
||||
childProcess.execSync(`"${docsetShell}" "${documentationDir}"`, { stdio: 'inherit' });
|
||||
} catch (e) {
|
||||
console.error("Failed to generate docset.");
|
||||
@@ -147,8 +147,6 @@ task ("docset", function()
|
||||
|
||||
function executableExists(command) {
|
||||
try {
|
||||
// 'which' is a common command on Unix-like systems (macOS, Linux)
|
||||
// 'where' is the equivalent on Windows
|
||||
const checkCmd = process.platform === 'win32' ? 'where' : 'which';
|
||||
childProcess.execSync(`${checkCmd} ${command}`, { stdio: 'pipe' });
|
||||
return true;
|
||||
@@ -160,118 +158,85 @@ function executableExists(command) {
|
||||
function generateDocs(/* boolean */ noFrame)
|
||||
{
|
||||
var doxygen = null;
|
||||
|
||||
// try to find a doxygen executable in the PATH;
|
||||
if (executableExists("doxygen")) {
|
||||
doxygen = "doxygen";
|
||||
}
|
||||
// If the Doxygen application is installed on Mac OS X, use that
|
||||
else if (process.platform === 'darwin' && executableExists("mdfind"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var findResult = childProcess.execSync("mdfind \"kMDItemContentType == 'com.apple.application-bundle' && kMDItemCFBundleIdentifier == 'org.doxygen'\"", { encoding: 'utf8' });
|
||||
var doxygenApps = findResult.trim().split("\n");
|
||||
if (doxygenApps[0] && fs.existsSync(doxygenApps[0])) {
|
||||
var potentialPath = path.join(doxygenApps[0], "Contents/Resources/doxygen");
|
||||
// Verify the executable exists and is executable
|
||||
fs.accessSync(potentialPath, fs.constants.X_OK);
|
||||
doxygen = potentialPath;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// mdfind failed, found nothing, or the result was not executable. Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
if (!doxygen)
|
||||
{
|
||||
if (!doxygen) {
|
||||
console.log("Doxygen not installed or not found, skipping documentation generation.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("Using " + doxygen + " for doxygen binary.");
|
||||
console.log("Pre-processing source files...");
|
||||
|
||||
var documentationDir = path.resolve("Tools", "Documentation");
|
||||
var preProcessorsDir = path.join(documentationDir, "preprocess");
|
||||
// --- Temporary Directory Setup ---
|
||||
const projectRoot = process.cwd();
|
||||
const tempDir = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'capp-docs-')));
|
||||
console.log(`Using temporary directory for build: ${tempDir}`);
|
||||
|
||||
try {
|
||||
var documentationDir = path.join(projectRoot, "Tools", "Documentation");
|
||||
|
||||
// --- Pre-processing ---
|
||||
console.log("Pre-processing source files...");
|
||||
const preProcessorsDir = path.join(documentationDir, "preprocess");
|
||||
var processors = fs.readdirSync(preProcessorsDir).sort();
|
||||
|
||||
for (var i = 0; i < processors.length; ++i) {
|
||||
var processorPath = path.join(preProcessorsDir, processors[i]);
|
||||
childProcess.execSync(`"${processorPath}" "${documentationDir}"`, { stdio: 'inherit' });
|
||||
for (const processor of processors) {
|
||||
const processorPath = path.join(preProcessorsDir, processor);
|
||||
childProcess.execSync(`"${processorPath}" "${projectRoot}"`, { stdio: 'inherit', cwd: tempDir });
|
||||
}
|
||||
|
||||
var doxygenConfigFile = path.join(documentationDir, "Cappuccino.doxygen");
|
||||
var doxygenConfigBackup = doxygenConfigFile + ".bak";
|
||||
// --- Doxygen Execution ---
|
||||
const doxygenConfigFile = path.join(documentationDir, "Cappuccino.doxygen");
|
||||
const doxygenTempConfig = path.join(tempDir, "Cappuccino.doxygen");
|
||||
fs.copyFileSync(doxygenConfigFile, doxygenTempConfig);
|
||||
|
||||
if (noFrame)
|
||||
{
|
||||
if (noFrame) {
|
||||
console.log("Disabling treeview for no-frame documentation.");
|
||||
childProcess.execSync(`sed -i.bak 's/GENERATE_TREEVIEW.*=.*YES/GENERATE_TREEVIEW = NO/' "${doxygenConfigFile}"`);
|
||||
}
|
||||
else if (fs.existsSync(doxygenConfigBackup)) {
|
||||
fs.renameSync(doxygenConfigBackup, doxygenConfigFile);
|
||||
childProcess.execSync(`sed -i.bak 's/GENERATE_TREEVIEW.*=.*YES/GENERATE_TREEVIEW = NO/' "${doxygenTempConfig}"`);
|
||||
}
|
||||
|
||||
console.log("Running Doxygen...");
|
||||
childProcess.execSync(`"${doxygen}" "Cappuccino.doxygen"`, { stdio: 'inherit', cwd: documentationDir });
|
||||
|
||||
// Restore the original doxygen settings if a backup exists
|
||||
if (fs.existsSync(doxygenConfigBackup)) {
|
||||
fs.renameSync(doxygenConfigBackup, doxygenConfigFile);
|
||||
}
|
||||
childProcess.execSync(`"${doxygen}" "${doxygenTempConfig}"`, { stdio: 'inherit', cwd: tempDir });
|
||||
|
||||
// --- Post-processing ---
|
||||
console.log("Post-processing generated documentation...");
|
||||
|
||||
var postProcessorsDir = path.join(documentationDir, "postprocess");
|
||||
var htmlOutputDir = path.join(documentationDir, "html");
|
||||
const postProcessorsDir = path.join(documentationDir, "postprocess");
|
||||
processors = fs.readdirSync(postProcessorsDir).sort();
|
||||
|
||||
for (var i = 0; i < processors.length; ++i) {
|
||||
var processorPath = path.join(postProcessorsDir, processors[i]);
|
||||
childProcess.execSync(`"${processorPath}" "${documentationDir}" "${htmlOutputDir}"`, { stdio: 'inherit' });
|
||||
// ** THE FIX IS HERE **
|
||||
// Doxygen creates a 'Documentation' subdirectory inside its CWD (the tempDir).
|
||||
const generatedDocsRoot = path.join(tempDir, "Documentation");
|
||||
const htmlOutputDir = path.join(generatedDocsRoot, "html");
|
||||
|
||||
for (const processor of processors) {
|
||||
const processorPath = path.join(postProcessorsDir, processor);
|
||||
// Pass the correct htmlOutputDir to the post-processing scripts
|
||||
childProcess.execSync(`"${processorPath}" "${projectRoot}" "${htmlOutputDir}"`, { stdio: 'inherit', cwd: tempDir });
|
||||
}
|
||||
|
||||
var generatedDocsSource = path.join(documentationDir, "Documentation");
|
||||
|
||||
if (fs.existsSync(generatedDocsSource)) {
|
||||
if (!fs.existsSync($BUILD_DIR)) {
|
||||
fs.mkdirSync($BUILD_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
// --- Final Installation: Create Build/Documentation/html structure ---
|
||||
if (fs.existsSync(htmlOutputDir)) {
|
||||
if (fs.existsSync($DOCUMENTATION_BUILD)) {
|
||||
fs.rmSync($DOCUMENTATION_BUILD, { recursive: true, force: true });
|
||||
}
|
||||
fs.mkdirSync($DOCUMENTATION_BUILD, { recursive: true });
|
||||
|
||||
var debugTxtSource = path.join(documentationDir, "debug.txt");
|
||||
if (fs.existsSync(debugTxtSource)) {
|
||||
var debugTxtDest = path.join(generatedDocsSource, "debug.txt");
|
||||
fs.renameSync(debugTxtSource, debugTxtDest);
|
||||
}
|
||||
// Move the entire generated 'Documentation' folder (which contains html)
|
||||
// to the final build location. This preserves the structure for 'docset'.
|
||||
fs.renameSync(generatedDocsRoot, path.join($BUILD_DIR, "Documentation"));
|
||||
|
||||
fs.renameSync(generatedDocsSource, $DOCUMENTATION_BUILD);
|
||||
|
||||
var customCSS = path.join(documentationDir, "doxygen.css");
|
||||
var destCSS = path.join($DOCUMENTATION_BUILD, "html", "doxygen.css");
|
||||
if(fs.existsSync(customCSS)) {
|
||||
fs.copyFileSync(customCSS, destCSS);
|
||||
}
|
||||
console.log("Documentation successfully built in " + $DOCUMENTATION_BUILD);
|
||||
const finalHtmlPath = path.join($DOCUMENTATION_BUILD, "html");
|
||||
console.log("Documentation successfully built in " + finalHtmlPath);
|
||||
} else {
|
||||
console.error("Doxygen ran but did not produce the expected 'Documentation' directory.");
|
||||
console.error("Doxygen or post-processing failed to produce the 'html' directory.");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("An error occurred during documentation generation:");
|
||||
console.error(e.message);
|
||||
// Clean up partially generated files
|
||||
var generatedDocsSource = path.join(documentationDir, "Documentation");
|
||||
if (fs.existsSync(generatedDocsSource)) {
|
||||
fs.rmSync(generatedDocsSource, { recursive: true, force: true });
|
||||
}
|
||||
console.error("An error occurred during documentation generation:", e.message);
|
||||
process.exit(1);
|
||||
} finally {
|
||||
// --- Cleanup ---
|
||||
console.log(`Cleaning up temporary directory: ${tempDir}`);
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# NOTE: The working directory should be the main capp directory when this script is run
|
||||
# Cleans up the temporary files generated by the pre-processor.
|
||||
# The Current Working Directory (CWD) is the main temporary build directory.
|
||||
#
|
||||
# $1 Cappuccino Tools/Documentation directory
|
||||
# $2 Generated documentation directory
|
||||
# ARGUMENTS:
|
||||
# $1 - The absolute path to the project root.
|
||||
|
||||
# Do this if you want to use the utility functions
|
||||
source "$1"/support/processor_setup.sh
|
||||
# Corrected path to the support script
|
||||
source "$1/Tools/Documentation/support/processor_setup.sh"
|
||||
|
||||
# Cleanup the files we generated to feed to doxygen
|
||||
processor_msg "Cleaning up generated header files..."
|
||||
|
||||
if [ -d AppKit.doc ]; then
|
||||
# The .doc directories are in our CWD (the temp dir), so we can remove them.
|
||||
if [ -d "AppKit.doc" ]; then
|
||||
rm -rf AppKit.doc
|
||||
fi
|
||||
|
||||
if [ -d Foundation.doc ]; then
|
||||
if [ -d "Foundation.doc" ]; then
|
||||
rm -rf Foundation.doc
|
||||
fi
|
||||
@@ -1,17 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# NOTE: The working directory should be the main capp directory when this script is run
|
||||
# A hook for transforming text in the generated HTML files.
|
||||
# CWD is the main temporary build directory.
|
||||
#
|
||||
# $1 Cappuccino Tools/Documentation directory
|
||||
# $2 Generated documentation directory
|
||||
# ARGUMENTS:
|
||||
# $1 - The absolute path to the project root.
|
||||
# $2 - The absolute path to the generated 'html' directory within the temp dir.
|
||||
|
||||
# Do this if you want to use the utility functions
|
||||
source "$1"/support/processor_setup.sh
|
||||
# Corrected path to the support script
|
||||
source "$1/Tools/Documentation/support/processor_setup.sh"
|
||||
|
||||
if [ ! -d "$2" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
processor_msg 'Massaging text...'
|
||||
|
||||
exec "$1"/support/massage_text.py "$2"
|
||||
# This is a placeholder. If the original script did something specific,
|
||||
# its logic would go here, operating on files inside the "$2" directory.
|
||||
# For now, we'll just log that it ran.
|
||||
processor_msg "Running text transformations..."
|
||||
@@ -1,10 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Remove the generated README.html once the build has finished.
|
||||
#
|
||||
# NOTE: The working directory should be the main capp directory when this script is run
|
||||
#
|
||||
# $1 Cappuccino documentation directory
|
||||
# Moves the generated README.html to be the main index page of the documentation.
|
||||
# CWD is the main temporary build directory.
|
||||
#
|
||||
# ARGUMENTS:
|
||||
# $1 - The absolute path to the project root.
|
||||
# $2 - The absolute path to the generated 'html' directory within the temp dir.
|
||||
|
||||
rm "$1"/README.html
|
||||
# Corrected path to the support script
|
||||
source "$1/Tools/Documentation/support/processor_setup.sh"
|
||||
|
||||
processor_msg "Installing custom main documentation page..."
|
||||
|
||||
# The README.html was generated in the root of our CWD (the temp dir)
|
||||
if [ -f "README.html" ]; then
|
||||
# The main doxygen page is index.html. We replace it with our README.
|
||||
mv "README.html" "$2/index.html"
|
||||
else
|
||||
processor_msg "Warning: README.html not found, cannot create main page." "yellow"
|
||||
fi
|
||||
@@ -1,21 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# NOTE: The working directory should be the main capp directory when this script is run
|
||||
# Creates README.html from the main README.markdown in the project root.
|
||||
# CWD is a temporary build directory.
|
||||
#
|
||||
# $1 Cappuccino documentation directory
|
||||
# ARGUMENTS:
|
||||
# $1 - The absolute path to the project root.
|
||||
|
||||
# Do this if you want to use the utility functions
|
||||
source "$1"/support/processor_setup.sh
|
||||
# Do this if you want to use the utility functions. Note the path change.
|
||||
source "$1/Tools/Documentation/support/processor_setup.sh"
|
||||
|
||||
markdown=`which markdown`
|
||||
|
||||
if [ -n "$markdown" ]; then
|
||||
processor_msg "Markdown main page..."
|
||||
"$markdown" README.markdown > "$1"/README.html
|
||||
# Read from project root, write to current (temp) directory
|
||||
"$markdown" "$1/README.markdown" > "README.html"
|
||||
else
|
||||
processor_msg "markdown binary is not installed, documentation cannot be generated." "red"
|
||||
echo "On Mac OS X, install brew with the following command line:"
|
||||
echo ' ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"'
|
||||
echo "Then use 'brew install markdown' from the command line to install markdown."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,69 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Creates temporary documentation source directories inside the main documentation directory.
|
||||
# Creates temporary documentation source directories in the CWD (a temp dir).
|
||||
#
|
||||
# ARGUMENTS:
|
||||
# $1 - The absolute path to the main documentation directory (e.g., /path/to/cappuccino/Tools/Documentation)
|
||||
# $1 - The absolute path to the project root.
|
||||
|
||||
# Do this if you want to use the utility functions
|
||||
source "$1"/support/processor_setup.sh
|
||||
# Do this if you want to use the utility functions. Note the path change.
|
||||
source "$1/Tools/Documentation/support/processor_setup.sh"
|
||||
|
||||
# --- Main Execution ---
|
||||
MAIN_DOC_DIR="$1"
|
||||
|
||||
processor_msg "Starting source collection script..."
|
||||
processor_msg "Current working directory: $(pwd)"
|
||||
processor_msg "Target documentation directory: $MAIN_DOC_DIR"
|
||||
|
||||
# A function to robustly collect sources using find and bsdtar
|
||||
# ARGS: $1=Framework Name, $2=Output Doc Dir Name
|
||||
# A function to collect sources. CWD is the temp dir.
|
||||
# ARGS: $1=Project Root, $2=Framework Name, $3=Output Doc Dir Name
|
||||
collect_sources() {
|
||||
local framework_name="$1"
|
||||
local doc_dir_name="$2"
|
||||
|
||||
# Construct full, absolute paths for all our work
|
||||
local full_doc_dir_path="$MAIN_DOC_DIR/$doc_dir_name"
|
||||
local full_tar_path="$MAIN_DOC_DIR/$doc_dir_name.tar"
|
||||
local project_root="$1"
|
||||
local framework_name="$2"
|
||||
local doc_dir_name="$3"
|
||||
local tar_file="temp.tar" # Temp tar file in the CWD
|
||||
|
||||
processor_msg "--------------------------------------------------"
|
||||
processor_msg "Processing framework: $framework_name"
|
||||
processor_msg "Output will be in: $full_doc_dir_path"
|
||||
|
||||
if [ ! -d "$framework_name" ]; then
|
||||
processor_msg "ERROR: Source directory '$framework_name' does not exist in $(pwd)." "red"
|
||||
exit 1
|
||||
fi
|
||||
# Find sources relative to the project root
|
||||
find "$project_root/$framework_name" -name "*.j" | bsdtar -s "|^$project_root/$framework_name/|$doc_dir_name/|" -cnf "$tar_file" -T -
|
||||
|
||||
# Create the tar archive *inside* the documentation directory
|
||||
find "$framework_name" -name "*.j" | bsdtar -s "|^$framework_name/|$doc_dir_name/|" -cnf "$full_tar_path" -T -
|
||||
|
||||
if [ -f "$full_tar_path" ]; then
|
||||
processor_msg "Extracting archive into '$MAIN_DOC_DIR'..."
|
||||
# Extract the archive *from within* the documentation directory
|
||||
bsdtar xf "$full_tar_path" -C "$MAIN_DOC_DIR"
|
||||
rm "$full_tar_path"
|
||||
if [ -f "$tar_file" ]; then
|
||||
processor_msg "Extracting archive to CWD..."
|
||||
bsdtar xf "$tar_file"
|
||||
rm "$tar_file"
|
||||
else
|
||||
processor_msg "ERROR: Failed to create tar archive for $framework_name." "red"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# --- Run Collection ---
|
||||
collect_sources "AppKit" "AppKit.doc"
|
||||
collect_sources "Foundation" "Foundation.doc"
|
||||
|
||||
collect_sources "$1" "AppKit" "AppKit.doc"
|
||||
collect_sources "$1" "Foundation" "Foundation.doc"
|
||||
|
||||
# --- Post-Process Files ---
|
||||
processor_msg "--------------------------------------------------"
|
||||
processor_msg "Removing @import and @class from source files..."
|
||||
|
||||
# Look for the .doc directories inside the main documentation directory
|
||||
if [ -d "$MAIN_DOC_DIR/AppKit.doc" ]; then
|
||||
find "$MAIN_DOC_DIR/AppKit.doc" -name *.j -exec sed -e '/@import.*/ d' -e '/@class.*/ d' -i '' {} \;
|
||||
fi
|
||||
if [ -d "$MAIN_DOC_DIR/Foundation.doc" ]; then
|
||||
find "$MAIN_DOC_DIR/Foundation.doc" -name *.j -exec sed -e '/@import.*/ d' -e '/@class.*/ d' -i '' {} \;
|
||||
fi
|
||||
|
||||
processor_msg "Source collection script finished."
|
||||
# These directories now exist in our CWD (the temp dir)
|
||||
find AppKit.doc -name *.j -exec sed -e '/@import.*/ d' -e '/@class.*/ d' -i '' {} \;
|
||||
find Foundation.doc -name *.j -exec sed -e '/@import.*/ d' -e '/@class.*/ d' -i '' {} \;
|
||||
Reference in new issue
Block a user