docgen: Fix escaping again; Make sure the generated code is valid before passing it to sphinx.