From 968b3acbceeed16e1b25e005874b7e1722fc9863 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 29 May 2024 13:53:08 +0800 Subject: [PATCH] Add gen-ext-docs command (#462) --- .github/workflows/update-docs-config.yml | 33 +- config/ext.json | 283 ++++++++++++++++++ src/SPC/ConsoleApplication.php | 4 +- src/SPC/command/dev/GenerateExtDocCommand.php | 80 +++++ 4 files changed, 395 insertions(+), 5 deletions(-) create mode 100644 src/SPC/command/dev/GenerateExtDocCommand.php diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index d29b7960c..d3687b42f 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -15,9 +15,6 @@ jobs: steps: - name: "Checkout static-php-cli" uses: actions/checkout@v4 - with: - ref: main - path: static-php-cli - name: "Checkout static-php-cli-docs" uses: actions/checkout@v4 @@ -33,7 +30,35 @@ jobs: git config --global user.name "GitHub Actions" - name: "Copy Config Files" - run: cp -r static-php-cli/config/* static-php-cli-docs/docs/.vitepress/config/ + run: cp -r config/* static-php-cli-docs/docs/.vitepress/config/ + + - name: "Install PHP for official runners" + uses: "shivammathur/setup-php@v2" + with: + coverage: none + tools: composer:v2 + php-version: 8.2 + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v4" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-8.2-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-8.2-locked-composer + + - name: "Install Locked Dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Generate Extension Support List" + run: | + bin/spc dev:gen-ext-docs > static-php-cli-docs/docs/extensions.md - name: "Commit and Push Changes" run: | diff --git a/config/ext.json b/config/ext.json index f3529fc2c..2ac53d090 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1,5 +1,8 @@ { "amqp": { + "support": { + "BSD": "wip" + }, "type": "external", "arg-type": "custom", "source": "amqp", @@ -18,6 +21,9 @@ "type": "builtin" }, "bz2": { + "support": { + "Windows": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -31,6 +37,7 @@ "type": "builtin" }, "curl": { + "notes": true, "type": "builtin", "arg-type": "with", "lib-depends": [ @@ -49,6 +56,9 @@ ] }, "dom": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -64,7 +74,21 @@ "type": "external", "source": "ext-ds" }, + "enchant": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "wip", + "Linux": "wip" + }, + "type": "wip" + }, "event": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "ext-event", "arg-type": "custom", @@ -82,6 +106,11 @@ "type": "builtin" }, "ffi": { + "support": { + "Linux": "no", + "BSD": "wip" + }, + "notes": true, "arg-type": "custom", "type": "builtin", "lib-depends-unix": [ @@ -104,6 +133,11 @@ ] }, "gd": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -122,6 +156,10 @@ ] }, "gettext": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -129,6 +167,12 @@ ] }, "glfw": { + "support": { + "Windows": "wip", + "BSD": "no", + "Linux": "no" + }, + "notes": true, "type": "external", "arg-type": "custom", "source": "ext-glfw", @@ -138,6 +182,10 @@ "lib-depends-windows": [] }, "gmp": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -145,6 +193,9 @@ ] }, "iconv": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "with", @@ -156,10 +207,18 @@ ] }, "igbinary": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "igbinary" }, "imagick": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-imagick", "arg-type": "custom", @@ -168,6 +227,11 @@ ] }, "imap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -178,16 +242,29 @@ ] }, "inotify": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "no" + }, "type": "external", "source": "inotify" }, "intl": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "lib-depends": [ "icu" ] }, "ldap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -215,7 +292,21 @@ "type": "builtin", "arg-type": "custom" }, + "mcrypt": { + "type": "wip", + "support": { + "Windows": "no", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "memcache": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-memcache", "arg-type": "custom", @@ -227,6 +318,11 @@ ] }, "memcached": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Linux": "no" + }, "type": "external", "source": "memcached", "arg-type": "custom", @@ -240,6 +336,12 @@ ] }, "mongodb": { + "support": { + "Darwin": "no", + "BSD": "wip", + "Windows": "wip" + }, + "notes": true, "type": "external", "source": "mongodb", "arg-type": "custom", @@ -264,11 +366,22 @@ "zlib" ] }, + "oci8": { + "type": "wip", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "opcache": { "type": "builtin", "arg-type": "custom" }, "openssl": { + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -281,6 +394,10 @@ ] }, "parallel": { + "support": { + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "parallel", "arg-type-windows": "with", @@ -289,6 +406,11 @@ ] }, "password-argon2": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -296,6 +418,9 @@ ] }, "pcntl": { + "support": { + "Windows": "no" + }, "type": "builtin", "unix-only": true }, @@ -311,6 +436,10 @@ ] }, "pdo_pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "ext-depends": [ @@ -322,6 +451,9 @@ ] }, "pdo_sqlite": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with", "ext-depends": [ @@ -333,6 +465,10 @@ ] }, "pdo_sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "pdo_sqlsrv", "arg-type": "with", @@ -342,6 +478,11 @@ ] }, "pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -355,19 +496,36 @@ ] }, "posix": { + "support": { + "Windows": "no" + }, "type": "builtin", "unix-only": true }, "protobuf": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "protobuf" }, "rar": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, "type": "external", "source": "rar", "cpp-extension": true }, "readline": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -375,6 +533,10 @@ ] }, "redis": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "redis", "arg-type": "custom", @@ -399,6 +561,9 @@ "cpp-extension": true }, "simplexml": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -409,6 +574,10 @@ ] }, "snappy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-snappy", "cpp-extension": true, @@ -421,6 +590,9 @@ ] }, "soap": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -434,6 +606,10 @@ "type": "builtin" }, "sodium": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with", "lib-depends": [ @@ -441,6 +617,9 @@ ] }, "sqlite3": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "with", @@ -449,6 +628,10 @@ ] }, "sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "sqlsrv", "lib-depends": [ @@ -460,6 +643,9 @@ "cpp-extension": true }, "ssh2": { + "support": { + "BSD": "wip" + }, "type": "external", "source": "ext-ssh2", "arg-type": "with-prefix", @@ -473,6 +659,11 @@ ] }, "swoole": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "swoole", "arg-type": "custom", @@ -495,6 +686,11 @@ ] }, "swoole-hook-mysql": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -507,6 +703,12 @@ ] }, "swoole-hook-pgsql": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -515,6 +717,11 @@ ] }, "swoole-hook-sqlite": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -523,6 +730,11 @@ ] }, "swow": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "swow", "arg-type": "custom", @@ -536,17 +748,32 @@ ] }, "sysvmsg": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "unix-only": true }, "sysvsem": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "unix-only": true }, "sysvshm": { + "support": { + "BSD": "wip" + }, "type": "builtin" }, "tidy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -557,6 +784,10 @@ "type": "builtin" }, "uuid": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-uuid", "arg-type": "with-prefix", @@ -565,6 +796,10 @@ ] }, "uv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-uv", "arg-type": "with-prefix", @@ -575,7 +810,22 @@ "sockets" ] }, + "xdebug": { + "type": "builtin", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "xhprof": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "xhprof", "ext-depends": [ @@ -583,6 +833,10 @@ ] }, "xlswriter": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "xlswriter", "arg-type": "custom", @@ -592,6 +846,10 @@ ] }, "xml": { + "support": { + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -603,6 +861,9 @@ ] }, "xmlreader": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -614,6 +875,9 @@ ] }, "xmlwriter": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -624,6 +888,10 @@ ] }, "xsl": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -635,6 +903,9 @@ ] }, "yac": { + "support": { + "BSD": "wip" + }, "type": "external", "source": "yac", "arg-type-unix": "custom", @@ -643,6 +914,10 @@ ] }, "yaml": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "yaml", "arg-type": "with-prefix", @@ -651,6 +926,10 @@ ] }, "zip": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "enable", @@ -667,6 +946,10 @@ ] }, "zstd": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-zstd", "arg-type": "custom", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index c18856f58..fca4015e9 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -8,6 +8,7 @@ use SPC\command\BuildLibsCommand; use SPC\command\DeleteDownloadCommand; use SPC\command\dev\AllExtCommand; +use SPC\command\dev\GenerateExtDocCommand; use SPC\command\dev\PhpVerCommand; use SPC\command\dev\SortConfigCommand; use SPC\command\DoctorCommand; @@ -24,7 +25,7 @@ */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.1'; + public const VERSION = '2.2.2'; public function __construct() { @@ -48,6 +49,7 @@ public function __construct() new AllExtCommand(), new PhpVerCommand(), new SortConfigCommand(), + new GenerateExtDocCommand(), ] ); } diff --git a/src/SPC/command/dev/GenerateExtDocCommand.php b/src/SPC/command/dev/GenerateExtDocCommand.php new file mode 100644 index 000000000..c53e529d5 --- /dev/null +++ b/src/SPC/command/dev/GenerateExtDocCommand.php @@ -0,0 +1,80 @@ + $ext) { + // notes is optional + $name = ($ext['notes'] ?? false) === true ? "[{$ext_name}](./extension-notes#{$ext_name})" : $ext_name; + // calculate max length + $max_name = max($max_name, strlen($name)); + + // linux + $linux = match ($ext['support']['Linux'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Linux'] ?? 'yes', + }; + $max_linux = max($max_linux, strlen($linux)); + + // macos + $macos = match ($ext['support']['Darwin'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Darwin'] ?? 'yes', + }; + $max_macos = max($max_macos, strlen($macos)); + + // freebsd + $freebsd = match ($ext['support']['BSD'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['BSD'] ?? 'yes', + }; + $max_freebsd = max($max_freebsd, strlen($freebsd)); + + // windows + $windows = match ($ext['support']['Windows'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Windows'] ?? 'yes', + }; + $max_windows = max($max_windows, strlen($windows)); + $md_lines[] = [ + $name, + $linux, + $macos, + $freebsd, + $windows, + ]; + } + + // generate markdown + $md = '| ' . str_pad('Extension Name', $max_name) . ' | ' . str_pad('Linux', $max_linux) . ' | ' . str_pad('macOS', $max_macos) . ' | ' . str_pad('FreeBSD', $max_freebsd) . ' | ' . str_pad('Windows', $max_windows) . ' |' . PHP_EOL; + $md .= '| ' . str_repeat('-', $max_name) . ' | ' . str_repeat('-', $max_linux) . ' | ' . str_repeat('-', $max_macos) . ' | ' . str_repeat('-', $max_freebsd) . ' | ' . str_repeat('-', $max_windows) . ' |' . PHP_EOL; + foreach ($md_lines as $line) { + $md .= '| ' . str_pad($line[0], $max_name) . ' | ' . str_pad($line[1], $max_linux) . ' | ' . str_pad($line[2], $max_macos) . ' | ' . str_pad($line[3], $max_freebsd) . ' | ' . str_pad($line[4], $max_windows) . ' |' . PHP_EOL; + } + $this->output->writeln($md); + return static::SUCCESS; + } +}