@shd101wyy/yo 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +10 -1
  2. package/out/cjs/index.cjs +579 -573
  3. package/out/cjs/yo-cli.cjs +1413 -592
  4. package/out/esm/index.mjs +437 -431
  5. package/out/types/src/build-runner.d.ts +1 -1
  6. package/out/types/src/doc/builder.d.ts +21 -0
  7. package/out/types/src/doc/builder.test.d.ts +1 -0
  8. package/out/types/src/doc/extractor.d.ts +27 -0
  9. package/out/types/src/doc/extractor.test.d.ts +1 -0
  10. package/out/types/src/doc/model.d.ts +87 -0
  11. package/out/types/src/doc/render-html.d.ts +23 -0
  12. package/out/types/src/doc/render-html.test.d.ts +1 -0
  13. package/out/types/src/doc/render-json.d.ts +7 -0
  14. package/out/types/src/doc/render-json.test.d.ts +1 -0
  15. package/out/types/src/doc/render-markdown.d.ts +13 -0
  16. package/out/types/src/doc/render-markdown.test.d.ts +1 -0
  17. package/out/types/src/doc/sections.d.ts +7 -0
  18. package/out/types/src/doc/sections.test.d.ts +1 -0
  19. package/out/types/src/doc-command.d.ts +10 -0
  20. package/out/types/src/env.d.ts +1 -0
  21. package/out/types/src/evaluator/builtins/build.d.ts +17 -0
  22. package/out/types/src/evaluator/context.d.ts +1 -0
  23. package/out/types/src/evaluator/exprs/import.d.ts +2 -0
  24. package/out/types/src/expr.d.ts +2 -1
  25. package/out/types/src/tests/import-path.test.d.ts +1 -0
  26. package/out/types/src/token.d.ts +4 -0
  27. package/out/types/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +2 -1
  29. package/scripts/build-site.ts +461 -0
  30. package/std/alg/hash.yo +12 -24
  31. package/std/allocator.yo +21 -29
  32. package/std/async.yo +4 -2
  33. package/std/build.yo +188 -42
  34. package/std/cli/arg_parser.yo +37 -1
  35. package/std/collections/array_list.yo +8 -20
  36. package/std/collections/btree_map.yo +15 -20
  37. package/std/collections/deque.yo +13 -15
  38. package/std/collections/hash_map.yo +15 -54
  39. package/std/collections/hash_set.yo +14 -50
  40. package/std/collections/linked_list.yo +6 -23
  41. package/std/collections/priority_queue.yo +15 -17
  42. package/std/crypto/md5.yo +10 -9
  43. package/std/crypto/random.yo +14 -12
  44. package/std/crypto/sha256.yo +9 -8
  45. package/std/encoding/base64.yo +13 -15
  46. package/std/encoding/hex.yo +14 -10
  47. package/std/encoding/html.yo +14 -11
  48. package/std/encoding/html_char_utils.yo +14 -11
  49. package/std/encoding/html_entities.yo +7 -8
  50. package/std/encoding/json.yo +36 -19
  51. package/std/encoding/punycode.yo +21 -18
  52. package/std/encoding/toml.yo +23 -9
  53. package/std/encoding/utf16.yo +16 -9
  54. package/std/error.yo +10 -23
  55. package/std/fmt/display.yo +15 -17
  56. package/std/fmt/index.yo +6 -27
  57. package/std/fmt/to_string.yo +4 -10
  58. package/std/fmt/writer.yo +33 -34
  59. package/std/fs/dir.yo +37 -30
  60. package/std/fs/file.yo +77 -75
  61. package/std/fs/metadata.yo +25 -25
  62. package/std/fs/temp.yo +21 -27
  63. package/std/fs/types.yo +20 -23
  64. package/std/fs/walker.yo +26 -31
  65. package/std/gc.yo +5 -0
  66. package/std/glob/index.yo +3 -0
  67. package/std/http/client.yo +25 -11
  68. package/std/http/http.yo +20 -0
  69. package/std/http/index.yo +1 -0
  70. package/std/io/reader.yo +4 -8
  71. package/std/io/writer.yo +4 -7
  72. package/std/libc/assert.yo +2 -2
  73. package/std/libc/ctype.yo +1 -2
  74. package/std/libc/dirent.yo +1 -2
  75. package/std/libc/errno.yo +1 -2
  76. package/std/libc/fcntl.yo +2 -2
  77. package/std/libc/float.yo +1 -2
  78. package/std/libc/limits.yo +1 -2
  79. package/std/libc/math.yo +2 -0
  80. package/std/libc/signal.yo +1 -2
  81. package/std/libc/stdatomic.yo +1 -2
  82. package/std/libc/stdint.yo +4 -3
  83. package/std/libc/stdio.yo +2 -0
  84. package/std/libc/stdlib.yo +2 -0
  85. package/std/libc/string.yo +2 -0
  86. package/std/libc/sys/stat.yo +1 -2
  87. package/std/libc/time.yo +2 -2
  88. package/std/libc/unistd.yo +2 -0
  89. package/std/libc/wctype.yo +1 -2
  90. package/std/libc/windows.yo +2 -2
  91. package/std/log/index.yo +11 -26
  92. package/std/net/addr.yo +18 -11
  93. package/std/net/dns.yo +3 -2
  94. package/std/net/errors.yo +16 -2
  95. package/std/net/tcp.yo +25 -22
  96. package/std/net/udp.yo +14 -12
  97. package/std/os/env.yo +23 -18
  98. package/std/os/signal.yo +31 -19
  99. package/std/path.yo +23 -74
  100. package/std/prelude.yo +284 -113
  101. package/std/process.yo +23 -37
  102. package/std/regex/compiler.yo +3 -5
  103. package/std/regex/flags.yo +11 -11
  104. package/std/regex/index.yo +2 -13
  105. package/std/regex/match.yo +3 -5
  106. package/std/regex/node.yo +6 -6
  107. package/std/regex/parser.yo +2 -4
  108. package/std/regex/unicode.yo +5 -5
  109. package/std/regex/vm.yo +5 -5
  110. package/std/string/index.yo +2 -1
  111. package/std/string/rune.yo +25 -1
  112. package/std/string/string.yo +31 -19
  113. package/std/string/unicode.yo +14 -15
  114. package/std/sync/channel.yo +18 -28
  115. package/std/sync/cond.yo +4 -0
  116. package/std/sync/mutex.yo +4 -1
  117. package/std/sync/once.yo +17 -19
  118. package/std/sync/rwlock.yo +19 -22
  119. package/std/sync/waitgroup.yo +21 -23
  120. package/std/sys/advise.yo +4 -4
  121. package/std/sys/bufio/buf_reader.yo +19 -16
  122. package/std/sys/bufio/buf_writer.yo +14 -11
  123. package/std/sys/clock.yo +4 -4
  124. package/std/sys/constants.yo +5 -5
  125. package/std/sys/copy.yo +9 -8
  126. package/std/sys/dir.yo +9 -8
  127. package/std/sys/dns.yo +8 -8
  128. package/std/sys/errors.yo +35 -6
  129. package/std/sys/events.yo +3 -3
  130. package/std/sys/externs.yo +3 -3
  131. package/std/sys/fallocate.yo +4 -4
  132. package/std/sys/fcntl.yo +8 -6
  133. package/std/sys/file.yo +7 -8
  134. package/std/sys/future.yo +1 -3
  135. package/std/sys/iov.yo +4 -4
  136. package/std/sys/lock.yo +7 -7
  137. package/std/sys/mmap.yo +7 -8
  138. package/std/sys/path.yo +4 -7
  139. package/std/sys/perm.yo +8 -8
  140. package/std/sys/pipe.yo +9 -8
  141. package/std/sys/process.yo +8 -8
  142. package/std/sys/seek.yo +4 -4
  143. package/std/sys/signal.yo +4 -4
  144. package/std/sys/signals.yo +4 -4
  145. package/std/sys/socket.yo +4 -4
  146. package/std/sys/socketpair.yo +4 -4
  147. package/std/sys/sockinfo.yo +4 -4
  148. package/std/sys/statfs.yo +8 -8
  149. package/std/sys/statx.yo +4 -4
  150. package/std/sys/sysinfo.yo +4 -4
  151. package/std/sys/tcp.yo +8 -8
  152. package/std/sys/temp.yo +9 -8
  153. package/std/sys/time.yo +8 -8
  154. package/std/sys/timer.yo +7 -8
  155. package/std/sys/tty.yo +13 -10
  156. package/std/sys/udp.yo +8 -8
  157. package/std/sys/umask.yo +4 -4
  158. package/std/sys/unix.yo +5 -5
  159. package/std/testing/bench.yo +21 -10
  160. package/std/thread.yo +18 -9
  161. package/std/time/datetime.yo +12 -14
  162. package/std/time/duration.yo +12 -14
  163. package/std/time/instant.yo +13 -16
  164. package/std/time/sleep.yo +9 -8
  165. package/std/url/index.yo +3 -19
  166. package/std/worker.yo +10 -18
package/std/fs/walker.yo CHANGED
@@ -1,25 +1,26 @@
1
- // std/fs/walker.yo - Recursive directory traversal
2
- //
3
- // Walks a directory tree and collects entries.
4
- //
5
- // Example:
6
- // { walk, WalkEntry } :: import "std/fs/walker";
7
- //
8
- // main :: (fn(using(io : IO)) -> unit)({
9
- // given(exn) : Exception = {
10
- // throw : (fn(forall(T : Type), error: AnyError) -> T)(
11
- // { println(error.to_string()); exit(i32(1)); }
12
- // )
13
- // };
14
- //
15
- // entries := io.await(walk(`/tmp`));
16
- // i := usize(0);
17
- // while runtime((i < entries.len())), {
18
- // e := entries.get(i).unwrap();
19
- // println(e.path);
20
- // i = (i + usize(1));
21
- // };
22
- // });
1
+ //! Recursive directory traversal.
2
+ //!
3
+ //! # Example
4
+ //!
5
+ //! ```rust
6
+ //! { walk, WalkEntry } :: import "std/fs/walker";
7
+ //!
8
+ //! main :: (fn(using(io : IO)) -> unit)({
9
+ //! given(exn) : Exception = {
10
+ //! throw : (fn(forall(T : Type), error: AnyError) -> T)(
11
+ //! { println(error.to_string()); exit(i32(1)); }
12
+ //! )
13
+ //! };
14
+ //!
15
+ //! entries := io.await(walk(`/tmp`));
16
+ //! i := usize(0);
17
+ //! while runtime((i < entries.len())), {
18
+ //! e := entries.get(i).unwrap();
19
+ //! println(e.path);
20
+ //! i = (i + usize(1));
21
+ //! };
22
+ //! });
23
+ //! ```
23
24
 
24
25
  { ArrayList } :: import "../collections/array_list";
25
26
  open import "../string";
@@ -30,10 +31,7 @@ open import "../string";
30
31
  { DirEntry } :: import "./dir";
31
32
  _dir :: import "./dir";
32
33
 
33
- // ============================================================================
34
- // WalkEntry
35
- // ============================================================================
36
-
34
+ /// Entry returned by the directory walker.
37
35
  WalkEntry :: struct(
38
36
  path : Path,
39
37
  name : String,
@@ -43,10 +41,7 @@ WalkEntry :: struct(
43
41
 
44
42
  export WalkEntry;
45
43
 
46
- // ============================================================================
47
- // WalkOptions
48
- // ============================================================================
49
-
44
+ /// Options controlling directory walk behavior.
50
45
  WalkOptions :: struct(
51
46
  max_depth : ?(u32),
52
47
  follow_symlinks : bool,
@@ -147,7 +142,7 @@ walk_with_cstr :: (fn(root: *(u8), options: WalkOptions, using(io : IO)) -> Impl
147
142
  walk_with(Path.from_cstr(root), options)
148
143
  );
149
144
 
150
- // Walk a directory tree with default options.
145
+ /// Walk a directory tree with default options.
151
146
  walk :: (fn(root: Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))
152
147
  walk_with(root, WalkOptions.defaults())
153
148
  ;
package/std/gc.yo CHANGED
@@ -1,9 +1,14 @@
1
+ //! Garbage collection interface for cycle collection.
2
+
1
3
  extern "Yo",
2
4
  __yo_gc_collect : (fn() -> unit),
3
5
  __yo_gc_tracked_count : (fn() -> u64)
4
6
  ;
5
7
 
8
+ /// Trigger the cycle collector to reclaim reference cycles.
6
9
  collect :: __yo_gc_collect;
10
+
11
+ /// Get the number of objects currently tracked by the cycle collector.
7
12
  tracked_count :: __yo_gc_tracked_count;
8
13
 
9
14
  export collect;
package/std/glob/index.yo CHANGED
@@ -1,3 +1,5 @@
1
+ //! Glob pattern matching for file paths.
2
+
1
3
  open import "../string";
2
4
  { ArrayList } :: import "../collections/array_list";
3
5
 
@@ -190,6 +192,7 @@ glob_match :: (fn(pattern: String, text: String) -> bool)(
190
192
  _glob_match_impl(pattern.as_bytes(), usize(0), text.as_bytes(), usize(0))
191
193
  );
192
194
 
195
+ /// Compiled glob pattern that can be matched against strings.
193
196
  GlobPattern :: object(
194
197
  _pattern : String
195
198
  );
@@ -1,3 +1,4 @@
1
+ //! Async HTTP client with high-level fetch API.
1
2
  // std/http/client.yo - Async HTTP client using TCP
2
3
  //
3
4
  // Provides an async HTTP client and a high-level `fetch` function
@@ -35,13 +36,21 @@ open import "../fmt";
35
36
  // HttpError
36
37
  // ============================================================================
37
38
 
39
+ /// HTTP client error variants.
38
40
  HttpError :: enum(
41
+ /// Failed to connect to the remote host.
39
42
  ConnectionFailed(msg: String),
43
+ /// The URL could not be parsed.
40
44
  InvalidUrl(msg: String),
45
+ /// The request timed out.
41
46
  Timeout,
47
+ /// Too many HTTP redirects.
42
48
  TooManyRedirects,
49
+ /// The URL scheme is not supported (only http/https).
43
50
  UnsupportedScheme(scheme: String),
51
+ /// The response body exceeds the size limit.
44
52
  ResponseTooLarge,
53
+ /// An unclassified HTTP error.
45
54
  Other(msg: String)
46
55
  );
47
56
 
@@ -67,6 +76,7 @@ export HttpError;
67
76
  // FetchOptions
68
77
  // ============================================================================
69
78
 
79
+ /// Options for configuring an HTTP request.
70
80
  FetchOptions :: object(
71
81
  method : HttpMethod,
72
82
  headers : ArrayList(HttpHeader),
@@ -74,6 +84,7 @@ FetchOptions :: object(
74
84
  );
75
85
 
76
86
  impl(FetchOptions,
87
+ /// Create default options (GET, no headers, empty body).
77
88
  new : (fn() -> Self)(
78
89
  Self(
79
90
  method: .GET,
@@ -82,16 +93,19 @@ impl(FetchOptions,
82
93
  )
83
94
  ),
84
95
 
96
+ /// Set the HTTP method.
85
97
  with_method : (fn(self: Self, method: HttpMethod) -> Self)({
86
98
  self.method = method;
87
99
  self
88
100
  }),
89
101
 
102
+ /// Add a request header.
90
103
  with_header : (fn(self: Self, name: String, value: String) -> Self)({
91
104
  self.headers.push(HttpHeader.new(name, value));
92
105
  self
93
106
  }),
94
107
 
108
+ /// Set the request body.
95
109
  with_body : (fn(self: Self, body: String) -> Self)({
96
110
  self.body = body;
97
111
  self
@@ -229,11 +243,11 @@ _read_http_response :: (fn(stream: TcpStream, using(io : IO, exn : Exception)) -
229
243
  // fetch — High-level async HTTP request (like JavaScript's fetch)
230
244
  // ============================================================================
231
245
 
232
- // Perform an HTTP request with custom options.
233
- //
234
- // Example:
235
- // opts := FetchOptions.new().with_method(.POST).with_body(`{"key": "value"}`);
236
- // resp := io.await(fetch_with(`http://example.com/api`, opts, using(io)));
246
+ /// Perform an HTTP request with custom options.
247
+ ///
248
+ /// Example:
249
+ /// opts := FetchOptions.new().with_method(.POST).with_body(`{"key": "value"}`);
250
+ /// resp := io.await(fetch_with(`http://example.com/api`, opts, using(io)));
237
251
  fetch_with :: (fn(url_str: String, opts: FetchOptions, using(io : IO)) ->
238
252
  Impl(Future(HttpResponse, IO, Exception))
239
253
  )(
@@ -342,12 +356,12 @@ fetch_with :: (fn(url_str: String, opts: FetchOptions, using(io : IO)) ->
342
356
 
343
357
  export fetch_with;
344
358
 
345
- // Perform an HTTP GET request to the given URL string.
346
- // Returns the HttpResponse on success.
347
- //
348
- // Example:
349
- // resp := io.await(fetch(`http://example.com`, using(io)));
350
- // cond(resp.is_ok() => println(resp.body), true => println(`Error`));
359
+ /// Perform an HTTP GET request to the given URL string.
360
+ /// Returns the `HttpResponse` on success.
361
+ ///
362
+ /// Example:
363
+ /// resp := io.await(fetch(`http://example.com`, using(io)));
364
+ /// cond(resp.is_ok() => println(resp.body), true => println(`Error`));
351
365
  fetch :: (fn(url_str: String, using(io : IO)) ->
352
366
  Impl(Future(HttpResponse, IO, Exception))
353
367
  )(
package/std/http/http.yo CHANGED
@@ -1,9 +1,11 @@
1
+ //! HTTP core types — methods, headers, requests, and responses.
1
2
  // std/http/http.yo - HTTP types and request/response builders
2
3
 
3
4
  open import "../string";
4
5
  { ArrayList } :: import "../collections/array_list";
5
6
  { ToString } :: import "../fmt";
6
7
 
8
+ /// Standard HTTP request methods.
7
9
  HttpMethod :: enum(GET, POST, PUT, DELETE, HEAD, PATCH);
8
10
 
9
11
  impl(HttpMethod, ToString(
@@ -19,14 +21,17 @@ impl(HttpMethod, ToString(
19
21
  )
20
22
  ));
21
23
 
24
+ /// An HTTP header as a name-value pair.
22
25
  HttpHeader :: object(name: String, value: String);
23
26
 
24
27
  impl(HttpHeader,
28
+ /// Create a new header with the given name and value.
25
29
  new : (fn(name: String, value: String) -> Self)(
26
30
  Self(name: name, value: value)
27
31
  )
28
32
  );
29
33
 
34
+ /// An HTTP request with method, path, headers, and optional body.
30
35
  HttpRequest :: object(
31
36
  method: HttpMethod,
32
37
  path: String,
@@ -35,32 +40,39 @@ HttpRequest :: object(
35
40
  );
36
41
 
37
42
  impl(HttpRequest,
43
+ /// Create a new request with the given method and path.
38
44
  new : (fn(method: HttpMethod, path: String) -> Self)(
39
45
  Self(method: method, path: path, headers: ArrayList(HttpHeader).new(), body: ``)
40
46
  ),
41
47
 
48
+ /// Add a header and return the request (builder pattern).
42
49
  header : (fn(self: Self, name: String, value: String) -> Self)({
43
50
  self.headers.push(HttpHeader.new(name, value));
44
51
  self
45
52
  }),
46
53
 
54
+ /// Set the request body and return the request (builder pattern).
47
55
  with_body : (fn(self: Self, body: String) -> Self)({
48
56
  self.body = body;
49
57
  self
50
58
  }),
51
59
 
60
+ /// Set the Host header.
52
61
  set_host : (fn(self: Self, host: String) -> unit)({
53
62
  self.headers.push(HttpHeader.new(`Host`, host));
54
63
  }),
55
64
 
65
+ /// Append a header to the request.
56
66
  set_header : (fn(self: Self, name: String, value: String) -> unit)({
57
67
  self.headers.push(HttpHeader.new(name, value));
58
68
  }),
59
69
 
70
+ /// Set the request body.
60
71
  set_body : (fn(self: Self, body: String) -> unit)({
61
72
  self.body = body;
62
73
  }),
63
74
 
75
+ /// Serialize the request to an HTTP/1.1 wire-format string.
64
76
  to_string : (fn(self: Self) -> String)({
65
77
  result := `${self.method.to_string()} ${self.path} HTTP/1.1\r\n`;
66
78
  i := usize(0);
@@ -77,6 +89,7 @@ impl(HttpRequest,
77
89
  })
78
90
  );
79
91
 
92
+ /// An HTTP response with status code, headers, and body.
80
93
  HttpResponse :: object(
81
94
  status_code: i32,
82
95
  status_text: String,
@@ -85,10 +98,12 @@ HttpResponse :: object(
85
98
  );
86
99
 
87
100
  impl(HttpResponse,
101
+ /// Create a new response with the given status code and text.
88
102
  new : (fn(status_code: i32, status_text: String) -> Self)(
89
103
  Self(status_code: status_code, status_text: status_text, headers: ArrayList(HttpHeader).new(), body: ``)
90
104
  ),
91
105
 
106
+ /// Look up a header value by name (case-insensitive).
92
107
  get_header : (fn(self: Self, name: String) -> Option(String))({
93
108
  lower_name := name.to_lowercase();
94
109
  i := usize(0);
@@ -99,19 +114,23 @@ impl(HttpResponse,
99
114
  .None
100
115
  }),
101
116
 
117
+ /// Return `true` if the status code is in the 2xx range.
102
118
  is_ok : (fn(self: Self) -> bool)(
103
119
  ((self.status_code >= i32(200)) && (self.status_code < i32(300)))
104
120
  ),
105
121
 
122
+ /// Return `true` if the status code is in the 3xx range.
106
123
  is_redirect : (fn(self: Self) -> bool)(
107
124
  ((self.status_code >= i32(300)) && (self.status_code < i32(400)))
108
125
  ),
109
126
 
127
+ /// Return `true` if the status code is 4xx or higher.
110
128
  is_error : (fn(self: Self) -> bool)(
111
129
  (self.status_code >= i32(400))
112
130
  )
113
131
  );
114
132
 
133
+ /// Parse a raw HTTP response string into an `HttpResponse`.
115
134
  parse_response :: (fn(raw: String) -> Result(HttpResponse, String))({
116
135
  lines := raw.split(`\r\n`);
117
136
  cond((lines.len() == usize(0)) => { return .Err(`Empty response`); }, true => ());
@@ -174,6 +193,7 @@ parse_response :: (fn(raw: String) -> Result(HttpResponse, String))({
174
193
  .Ok(resp)
175
194
  });
176
195
 
196
+ /// Return the standard status text for an HTTP status code.
177
197
  http_status_text :: (fn(code: i32) -> String)(
178
198
  cond(
179
199
  (code == i32(200)) => `OK`,
package/std/http/index.yo CHANGED
@@ -1,3 +1,4 @@
1
+ //! HTTP client library — types, request building, and async fetching.
1
2
  // std/http - HTTP types, request/response builders, and async client.
2
3
  //
3
4
  // Example:
package/std/io/reader.yo CHANGED
@@ -1,15 +1,11 @@
1
- // std/io/reader.yo - Reader trait for byte-level input
2
- //
3
- // Provides a common interface for reading bytes from various sources
4
- // (files, network streams, buffers, etc.)
1
+ //! Reader trait for byte-level input.
5
2
 
6
3
  { Exception } :: import "../error";
7
4
 
8
- // Reader trait synchronous byte reading interface.
9
- // Types implementing Reader provide `read` for reading into a buffer.
5
+ /// Common interface for reading bytes from various sources.
10
6
  Reader :: trait(
11
- // Read up to `size` bytes into buffer `buf`.
12
- // Returns the number of bytes actually read (0 at end-of-stream).
7
+ /// Read up to `size` bytes into buffer `buf`.
8
+ /// Returns the number of bytes actually read (0 at end-of-stream).
13
9
  read :
14
10
  fn(self: *(Self), buf: *(u8), size: usize, using(exn : Exception)) -> usize
15
11
  );
package/std/io/writer.yo CHANGED
@@ -1,17 +1,14 @@
1
- // std/io/writer.yo - Writer trait for byte-level output
2
- //
3
- // Provides a common interface for writing bytes to various destinations
4
- // (files, network streams, buffers, etc.)
1
+ //! Writer trait for byte-level output.
5
2
 
6
3
  { Exception } :: import "../error";
7
4
 
8
- // Writer trait synchronous byte writing interface.
5
+ /// Common interface for writing bytes to a destination.
9
6
  Writer :: trait(
10
- // Write bytes from buffer. Returns number of bytes written.
7
+ /// Write bytes from buffer. Returns number of bytes written.
11
8
  write :
12
9
  fn(self: *(Self), buf: *(u8), size: usize, using(exn : Exception)) -> usize,
13
10
 
14
- // Flush any buffered data to the underlying destination.
11
+ /// Flush any buffered data to the underlying destination.
15
12
  flush :
16
13
  fn(self: *(Self), using(exn : Exception)) -> unit
17
14
  );
@@ -1,5 +1,5 @@
1
- // C11 assert.h - Assertion debugging facility
2
- // Provides runtime assertion checking for debugging
1
+ //! C11 `<assert.h>` assertion debugging facility.
2
+ //! Provides runtime assertion checking for debugging.
3
3
 
4
4
  c_include "<assert.h>",
5
5
  // The actual assertion function called by the assert macro
package/std/libc/ctype.yo CHANGED
@@ -1,5 +1,4 @@
1
- // C11 ctype.h - Character classification and conversion functions
2
- // Provides functions to test and convert character types
1
+ //! C11 `<ctype.h>` character classification and conversion functions.
3
2
 
4
3
  c_include "<ctype.h>",
5
4
  // Character classification functions
@@ -1,5 +1,4 @@
1
- // C11 dirent.h - Directory entry operations
2
- // Provides directory traversal functionality
1
+ //! C11 `<dirent.h>` directory entry operations.
3
2
 
4
3
  c_include "<dirent.h>",
5
4
  // Types
package/std/libc/errno.yo CHANGED
@@ -1,5 +1,4 @@
1
- // C11 errno.h - Error handling constants and errno variable
2
- // Provides standard error codes and errno global variable
1
+ //! C11 `<errno.h>` error handling constants and `errno` variable.
3
2
 
4
3
  c_include "<errno.h>",
5
4
  // The errno variable - global error indicator
package/std/libc/fcntl.yo CHANGED
@@ -1,5 +1,5 @@
1
- // POSIX fcntl.h - File control options
2
- // Provides open flags and file control operations
1
+ //! POSIX `<fcntl.h>` file control options.
2
+ //! Provides open flags and file control operations.
3
3
 
4
4
  c_include "<fcntl.h>",
5
5
  // File access modes (for open)
package/std/libc/float.yo CHANGED
@@ -1,5 +1,4 @@
1
- // C11 float.h - Floating-point implementation limits
2
- // Provides implementation-defined limits for floating-point types
1
+ //! C11 `<float.h>` floating-point implementation limits.
3
2
 
4
3
  c_include "<float.h>",
5
4
  // Floating-point model parameters
@@ -1,5 +1,4 @@
1
- // C11 limits.h - Implementation-defined limits for integer types
2
- // Provides minimum and maximum values for various integer types
1
+ //! C11 `<limits.h>` implementation-defined limits for integer types.
3
2
 
4
3
  c_include "<limits.h>",
5
4
  // Character limits
package/std/libc/math.yo CHANGED
@@ -1,3 +1,5 @@
1
+ //! C11 `<math.h>` — mathematical functions and constants.
2
+
1
3
  c_include "<math.h>",
2
4
  // Mathematical constants (implementation-defined)
3
5
  M_E : f64, // e (2.71828...)
@@ -1,5 +1,4 @@
1
- // C11 signal.h - Signal handling functions and constants
2
- // Provides signal handling capabilities for process control
1
+ //! C11 `<signal.h>` signal handling functions and constants.
3
2
 
4
3
  c_include "<signal.h>",
5
4
  // Signal handler type
@@ -1,5 +1,4 @@
1
- // C11 Atomic Operations and Types
2
- // Corresponds to C's <stdatomic.h>
1
+ //! C11 `<stdatomic.h>` atomic operations and types.
3
2
 
4
3
  c_include "<stdatomic.h>",
5
4
  // Atomic types
@@ -1,6 +1,7 @@
1
- // C11 stdint.h - Fixed-width integer types and limits
2
- // Note: Yo already has i8, i16, i32, i64, u8, u16, u32, u64
3
- // This file provides C-compatible aliases and additional types/constants
1
+ //! C11 `<stdint.h>` fixed-width integer types and limits.
2
+ //!
3
+ //! Note: Yo already has `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`.
4
+ //! This file provides C-compatible aliases and additional types/constants.
4
5
 
5
6
  // Type aliases for C compatibility (mapping Yo types to C stdint names)
6
7
  int8_t :: i8;
package/std/libc/stdio.yo CHANGED
@@ -1,3 +1,5 @@
1
+ //! C11 `<stdio.h>` — standard I/O functions.
2
+
1
3
  c_include "<stdio.h>",
2
4
  // Types
3
5
  FILE : Type,
@@ -1,3 +1,5 @@
1
+ //! C11 `<stdlib.h>` — general utility functions.
2
+
1
3
  c_include "<stdlib.h>",
2
4
  // Types for div functions
3
5
  div_t : Type,
@@ -1,3 +1,5 @@
1
+ //! C11 `<string.h>` — string and memory functions.
2
+
1
3
  c_include "<string.h>",
2
4
  // Memory functions
3
5
  memcpy :
@@ -1,5 +1,4 @@
1
- // POSIX sys/stat.h - File status and mode operations
2
- // Provides stat, fstat, lstat, mkdir, chmod, etc.
1
+ //! POSIX `<sys/stat.h>` file status and mode operations.
3
2
 
4
3
  c_include "<sys/stat.h>",
5
4
  // Types
package/std/libc/time.yo CHANGED
@@ -1,5 +1,5 @@
1
- // C11 time.h - Date and time functions
2
- // Provides time manipulation, formatting, and calendar functions
1
+ //! C11 `<time.h>` date and time functions.
2
+
3
3
  c_include "<time.h>",
4
4
  // Types
5
5
  time_t : Type,
@@ -1,3 +1,5 @@
1
+ //! POSIX `<unistd.h>` — standard symbolic constants and types.
2
+
1
3
  c_include "<unistd.h>",
2
4
  // Types
3
5
  // usize : Type,
@@ -1,5 +1,4 @@
1
- // C11 wctype.h - Wide character classification and conversion functions
2
- // Provides functions to test and convert wide character types
1
+ //! C11 `<wctype.h>` wide character classification and conversion functions.
3
2
 
4
3
  { wint_t } :: import "./stdint";
5
4
 
@@ -1,5 +1,5 @@
1
- // Windows-specific C API bindings
2
- // Only available when compiling for Windows
1
+ //! Windows-specific C API bindings.
2
+ //! Only available when compiling for Windows.
3
3
 
4
4
  // Windows type aliases (using Yo types that match the C types)
5
5
  DWORD :: ulong; // unsigned long on Windows
package/std/log/index.yo CHANGED
@@ -1,22 +1,10 @@
1
- // std/log - Structured logging
2
- //
3
- // Provides a global logger with configurable level and output destination.
4
- //
5
- // Example:
6
- // { info, warn, error, set_level, Level } :: import "std/log";
7
- //
8
- // set_level(.Info);
9
- // info(String.from("application started"));
10
- // warn(String.from("disk usage high"));
1
+ //! Structured logging with configurable level and output destination.
11
2
 
12
3
  open import "../string";
13
4
  { ToString } :: import "../fmt";
14
- { fwrite, stdout, stderr } :: import "../libc/stdio";
15
-
16
- // ============================================================================
17
- // Level
18
- // ============================================================================
5
+ { fwrite, stdout, stderr, FILE } :: import "../libc/stdio";
19
6
 
7
+ /// Log severity level.
20
8
  Level :: enum(Trace, Debug, Info, Warn, Error);
21
9
 
22
10
  impl(Level, ToString(
@@ -33,10 +21,7 @@ impl(Level, ToString(
33
21
 
34
22
  export Level;
35
23
 
36
- // ============================================================================
37
- // LogOutput
38
- // ============================================================================
39
-
24
+ /// Where log messages are written.
40
25
  LogOutput :: enum(
41
26
  Stderr,
42
27
  Stdout
@@ -55,13 +40,13 @@ _global_output := LogOutput.Stderr;
55
40
  // Configuration
56
41
  // ============================================================================
57
42
 
58
- set_level :: (fn(level: Level) -> unit)(
59
- _global_level = level
60
- );
43
+ set_level :: (fn(level: Level) -> unit)({
44
+ _global_level = level;
45
+ });
61
46
 
62
- set_output :: (fn(output: LogOutput) -> unit)(
63
- _global_output = output
64
- );
47
+ set_output :: (fn(output: LogOutput) -> unit)({
48
+ _global_output = output;
49
+ });
65
50
 
66
51
  export set_level, set_output;
67
52
 
@@ -80,7 +65,7 @@ _level_value :: (fn(l: Level) -> i32)(
80
65
  );
81
66
 
82
67
  // Write all bytes from a String to the file handle.
83
- _write_string :: (fn(s: String, dest: *(void)) -> unit)({
68
+ _write_string :: (fn(s: String, dest: *(FILE)) -> unit)({
84
69
  bytes := s.as_bytes();
85
70
  cond(
86
71
  (bytes.len() > usize(0)) => {