The browser code snippets can possibly be execute-able in-place.
I found a small number of minor issues in the backend snippets. One solution to this is to put these into separate files, ensure each snippet is correct, and embed it here. I think both docusorus, and more importantly mkdoc (used in the future papermoon website) should have support for this.
Some ideas around https://contracts.polkadot.io/getting-started-with-ethers.js/