cleanup, docs
This commit is contained in:
@@ -23,7 +23,7 @@ String cli_truncate(String value, u64 max_len = 240)
|
||||
return(value.substr(0, max_len) + "...");
|
||||
}
|
||||
|
||||
CliHttpResponse cli_http_request(String host, short port, String path, String extra_headers = "")
|
||||
CliHttpResponse cli_http_request(String host, u16 port, String path, String extra_headers = "")
|
||||
{
|
||||
CliHttpResponse res;
|
||||
u64 fd = socket_connect(host, port);
|
||||
@@ -160,6 +160,35 @@ bool cli_doc_source_has_example(String source)
|
||||
return(false);
|
||||
}
|
||||
|
||||
// A real example must exercise the documented API and print a derived result.
|
||||
// These placeholder shapes (auto-generated stubs) are forbidden by the gate.
|
||||
bool cli_doc_example_is_placeholder(String source)
|
||||
{
|
||||
bool in_example = false;
|
||||
StringList body;
|
||||
for(String line : split(source, "\n"))
|
||||
{
|
||||
String t = trim(line);
|
||||
if(!in_example)
|
||||
{
|
||||
if(t == ":example")
|
||||
in_example = true;
|
||||
continue;
|
||||
}
|
||||
if(t.length() > 0 && t.substr(0, 1) == ":")
|
||||
break;
|
||||
body.push_back(line);
|
||||
}
|
||||
String joined = join(body, "\n");
|
||||
if(cli_contains(joined, " example\\n\");"))
|
||||
return(true);
|
||||
if(cli_contains(joined, "is resource-bound; configure"))
|
||||
return(true);
|
||||
if(cli_contains(joined, "documents a UCE concept"))
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
void cli_run_doc_pages_gate()
|
||||
{
|
||||
StringList error_markers;
|
||||
@@ -172,10 +201,10 @@ void cli_run_doc_pages_gate()
|
||||
|
||||
for(String file_name : ls("../doc/pages/"))
|
||||
{
|
||||
String source = file_get_contents("../doc/pages/" + file_name);
|
||||
String page = nibble(file_name, ".");
|
||||
if(page == "")
|
||||
continue;
|
||||
String source = file_get_contents("../doc/pages/" + file_name);
|
||||
bool has_example = cli_doc_source_has_example(source);
|
||||
String path = "/doc/index.uce?p=" + uri_encode(page);
|
||||
CliHttpResponse res = cli_frontend(path);
|
||||
@@ -194,6 +223,11 @@ void cli_run_doc_pages_gate()
|
||||
ok = false;
|
||||
summary += "; example reported an error";
|
||||
}
|
||||
if(cli_doc_example_is_placeholder(source))
|
||||
{
|
||||
ok = false;
|
||||
summary += "; placeholder example (must exercise the API)";
|
||||
}
|
||||
}
|
||||
cli_test_case("uce_doc_gate:doc page " + page, ok, ok ? summary : summary + "; body=" + cli_truncate(res.body));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user