#include "lib/doc_page.h" void render_doc_page_link(String page, String label = "", String badge = "") { page = trim(page); if(page == "") return; if(label == "") label = doc_index_label(page); if(badge == "") badge = doc_page_kind_badge(doc_page_kind(page)); ?>()

Parameters

:
} String doc_example_path(Request& context, String page, u64 idx) { String bin_dir = context.params["UCE_BIN_DIRECTORY"]; if(bin_dir == "") return(""); String dir = path_join(bin_dir, "doc-examples"); mkdir(dir); return(path_join(dir, page + "_" + std::to_string(idx + 1) + ".uce")); } String doc_example_unit_source(String body) { return("RENDER(Request& context)\n{\n" + body + "\n}\n"); } bool doc_write_if_changed(String path, String content) { if(file_exists(path) && file_get_contents(path) == content) return(true); return(file_put_contents(path, content)); } String doc_render_example_output(Request& context, String page, u64 idx, String body) { String path = doc_example_path(context, page, idx); if(path == "") return("DOC EXAMPLE ERROR: UCE_BIN_DIRECTORY is not available"); String unit_source = doc_example_unit_source(body); if(!doc_write_if_changed(path, unit_source)) return("DOC EXAMPLE ERROR: could not write " + path); if(!unit_compile(path)) return("DOC EXAMPLE ERROR: unit_compile failed for " + path); ob_start(); unit_render(path); String out = ob_get_close(); if(out == "") return("DOC EXAMPLE ERROR: example produced no output"); return(out); } void render_doc_examples(Request& context, String page, StringList example_blocks) { for(u64 idx = 0; idx < example_blocks.size(); idx++) { String body = example_blocks[idx]; String output = doc_render_example_output(context, page, idx, body); ?>

Example

Output

} void render_doc_see_links(StringList see_lines) { if(see_lines.size() == 0) return; <> ') { String target = trim(sl.substr(1)); if(doc_has_area(target)) { render_see_section(target); } else if(doc_has_page(target)) { ?>
} RENDER(Request& context) { String page = first(context.get["p"], "index"); DocPage doc_page; String page_title = doc_default_title(page); if(page != "index") { doc_page = load_doc_page(page); if(doc_page.title != "") page_title = doc_page.title; } <>

UCE Docs /

All API Functions

} else { String detail_class = "detail-layout"; if(doc_page.see_lines.size() == 0) detail_class += " no-sidebar"; ?>
0) { ?>

Signature

0) { ?>
}