The codebase metrics page (docs/metrics.md) has been maintained by hand, so its numbers and its inline SVG charts drift from the code between refreshes. This adds a committed generator that produces the whole page from measured data, and regenerates the page from it.
What this does
- Adds scripts/generate-metrics.php: it reads the per-file JSON from cloc on stdin and writes docs/metrics.md (prose, tables and inline SVG charts) from a set of documented counting rules. Every number and bar is derived; nothing on the page is hand-maintained.
- Regenerates docs/metrics.md from the current 1.x. The per-submodule breakdown now sums exactly to the totals (the hand-made page left a small unattributed remainder), services count service definitions only (aliases excluded), and plugins are counted by class.
Security
The committed script executes no commands (no shell_exec, exec, system, passthru, proc_open, popen or eval), refuses to run outside the CLI, does all file discovery with native PHP filesystem APIs, and only reads files plus writes the single docs/metrics.md. You run cloc yourself and pipe its JSON in; the script never invokes it.
Usage
From the module root:
cloc --exclude-dir=node_modules --by-file --json --quiet . | php scripts/generate-metrics.phpIssue fork orchestra-3608539
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mably commentedOpened MR !290 against 1.x: adds scripts/generate-metrics.php and regenerates docs/metrics.md from it.
The script executes no commands and is CLI-only; it reads the per-file JSON from cloc on stdin and writes the single docs/metrics.md, discovering files with native PHP. Verified locally: php -l, phpcs and cspell all clean. Setting to Needs review pending CI.
Comment #5
mably commented