write document to code