add writedoc for rst/markdown, mv latex to writedoc