@@ -0,0 +1,1865 @@
+import codecs%0Afrom os import path%0A%0Afrom docutils.io import StringOutput%0A%0Afrom sphinx.util.console import bold, darkgreen, brown%0Afrom sphinx.util.nodes import inline_all_toctrees%0Afrom sphinx.util.osutil import ensuredir, os_path%0Afrom sphinx.builders.text import TextBuilder%0Afrom sphinx.writers.text import TextWriter, TextTranslator%0A%0Aclass SingleFileTextTranslator(TextTranslator):%0A    def visit_start_of_file(self, node):%0A        pass%0A    def depart_start_of_file(self, node):%0A        pass%0A%0Aclass SingleFileTextWriter(TextWriter):%0A    def translate(self):%0A        visitor = SingleFileTextTranslator(self.document, self.builder)%0A        self.document.walkabout(visitor)%0A        self.output = visitor.body%0A%0Aclass SingleFileTextBuilder(TextBuilder):%0A    %22%22%22%0A    A TextBuilder subclass that puts the whole document tree in one text file.%0A    %22%22%22%0A    name = 'singletext'%0A    copysource = False%0A%0A    def get_outdated_docs(self):%0A        return 'all documents'%0A%0A    def assemble_doctree(self):%0A        master = self.config.master_doc%0A        tree = self.env.get_doctree(master)%0A        tree = inline_all_toctrees(self, set(), master, tree, darkgreen)%0A        tree%5B'docname'%5D = master%0A        self.env.resolve_references(tree, master, self)%0A        return tree%0A%0A    def prepare_writing(self, docnames):%0A        self.writer = SingleFileTextWriter(self)%0A%0A    def write(self, *ignored):%0A        docnames = self.env.all_docs%0A%0A        self.info(bold('preparing documents... '), nonl=True)%0A        self.prepare_writing(docnames)%0A        self.info('done')%0A%0A        self.info(bold('assembling single document... '), nonl=True)%0A        doctree = self.assemble_doctree()%0A        self.info()%0A        self.info(bold('writing... '), nonl=True)%0A        self.write_doc(self.config.master_doc, doctree)%0A        self.info('done')%0A%0Adef setup(app):%0A    app.add_builder(SingleFileTextBuilder)%0A

Create singletext.py