def render(library, docname, data, realpath, out_dir, generate_pdf): out = os.path.join(out_dir, docname + ".html") html_contents = render_complete( library=library, s=data, raise_errors=True, realpath=realpath, generate_pdf=generate_pdf ) doc = get_minimal_document(html_contents, add_markdown_css=True) d = os.path.dirname(out) if not os.path.exists(d): os.makedirs(d) with open(out, "w") as f: f.write(doc) logger.info("Written %s " % out)
def render(libname, docname, generate_pdf): librarian = get_test_librarian() library = librarian.load_library('manual') d = tempfile.mkdtemp() library.use_cache_dir(d) l = library.load_library(libname) basename = docname + '.' + MCDPLibrary.ext_doc_md f = l._get_file_data(basename) data = f['data'] realpath = f['realpath'] html_contents = render_complete(library=l, s=data, raise_errors=True, realpath=realpath, generate_pdf=generate_pdf) doc = get_minimal_document(html_contents, add_markdown_css=True) return ((libname, docname), doc)
def check_rendering(libname, filename): library = get_test_library(libname) import codecs data = codecs.open(filename, encoding='utf-8').read().encode('utf-8') tmpdir = tempfile.mkdtemp(prefix='mcdplibrary_cache') library.use_cache_dir(tmpdir) contents = render_complete(library, data, raise_errors=True, realpath=filename) html = get_minimal_document(contents, add_markdown_css=True) basename = os.path.basename(filename) fn = os.path.join('out', 'check_rendering', libname, basename + '.html') d = os.path.dirname(fn) if not os.path.exists(d): os.makedirs(d) with open(fn, 'w') as f: f.write(html) print('written to %r ' % fn) shutil.rmtree(tmpdir)