doc update

This commit is contained in:
udo
2022-04-18 23:37:21 +00:00
parent defc628204
commit 364d83b199
17 changed files with 482 additions and 120 deletions
+5 -1
View File
@@ -1,6 +1,10 @@
Output Buffer Functions
Output / Invocation Functions
call_file
load
ob_clear
ob_get
ob_get_clear
ob_start
print
render_file
+2
View File
@@ -1,9 +1,11 @@
String Functions
concat
filter
first
join
nibble
print
split
split_space
split_utf8
+1 -1
View File
@@ -11,7 +11,7 @@ void render_see_section(String name)
}
else if(line != "")
{
<><li><a href="index.uce?p=<?= line ?>"><?= line ?><span style="opacity:0.5">()</span></a></li></>
<><li><a href="index.uce?p=<?= uri_encode(line) ?>"><?= line ?><span style="opacity:0.5">()</span></a></li></>
}
idx += 1;
}
+23
View File
@@ -0,0 +1,23 @@
:sig
DTree* call_file(String file_name, String function_name, DTree* call_param = null)
:params
file_name : UCE file to load and execute
function_name : name of the function to invoke
call_param : optional, call parameter
return value : DTree* returned from function
:desc
Calls a function inside a UCE file.
:Example
// export a function
EXPORT void test_func()
{
print("HELLO FROM TEST FUNCTION");
}
// use that function in another file
call_file("call_file_funcs.uce", "test_func");
:see
>ob
+11
View File
@@ -0,0 +1,11 @@
:sig
String concat(...vals)
:params
...val : one or more values that should be concatenated
:desc
Returns a string with all the parameters concatenated into one.
:see
>string
@@ -7,3 +7,5 @@ file name : name of an UCE file that should be included
:desc
Includes another UCE file
:see
>ob
+2 -1
View File
@@ -7,4 +7,5 @@ void print(...val)
:desc
Appends data to the current request's output stream.
:see
>string
+16
View File
@@ -0,0 +1,16 @@
:sig
void render_file(String file_name, DTree& call_param = null)
:params
file_name : UCE file to load and execute
call_param : optional, call parameter
:desc
Calls another UCE file and executes its RENDER() function.
:Example
// call a common page template
render_file("page-template.uce");
:see
>ob
+142
View File
@@ -0,0 +1,142 @@
StringMap* already_shown_items;
void render_doc_page(String page)
{
(*already_shown_items)[page] = "Y";
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
String layout_class = "text";
u32 line_idx = 0;
for(auto s : doc)
{
line_idx++;
if(s == "")
{
}
else if(s.substr(0, 1) == ":")
{
layout_class = s.substr(1);
if(line_idx > 1)
{
<></div></>
}
<><div class="<?= layout_class ?>"></>
if(layout_class == "params")
{
<><h3>Parameters</h3></>
}
else if(layout_class == "sig")
{
String page_name = page;
if(page[1] == '_')
{
nibble(page_name, "_");
}
<><h2><?= page_name ?></h2></>
}
else if(layout_class == "pre")
{
layout_class = "sig";
}
else if(layout_class == "desc")
{
<><h3>Description</h3></>
}
else if(layout_class == "see")
{
}
else
{
<><h3><?= layout_class ?></h3></>
}
}
else
{
if(s.substr(0, 1) == "-")
{
nibble(s, "-");
<><li><?= (s) ?></li></>
}
else if(layout_class == "sig")
{
<><pre><? print(s); ?></pre></>
}
else if(layout_class == "params")
{
<><div><b><?= trim(nibble(s, ":")) ?></b> : <?= trim(s) ?></div></>
}
else if(layout_class == "see")
{
if(s[0] == '>')
{
//render_see_section(s.substr(1));
}
else
{
<><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div></>
}
}
else
{
<><div><? print(s); ?></div></>
}
}
}
}
void render_see_section(String name)
{
StringList lines = split(file_get_contents("areas/"+name+".txt"), "\n");
s32 idx = 0;
for(auto line : lines)
{
if(idx == 0)
{
<><h1><?= line ?></h1></>
}
else if(line != "")
{
render_doc_page(line);
}
idx += 1;
}
}
RENDER()
{
already_shown_items = new StringMap();
String page = first(context->get["p"], "index");
<><html>
<head>
<!--<link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>-->
</head>
<body>
<h1>
UCE API
</h1>
<?
for(auto file_name : ls("areas/"))
{
String ft = nibble(file_name, ".");
render_see_section(ft);
}
?><h1>Other Functions and Data Structures</h1><?
for(auto file_name : ls("pages/"))
{
String ft = nibble(file_name, ".");
if((*already_shown_items)[ft] == "")
render_doc_page(ft);
}
?>
</body>
</html></>
}