Avoid documentation issues by detecting them at runtime, gated by a flag to avoid throwing errors in production for doc issues.
The flag is currently disabled even in tests, where is should be enabled after the current issues have been fixed.
Backport of core#23083 and core#25161.