Does this mean that you must start a local server to access it?
The Same Origin Policy disallows reading the remote resource at file:///E:/code/me/test-zig/miniaudio.zig/zig-out/docs/main.wasm. (Reason: CORS request not http).
Does this mean that you must start a local server to access it?
The Same Origin Policy disallows reading the remote resource at file:///E:/code/me/test-zig/miniaudio.zig/zig-out/docs/main.wasm. (Reason: CORS request not http).
It seems so
Until we have a local server for our generated documentation:
python -m http.server -b 127.0.0.1 8000 -d zig-out/docs/
There is a server for the standard library:
zig std
modern java also
β°ββ― jwebserver -p 9999 -d $'(pwd)\zig-out\docs'
Binding to loopback by default. For all interfaces use "-b 0.0.0.0" or "-b ::".
Serving E:\code\me\test-zig\miniaudio.zig\zig-out\docs and subdirectories on 127.0.0.1 port 9999
URL http://127.0.0.1:9999/
127.0.0.1 - - [11/5ζ/2024:14:53:32 +0800] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [11/5ζ/2024:14:53:32 +0800] "GET /main.js HTTP/1.1" 200 -
127.0.0.1 - - [11/5ζ/2024:14:53:32 +0800] "GET /main.wasm HTTP/1.1" 200 -
127.0.0.1 - - [11/5ζ/2024:14:53:32 +0800] "GET /sources.tar HTTP/1.1" 200 -
We can also use redbean to build a single file document http server
build.zig
// docs
//
{
const docs_step = b.step("docs", "Build the project documentation");
const install_docs = b.addInstallDirectory(.{
.source_dir = exe.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs/",
});
docs_step.dependOn(&install_docs.step);
// docs.com (requires curl,zip)
//
{
const docs_com_step = b.step("docscom", "Build docs.com (documentation http server powered by redbean.com)");
const download_redbean = b.addSystemCommand(&.{ "curl", "-fsSLo", "docs.com", "https://redbean.dev/redbean-2.2.com", "--ssl-no-revoke" });
download_redbean.has_side_effects = true;
download_redbean.setCwd(.{ .path = b.install_path });
download_redbean.expectExitCode(0);
const zip_docs_into_redbean = b.addSystemCommand(&.{ "zip", "-r", "docs.com", "docs" });
zip_docs_into_redbean.has_side_effects = true;
zip_docs_into_redbean.setCwd(.{ .path = b.install_path });
zip_docs_into_redbean.expectExitCode(0);
zip_docs_into_redbean.step.dependOn(&download_redbean.step);
docs_com_step.dependOn(docs_step);
docs_com_step.dependOn(&zip_docs_into_redbean.step);
}
}
zig build docscom
and get docs.com in
.\zig-out
βββ docs
β βββ index.html
β βββ main.js
β βββ main.wasm
β βββ sources.tar
βββ docs.com
and start it
./zig-out/docs.com -v -p 8888
β°ββ― ./zig-out/docs.com -v -p 8888
I2024-05-12T10:33:47.859546:tool/net/redbean.c:7057:docs:19228] (srvr) listen http://192.168.1.101:8888
I2024-05-12T10:33:47+000000:tool/net/redbean.c:7057:docs:19228] (srvr) listen http://127.0.0.1:8888
I2024-05-12T10:33:47+000000:tool/net/redbean.c:7057:docs:19228] (srvr) listen http://172.28.224.1:8888
I2024-05-12T10:33:47+000000:tool/net/redbean.c:7057:docs:19228] (srvr) listen http://172.21.64.1:8888
V2024-05-12T10:33:47+000000:tool/net/redbean.c:2003:docs:19228] (ssl) could not find non-CA SSL certificate key pair with -addext keyUsage=digitalSignature -addext extendedKeyUsage=serverAuth
V2024-05-12T10:33:47+000000:tool/net/redbean.c:2006:docs:19228] (ssl) could not find CA key signing key pair with -addext keyUsage=keyCertSign
V2024-05-12T10:33:47+000000:tool/net/redbean.c:2008:docs:19228] (ssl) generating self-signed ssl certificates
V2024-05-12T10:33:47+001003:tool/net/redbean.c:680:docs:19228] (ssl) using EC certificate "CN=xxx" for HTTPS server
V2024-05-12T10:33:48.044676:tool/net/redbean.c:680:docs:19228] (ssl) using RSA certificate "CN=xxx" for HTTPS server
>:
finally, we can open http://localhost:8888/docs/
to read docs
Well, letβs do one in Zig then: A "just-enough-functionality" Zig docs server: zds :^)