cleanup, docs

This commit is contained in:
root
2026-06-16 12:21:31 +00:00
parent dff1959341
commit ea08d5f28b
296 changed files with 1571 additions and 1940 deletions
+51 -32
View File
@@ -5,6 +5,7 @@ struct DocPage {
String content;
StringList sig_lines;
StringList param_lines;
StringList example_blocks;
StringList see_lines;
};
@@ -104,30 +105,69 @@ String doc_index_label(String page)
return(label);
}
void doc_flush_section(DocPage& result, String page, String section, StringList& section_lines, StringList& content_lines)
{
if(section == "")
return;
if(section == "title")
{
String title = trim(join(section_lines, "\n"));
if(title != page)
result.title = title;
}
else if(section == "sig")
{
for(String line : section_lines)
result.sig_lines.push_back(line);
}
else if(section == "params")
{
for(String line : section_lines)
result.param_lines.push_back(line);
}
else if(section == "see")
{
for(String line : section_lines)
{
line = trim(line);
if(line != "")
result.see_lines.push_back(line);
}
}
else if(section == "example")
{
String example = join(section_lines, "\n");
if(trim(example) != "")
result.example_blocks.push_back(example);
}
else
{
for(String line : section_lines)
content_lines.push_back(line);
}
}
DocPage load_doc_page(String page)
{
DocPage result;
StringList lines = split(file_get_contents("pages/" + page + ".txt"), "\n");
String current_section = "";
bool content_mode = false;
StringList current_lines;
StringList content_lines;
for(auto line : lines)
{
if(!content_mode && line != "" && line.substr(0, 1) == ":")
if(line != "" && line.substr(0, 1) == ":")
{
doc_flush_section(result, page, current_section, current_lines, content_lines);
current_lines.clear();
String section = trim(line.substr(1));
if(section == "title" || section == "sig" || section == "params" || section == "see")
if(section == "title" || section == "sig" || section == "params" || section == "content" || section == "example" || section == "see")
{
current_section = section;
continue;
}
if(section == "content")
{
content_mode = true;
current_section = "content";
continue;
}
current_section = "legacy";
String heading = doc_legacy_heading(section);
@@ -141,31 +181,10 @@ DocPage load_doc_page(String page)
continue;
}
if(current_section == "title")
{
if(result.title != "")
result.title += "\n";
result.title += line;
}
else if(current_section == "sig")
{
result.sig_lines.push_back(line);
}
else if(current_section == "params")
{
result.param_lines.push_back(line);
}
else if(current_section == "see")
{
if(trim(line) != "")
result.see_lines.push_back(trim(line));
}
else
{
content_lines.push_back(line);
}
current_lines.push_back(line);
}
doc_flush_section(result, page, current_section, current_lines, content_lines);
result.content = join(content_lines, "\n");
result.title = trim(result.title);
return(result);