The specifics may vary from team to team and tool to tool, but this is the broad shape of what this process looks like:
Write docs examples in unit test suites
Excerpt example code for inclusion in docs
Include example code in docs
Run docs tests in CI
In another post, I’ll dive deeper on what your docs code examples and tests should cover. For this topic, I’ll follow a code example from the unit test suite to publishing the docs."