Update code reference documentation

This commit is contained in:
Dennis Dornon 2025-03-13 14:06:30 -04:00
parent 94434d85c7
commit 17a5d2f741
10 changed files with 130 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
.github/.DS_Store vendored Normal file

Binary file not shown.

46
.github/workflows/update-docs.yml vendored Normal file
View file

@ -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

10
.gitignore vendored Normal file
View file

@ -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/

71
build.sh Executable file
View file

@ -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|<directory>.*</directory>|<directory>$REPO_PATH</directory>|" phpdoc.xml
# Update ignore patterns if provided
if [ ! -z "$IGNORE_PATTERNS" ]; then
# Remove existing ignore-patterns section
sed -i '' '/<ignore-patterns>/,/<\/ignore-patterns>/d' phpdoc.xml || true
# Add new ignore-patterns section before the closing </phpdocumentor> tag
sed -i '' "s|</phpdocumentor>|<ignore-patterns>\n$IGNORE_PATTERNS\n</ignore-patterns>\n</phpdocumentor>|" 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="<ignore>*/tests/*</ignore>\n<ignore>*/node_modules/*</ignore>\n<ignore>*/vendor/*</ignore>"
MAINWP_CHILD_IGNORES="<ignore>*/tests/*</ignore>\n<ignore>*/node_modules/*</ignore>\n<ignore>*/vendor/*</ignore>\n<ignore>*/assets/*</ignore>\n<ignore>*/libs/external/*</ignore>"

# 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!"

BIN
source/.DS_Store vendored Normal file

Binary file not shown.

1
source/mainwp Submodule

@ -0,0 +1 @@
Subproject commit f573279fef7feb371c0d94d3df9da3c19aba00cc

1
source/mainwp-child Submodule

@ -0,0 +1 @@
Subproject commit 52b8e66a5f89ff2291d7d2da6313f21d851d2b32

BIN
tools/.DS_Store vendored Normal file

Binary file not shown.

1
tools/code-reference Submodule

@ -0,0 +1 @@
Subproject commit af0f472c5196c19e181e27eb80fe7cded668da6e