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 [[https://github.com/bitcoin/bitcoin/pull/23083 | core#23083]] and [[https://github.com/bitcoin/bitcoin/pull/25161 | core#25161]].