fix doc example cache path
This commit is contained in:
parent
4eda629c8d
commit
c0f3c5507c
@ -45,9 +45,14 @@ void render_doc_params(StringList param_lines)
|
|||||||
?></div></>
|
?></div></>
|
||||||
}
|
}
|
||||||
|
|
||||||
String doc_example_path(String page, u64 idx)
|
String doc_example_path(Request& context, String page, u64 idx)
|
||||||
{
|
{
|
||||||
return("examples/_gen/" + page + "_" + std::to_string(idx + 1) + ".uce");
|
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)
|
String doc_example_unit_source(String body)
|
||||||
@ -62,9 +67,11 @@ bool doc_write_if_changed(String path, String content)
|
|||||||
return(file_put_contents(path, content));
|
return(file_put_contents(path, content));
|
||||||
}
|
}
|
||||||
|
|
||||||
String doc_render_example_output(String page, u64 idx, String body)
|
String doc_render_example_output(Request& context, String page, u64 idx, String body)
|
||||||
{
|
{
|
||||||
String path = doc_example_path(page, idx);
|
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);
|
String unit_source = doc_example_unit_source(body);
|
||||||
if(!doc_write_if_changed(path, unit_source))
|
if(!doc_write_if_changed(path, unit_source))
|
||||||
return("DOC EXAMPLE ERROR: could not write " + path);
|
return("DOC EXAMPLE ERROR: could not write " + path);
|
||||||
@ -79,12 +86,12 @@ String doc_render_example_output(String page, u64 idx, String body)
|
|||||||
return(out);
|
return(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_doc_examples(String page, StringList example_blocks)
|
void render_doc_examples(Request& context, String page, StringList example_blocks)
|
||||||
{
|
{
|
||||||
for(u64 idx = 0; idx < example_blocks.size(); idx++)
|
for(u64 idx = 0; idx < example_blocks.size(); idx++)
|
||||||
{
|
{
|
||||||
String body = example_blocks[idx];
|
String body = example_blocks[idx];
|
||||||
String output = doc_render_example_output(page, idx, body);
|
String output = doc_render_example_output(context, page, idx, body);
|
||||||
?><div class="doc-section example">
|
?><div class="doc-section example">
|
||||||
<h3>Example</h3>
|
<h3>Example</h3>
|
||||||
<pre class="example-source"><?= body ?></pre>
|
<pre class="example-source"><?= body ?></pre>
|
||||||
@ -276,7 +283,7 @@ RENDER(Request& context)
|
|||||||
?><div class="doc-section content"><?: markdown_to_html(doc_page.content) ?></div><?
|
?><div class="doc-section content"><?: markdown_to_html(doc_page.content) ?></div><?
|
||||||
}
|
}
|
||||||
|
|
||||||
render_doc_examples(page, doc_page.example_blocks);
|
render_doc_examples(context, page, doc_page.example_blocks);
|
||||||
|
|
||||||
?></article><?
|
?></article><?
|
||||||
|
|
||||||
|
|||||||
@ -340,6 +340,9 @@ u64 request_seed_from_time(f64 time_value)
|
|||||||
|
|
||||||
void prepare_request_body_maps(Request& request)
|
void prepare_request_body_maps(Request& request)
|
||||||
{
|
{
|
||||||
|
if(request.server)
|
||||||
|
request.params["UCE_BIN_DIRECTORY"] = request.server->config["BIN_DIRECTORY"];
|
||||||
|
|
||||||
String route_path;
|
String route_path;
|
||||||
request.get = parse_query(request.params["QUERY_STRING"], &route_path);
|
request.get = parse_query(request.params["QUERY_STRING"], &route_path);
|
||||||
request_populate_context_params_from_route(request, route_path);
|
request_populate_context_params_from_route(request, route_path);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user