Exemplo n.º 1
0
    def handle(self, *args, **options):
        examples_dir = os.path.join(self.root_dir, EXAMPLES_PATH)
        template_dir = os.path.join(self.root_dir, TEMPLATE_PATH)
        docs_dir = os.path.join(self.root_dir, DOCS_TEMPLATE_PATH)

        with open(os.path.join(template_dir, 'doc_template.txt'), 'r') as fdoc:
            doc_template = template(fdoc.read())

        for src_file in PYTHON_TO_PYCCO:
            source = os.path.join(examples_dir, src_file)
            folder = src_file.split('/')[0]
            outdir = os.path.join(docs_dir, folder)

            with open(source, 'r') as fin:
                sections = parse(source, fin.read())
                highlight(source, sections, outdir=outdir)
                rendered = doc_template({
                    "title": src_file,
                    "sections": sections,
                    "source": source,
                })
                result = re.sub(r"__DOUBLE_OPEN_STACHE__", "{{",
                                rendered).encode("utf-8")
            print destination(source, outdir=outdir)
            with open(destination(source, outdir=outdir), "w") as fout:
                fout.write(result)
Exemplo n.º 2
0
def test_destination(filepath, preserve_paths, outdir):
    dest = p.destination(filepath, preserve_paths=preserve_paths, outdir=outdir)
    assert dest.startswith(outdir)
    assert dest.endswith(".html")
Exemplo n.º 3
0
def test_destination(filepath, preserve_paths, outdir):
    dest = p.destination(filepath,
                         preserve_paths=preserve_paths,
                         outdir=outdir)
    assert dest.startswith(outdir)
    assert dest.endswith(".html")