move document generation to document.scala