Generate the codebase metrics page from a committed script

Adds a committed generator that produces docs/metrics.md from measured data, and regenerates the page. See #3608539.

  • scripts/generate-metrics.php reads the per-file JSON from cloc on stdin and writes docs/metrics.md (prose, tables and inline SVG charts) from documented counting rules. Every number and bar is derived; nothing on the page is hand-maintained.
  • docs/metrics.md regenerated from current 1.x. The per-submodule breakdown now sums exactly to the totals (the hand-made page left a small remainder), services count definitions only (aliases excluded), and plugins are counted by class.

Security: the script executes no commands (no shell_exec/exec/system/passthru/proc_open/popen/eval), refuses to run outside the CLI, discovers files 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.

Usage:

cloc --exclude-dir=node_modules --by-file --json --quiet . | php scripts/generate-metrics.php

Verified locally: php -l, phpcs (Drupal, DrupalPractice) and cspell all clean.

Merge request reports

Loading