diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..7381822 Binary files /dev/null and b/.DS_Store differ diff --git a/.github/.DS_Store b/.github/.DS_Store new file mode 100644 index 0000000..dc3dc1a Binary files /dev/null and b/.github/.DS_Store differ diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 0000000..4a64060 --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,46 @@ +name: Update Documentation + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' # Run daily at midnight + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + extensions: dom, curl, json + + - name: Clone MainWP repositories + run: | + mkdir -p source + git clone https://github.com/mainwp/mainwp.git source/mainwp + git clone https://github.com/mainwp/mainwp-child.git source/mainwp-child + + - name: Install code-reference + run: | + mkdir -p tools + git clone https://github.com/woocommerce/code-reference.git tools/code-reference + cd tools/code-reference + composer install + + - name: Build documentation + run: | + ./build.sh + + - name: Commit and push changes + run: | + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + git add docs + git commit -m "Update documentation" || echo "No changes to commit" + git push \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f8ea5a --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Ignore temporary build files +tools/code-reference/build/ + +# Ignore composer files in tools +tools/code-reference/vendor/ +tools/code-reference/composer.lock + +# Ignore source repositories (we don't want to commit these to mainwp.dev) +source/mainwp/.git/ +source/mainwp-child/.git/ \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..64e11fe --- /dev/null +++ b/build.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Directory setup - all relative to the script location +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CODE_REF_DIR="$SCRIPT_DIR/tools/code-reference" +MAINWP_DIR="$SCRIPT_DIR/source/mainwp" +MAINWP_CHILD_DIR="$SCRIPT_DIR/source/mainwp-child" +OUTPUT_DIR="$SCRIPT_DIR/code-docs" + +# Create output directory if it doesn't exist +mkdir -p "$OUTPUT_DIR" + +# Function to build documentation for a repo +build_docs() { + REPO_NAME=$1 + REPO_PATH=$2 + IGNORE_PATTERNS=$3 + + echo "Building documentation for $REPO_NAME..." + + # Navigate to code reference tool + cd "$CODE_REF_DIR" + + # Update phpdoc.xml to point to the correct repository + sed -i '' "s|.*|$REPO_PATH|" phpdoc.xml + + # Update ignore patterns if provided + if [ ! -z "$IGNORE_PATTERNS" ]; then + # Remove existing ignore-patterns section + sed -i '' '//,/<\/ignore-patterns>/d' phpdoc.xml || true + + # Add new ignore-patterns section before the closing tag + sed -i '' "s||\n$IGNORE_PATTERNS\n\n|" phpdoc.xml + fi + + # Build the documentation - using a placeholder version since we're not downloading + ./deploy.sh --source-version "1.0.0" --github-repo "mainwp/$REPO_NAME" --build-only --no-download + + # Copy the built files to the output directory + if [ -d "$CODE_REF_DIR/build/api" ]; then + echo "Copying files to $OUTPUT_DIR/$REPO_NAME" + mkdir -p "$OUTPUT_DIR/$REPO_NAME" + cp -R "$CODE_REF_DIR/build/api/"* "$OUTPUT_DIR/$REPO_NAME/" + else + echo "Error: Build directory not found" + exit 1 + fi +} + +# Define ignore patterns for each repository +MAINWP_IGNORES="*/tests/*\n*/node_modules/*\n*/vendor/*" +MAINWP_CHILD_IGNORES="*/tests/*\n*/node_modules/*\n*/vendor/*\n*/assets/*\n*/libs/external/*" + +# Update repositories to the latest version +echo "Updating MainWP repositories..." +cd "$MAINWP_DIR" && git pull origin master +cd "$MAINWP_CHILD_DIR" && git pull origin master + +# Build documentation for MainWP Dashboard +build_docs "mainwp" "$MAINWP_DIR" "$MAINWP_IGNORES" + +# Build documentation for MainWP Child +build_docs "mainwp-child" "$MAINWP_CHILD_DIR" "$MAINWP_CHILD_IGNORES" + +# Commit changes to mainwp.dev +cd "$SCRIPT_DIR" +git add . +git commit -m "Update code reference documentation" +git push origin main + +echo "Documentation build complete!" \ No newline at end of file diff --git a/source/.DS_Store b/source/.DS_Store new file mode 100644 index 0000000..f2d8f07 Binary files /dev/null and b/source/.DS_Store differ diff --git a/source/mainwp b/source/mainwp new file mode 160000 index 0000000..f573279 --- /dev/null +++ b/source/mainwp @@ -0,0 +1 @@ +Subproject commit f573279fef7feb371c0d94d3df9da3c19aba00cc diff --git a/source/mainwp-child b/source/mainwp-child new file mode 160000 index 0000000..52b8e66 --- /dev/null +++ b/source/mainwp-child @@ -0,0 +1 @@ +Subproject commit 52b8e66a5f89ff2291d7d2da6313f21d851d2b32 diff --git a/tools/.DS_Store b/tools/.DS_Store new file mode 100644 index 0000000..28b436e Binary files /dev/null and b/tools/.DS_Store differ diff --git a/tools/code-reference b/tools/code-reference new file mode 160000 index 0000000..af0f472 --- /dev/null +++ b/tools/code-reference @@ -0,0 +1 @@ +Subproject commit af0f472c5196c19e181e27eb80fe7cded668da6e