docs(lib): narrate remaining stdlib modules (M2)
Add module intros and per-function purpose lines across EN/ZH libs, with callable examples on the smaller modules; keep + params and host bodies intact. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
53bc3538da
commit
fecaacd5be
49 files changed
+617
-21
No files matched your search
@@ -24,7 +24,7 @@
|
||||
| **Call** | `pre_modifiers`;`tests/structure/bracket-call.mq.md`;mapping / call-arguments | **done** |
|
||||
| **M0 View** | `InterpPart::Index` → `[k](base)`;`call_display` 修饰表面 | **done** |
|
||||
| **M1** | 试点 `lib/table` · `lib/text` · `lib/json`(中英)+ public/stdlib | **done** |
|
||||
| **M2** | 其余 `lib/*` 叙述化;禁新脚注取元 | pending |
|
||||
| **M2** | 其余 `lib/*` 叙述化;禁新脚注取元 | **done** |
|
||||
| **M3–M4** | `ext/web`、`ext/ai`:脚注→链接取元;叙述;示例可逐步换括号调用 | pending |
|
||||
| **M5** | quantum / linalg + full gold | pending |
|
||||
|
||||
@@ -40,3 +40,4 @@
|
||||
|------|------|
|
||||
| 2026-09-14 | 初稿;Call + M0 标 done |
|
||||
| 2026-09-14 | M1 试点 table/text/json + public/stdlib 标 done |
|
||||
| 2026-09-14 | M2 其余 lib 叙述化标 done |
|
||||
@@ -6,6 +6,8 @@ description: >-
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
Readable browser effect helpers for WASM clients. Prefer GFM tables + these helpers; do not build effects with json.set chains.
|
||||
|
||||
## set_text
|
||||
+ `sel`
|
||||
+ `text`
|
||||
@@ -136,6 +138,8 @@ Build unobserve effect; specs is a map or @ list with id.
|
||||
## focus
|
||||
+ `sel`
|
||||
|
||||
focus.
|
||||
|
||||
*> table.put in=None at="focus" value=sel*
|
||||
|
||||
## navigate
|
||||
@@ -153,6 +157,8 @@ Build unobserve effect; specs is a map or @ list with id.
|
||||
## storage
|
||||
+ `spec`
|
||||
|
||||
storage.
|
||||
|
||||
*> table.put in=None at="storage" value=spec*
|
||||
|
||||
## interval
|
||||
@@ -171,6 +177,8 @@ Build unobserve effect; specs is a map or @ list with id.
|
||||
## clear_interval
|
||||
+ `id`="default"
|
||||
|
||||
clear_interval.
|
||||
|
||||
**`spec` = > table.put in=None at="id" value=id**
|
||||
*> table.put in=None at="clear_interval" value=spec*
|
||||
|
||||
@@ -214,11 +222,15 @@ Build unobserve effect; specs is a map or @ list with id.
|
||||
## ws
|
||||
+ `spec`
|
||||
|
||||
ws.
|
||||
|
||||
*> table.put in=None at="ws" value=spec*
|
||||
|
||||
## clipboard
|
||||
+ `text`
|
||||
|
||||
clipboard.
|
||||
|
||||
**`spec` = > table.put in=None at="text" value=text**
|
||||
*> table.put in=None at="clipboard" value=spec*
|
||||
|
||||
|
||||
+5
-1
@@ -3,9 +3,13 @@ title: lib/cli
|
||||
description: Parse argv flags (Mid M5). --key value / --key=value / --flag; positionals under _.
|
||||
---
|
||||
|
||||
Parse process argv into a map. Flags and positionals (under _).
|
||||
|
||||
## parse
|
||||
+ `args`=None
|
||||
|
||||
Parse `--key value` / `--key=value` / `--flag`. A bare `--flag` must not be followed by a non-option token if you need it as boolean (put flags last, or use `--flag=true`). Positionals land under `_`.
|
||||
Parse --key value / --key=value / --flag. A bare --flag must not be followed by a non-option token if you need it as boolean (put flags last, or use --flag=true). Positionals land under _. Omit args to use process argv.
|
||||
|
||||
Caller: [cli.parse]
|
||||
|
||||
*> host_cli_parse args=`args`*
|
||||
@@ -3,12 +3,20 @@ title: lib/csv
|
||||
description: RFC4180-ish CSV parse/stringify (Mid M4). First row = headers → list of maps.
|
||||
---
|
||||
|
||||
CSV parse and stringify. First row is headers; rows become a list of maps.
|
||||
|
||||
## parse
|
||||
+ `text`
|
||||
|
||||
Parse CSV text into a list of maps.
|
||||
|
||||
Caller: [csv.parse] text=`raw`
|
||||
|
||||
*> host_csv_parse text=`text`*
|
||||
|
||||
## stringify
|
||||
+ `rows`
|
||||
|
||||
Serialize a list of maps to CSV text.
|
||||
|
||||
*> host_csv_stringify rows=`rows`*
|
||||
@@ -3,6 +3,8 @@ title: lib/datetime
|
||||
description: Calendar moments as maps {unix, zone, iso} (Mid2 M7). Fixed offsets + a few IANA aliases.
|
||||
---
|
||||
|
||||
Calendar moments as maps {unix, zone, iso} (Mid2 M7). Fixed offsets + a few IANA aliases.
|
||||
|
||||
## now
|
||||
|
||||
Current UTC moment map.
|
||||
@@ -13,11 +15,15 @@ Current UTC moment map.
|
||||
+ `unix`
|
||||
+ `zone`=None
|
||||
|
||||
from_unix.
|
||||
|
||||
*> host_datetime_from_unix unix=`unix` zone=`zone`*
|
||||
|
||||
## to_unix
|
||||
+ `dt`
|
||||
|
||||
to_unix.
|
||||
|
||||
*> host_datetime_to_unix dt=`dt`*
|
||||
|
||||
## parse
|
||||
@@ -43,6 +49,8 @@ Styles: `rfc3339` (default), `date`, `time`, or a strftime pattern.
|
||||
+ `minutes`=None
|
||||
+ `seconds`=None
|
||||
|
||||
add.
|
||||
|
||||
*> host_datetime_add dt=`dt` days=`days` hours=`hours` minutes=`minutes` seconds=`seconds`*
|
||||
|
||||
## in_zone
|
||||
|
||||
+15
-1
@@ -3,34 +3,48 @@ title: lib/encoding
|
||||
description: Base64, hex, and base32 encode/decode (Mid M1 + Mid2 M8). UTF-8 text round-trip.
|
||||
---
|
||||
|
||||
Base64, hex, and base32 encode/decode. UTF-8 text round-trip.
|
||||
|
||||
## base64_encode
|
||||
+ `text`
|
||||
|
||||
Base64-encode text.
|
||||
|
||||
Caller: [encoding.base64_encode] text=`s`
|
||||
|
||||
*> host_encoding_base64_encode text=`text`*
|
||||
|
||||
## base64_decode
|
||||
+ `text`
|
||||
|
||||
Base64-decode text.
|
||||
|
||||
*> host_encoding_base64_decode text=`text`*
|
||||
|
||||
## hex_encode
|
||||
+ `text`
|
||||
|
||||
Hex-encode text.
|
||||
|
||||
*> host_encoding_hex_encode text=`text`*
|
||||
|
||||
## hex_decode
|
||||
+ `text`
|
||||
|
||||
Hex-decode text.
|
||||
|
||||
*> host_encoding_hex_decode text=`text`*
|
||||
|
||||
## base32_encode
|
||||
+ `text`
|
||||
|
||||
RFC 4648 alphabet; padding with `=`.
|
||||
Base32-encode text (RFC 4648 alphabet; padding with =).
|
||||
|
||||
*> host_encoding_base32_encode text=`text`*
|
||||
|
||||
## base32_decode
|
||||
+ `text`
|
||||
|
||||
Base32-decode text.
|
||||
|
||||
*> host_encoding_base32_decode text=`text`*
|
||||
@@ -3,16 +3,24 @@ title: lib/foreign
|
||||
description: Run bound code fences and inline sources via local interpreters
|
||||
---
|
||||
|
||||
Run bound code fences and inline sources via local interpreters.
|
||||
|
||||
## set_cmd
|
||||
+ `lang`
|
||||
+ `cmd`
|
||||
|
||||
Bind interpreter command cmd for language lang.
|
||||
|
||||
*> host_foreign_set_cmd lang=`lang` cmd=`cmd`*
|
||||
|
||||
## run
|
||||
+ `code`
|
||||
+ `stdin`=None
|
||||
|
||||
Run a bound code fence value; optional stdin.
|
||||
|
||||
Caller: [foreign.run] code=`block`
|
||||
|
||||
*> host_foreign_run code=`code` stdin=`stdin`*
|
||||
|
||||
## run_lang
|
||||
@@ -20,8 +28,12 @@ description: Run bound code fences and inline sources via local interpreters
|
||||
+ `source`
|
||||
+ `stdin`=None
|
||||
|
||||
Run source text with language lang; optional stdin.
|
||||
|
||||
*> host_foreign_run_lang lang=`lang` source=`source` stdin=`stdin`*
|
||||
|
||||
## langs
|
||||
|
||||
List configured foreign languages.
|
||||
|
||||
*> host_foreign_langs*
|
||||
@@ -3,36 +3,50 @@ title: lib/fs
|
||||
description: English filesystem wrappers
|
||||
---
|
||||
|
||||
English filesystem wrappers
|
||||
|
||||
## read_text
|
||||
+ `path`
|
||||
|
||||
Read UTF-8 text from path.
|
||||
|
||||
*> host_read_text path=`path`*
|
||||
|
||||
## write_text
|
||||
+ `path`
|
||||
+ `text`
|
||||
|
||||
Write text to path (overwrite).
|
||||
|
||||
*> host_write_text path=`path` text=`text`*
|
||||
|
||||
## append_text
|
||||
+ `path`
|
||||
+ `text`
|
||||
|
||||
Append text to path.
|
||||
|
||||
*> host_append_text path=`path` text=`text`*
|
||||
|
||||
## exists
|
||||
+ `path`
|
||||
|
||||
Whether path exists.
|
||||
|
||||
*> host_exists path=`path`*
|
||||
|
||||
## list_dir
|
||||
+ `path`
|
||||
|
||||
List directory entries at path.
|
||||
|
||||
*> host_list_dir path=`path`*
|
||||
|
||||
## make_dir
|
||||
+ `path`
|
||||
|
||||
Create directory at path.
|
||||
|
||||
*> host_make_dir path=`path`*
|
||||
|
||||
## make_dirs
|
||||
@@ -45,6 +59,8 @@ Create directories recursively (`mkdir -p`).
|
||||
## remove
|
||||
+ `path`
|
||||
|
||||
Remove file or empty directory at path.
|
||||
|
||||
*> host_remove path=`path`*
|
||||
|
||||
## remove_tree
|
||||
|
||||
@@ -3,23 +3,35 @@ title: lib/hash
|
||||
description: Digests and HMAC (Mid M3). Integrity / cache keys — not password hashing.
|
||||
---
|
||||
|
||||
Digests and HMAC. For integrity and cache keys — not password storage.
|
||||
|
||||
## sha256
|
||||
+ `text`
|
||||
|
||||
SHA-256 hex digest of text.
|
||||
|
||||
Caller: [hash.sha256] text=`s`
|
||||
|
||||
*> host_hash_sha256 text=`text`*
|
||||
|
||||
## sha1
|
||||
+ `text`
|
||||
|
||||
SHA-1 hex digest of text.
|
||||
|
||||
*> host_hash_sha1 text=`text`*
|
||||
|
||||
## md5
|
||||
+ `text`
|
||||
|
||||
MD5 hex digest of text.
|
||||
|
||||
*> host_hash_md5 text=`text`*
|
||||
|
||||
## hmac_sha256
|
||||
+ `key`
|
||||
+ `text`
|
||||
|
||||
HMAC-SHA256 of text with key.
|
||||
|
||||
*> host_hash_hmac_sha256 key=`key` text=`text`*
|
||||
@@ -3,12 +3,20 @@ title: lib/html
|
||||
description: HTML escape / unescape (Mid2 M8). XSS floor for string assembly.
|
||||
---
|
||||
|
||||
HTML escape helpers. Use before stitching untrusted text into markup.
|
||||
|
||||
## escape
|
||||
+ `text`
|
||||
|
||||
Escape text for HTML.
|
||||
|
||||
Caller: [html.escape] text=`s`
|
||||
|
||||
*> host_html_escape text=`text`*
|
||||
|
||||
## unescape
|
||||
+ `text`
|
||||
|
||||
Unescape HTML entities in text.
|
||||
|
||||
*> host_html_unescape text=`text`*
|
||||
@@ -3,6 +3,8 @@ title: lib/log
|
||||
description: Level-filtered one-line logs (Mid M6 + Mid2 M10 fields). Default level info.
|
||||
---
|
||||
|
||||
Level-filtered one-line logs (Mid M6 + Mid2 M10 fields). Default level info.
|
||||
|
||||
## set_level
|
||||
+ `level`
|
||||
|
||||
@@ -14,6 +16,8 @@ level is debug / info / warn / error.
|
||||
+ `text`
|
||||
+ `fields`=None
|
||||
|
||||
Emit a debug log line; optional fields map.
|
||||
|
||||
**line = > host_log_line level="debug" text=`text` fields=`fields`**
|
||||
1. `line`
|
||||
> print text=`line`
|
||||
@@ -24,6 +28,8 @@ level is debug / info / warn / error.
|
||||
+ `text`
|
||||
+ `fields`=None
|
||||
|
||||
Emit an info log line; optional fields map.
|
||||
|
||||
**line = > host_log_line level="info" text=`text` fields=`fields`**
|
||||
1. `line`
|
||||
> print text=`line`
|
||||
@@ -34,6 +40,8 @@ level is debug / info / warn / error.
|
||||
+ `text`
|
||||
+ `fields`=None
|
||||
|
||||
Emit a warn log line; optional fields map.
|
||||
|
||||
**line = > host_log_line level="warn" text=`text` fields=`fields`**
|
||||
1. `line`
|
||||
> print text=`line`
|
||||
@@ -44,6 +52,8 @@ level is debug / info / warn / error.
|
||||
+ `text`
|
||||
+ `fields`=None
|
||||
|
||||
Emit an error log line; optional fields map.
|
||||
|
||||
**line = > host_log_line level="error" text=`text` fields=`fields`**
|
||||
1. `line`
|
||||
> print text=`line`
|
||||
|
||||
@@ -3,160 +3,222 @@ title: lib/math
|
||||
description: High-school math — num, random, formula, plot
|
||||
---
|
||||
|
||||
High-school math — num, random, formula, plot
|
||||
|
||||
## pi
|
||||
|
||||
pi.
|
||||
|
||||
*> host_pi*
|
||||
|
||||
## e
|
||||
|
||||
e.
|
||||
|
||||
*> host_e*
|
||||
|
||||
## num
|
||||
+ `value`
|
||||
|
||||
num.
|
||||
|
||||
*> host_num value=`value`*
|
||||
|
||||
## add
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
add.
|
||||
|
||||
*> host_math_add a=`a` b=`b`*
|
||||
|
||||
## sub
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
sub.
|
||||
|
||||
*> host_math_sub a=`a` b=`b`*
|
||||
|
||||
## mul
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
mul.
|
||||
|
||||
*> host_math_mul a=`a` b=`b`*
|
||||
|
||||
## div
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
div.
|
||||
|
||||
*> host_math_div a=`a` b=`b`*
|
||||
|
||||
## pow
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
pow.
|
||||
|
||||
*> host_math_pow a=`a` b=`b`*
|
||||
|
||||
## neg
|
||||
+ `value`
|
||||
|
||||
neg.
|
||||
|
||||
*> host_math_neg value=`value`*
|
||||
|
||||
## sin
|
||||
+ `value`
|
||||
|
||||
sin.
|
||||
|
||||
*> host_math_sin value=`value`*
|
||||
|
||||
## cos
|
||||
+ `value`
|
||||
|
||||
cos.
|
||||
|
||||
*> host_math_cos value=`value`*
|
||||
|
||||
## tan
|
||||
+ `value`
|
||||
|
||||
tan.
|
||||
|
||||
*> host_math_tan value=`value`*
|
||||
|
||||
## asin
|
||||
+ `value`
|
||||
|
||||
asin.
|
||||
|
||||
*> host_math_asin value=`value`*
|
||||
|
||||
## acos
|
||||
+ `value`
|
||||
|
||||
acos.
|
||||
|
||||
*> host_math_acos value=`value`*
|
||||
|
||||
## atan
|
||||
+ `value`
|
||||
|
||||
atan.
|
||||
|
||||
*> host_math_atan value=`value`*
|
||||
|
||||
## sqrt
|
||||
+ `value`
|
||||
|
||||
sqrt.
|
||||
|
||||
*> host_math_sqrt value=`value`*
|
||||
|
||||
## abs
|
||||
+ `value`
|
||||
|
||||
abs.
|
||||
|
||||
*> host_math_abs value=`value`*
|
||||
|
||||
## ln
|
||||
+ `value`
|
||||
|
||||
ln.
|
||||
|
||||
*> host_math_ln value=`value`*
|
||||
|
||||
## exp
|
||||
+ `value`
|
||||
|
||||
exp.
|
||||
|
||||
*> host_math_exp value=`value`*
|
||||
|
||||
## floor
|
||||
+ `value`
|
||||
|
||||
floor.
|
||||
|
||||
*> host_math_floor value=`value`*
|
||||
|
||||
## ceil
|
||||
+ `value`
|
||||
|
||||
ceil.
|
||||
|
||||
*> host_math_ceil value=`value`*
|
||||
|
||||
## min
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
min.
|
||||
|
||||
*> host_math_min a=`a` b=`b`*
|
||||
|
||||
## max
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
max.
|
||||
|
||||
*> host_math_max a=`a` b=`b`*
|
||||
|
||||
## random
|
||||
|
||||
random.
|
||||
|
||||
*> host_random*
|
||||
|
||||
## random_int
|
||||
+ `min`
|
||||
+ `max`
|
||||
|
||||
random_int.
|
||||
|
||||
*> host_random_int min=`min` max=`max`*
|
||||
|
||||
## seed
|
||||
+ `value`
|
||||
|
||||
seed.
|
||||
|
||||
*> host_seed value=`value`*
|
||||
|
||||
## formula
|
||||
+ `text`
|
||||
|
||||
formula.
|
||||
|
||||
*> host_formula value=`text`*
|
||||
|
||||
## simplify
|
||||
+ `formula`
|
||||
|
||||
simplify.
|
||||
|
||||
*> host_simplify value=`formula`*
|
||||
|
||||
## expand
|
||||
+ `formula`
|
||||
|
||||
expand.
|
||||
|
||||
*> host_expand value=`formula`*
|
||||
|
||||
## diff
|
||||
+ `formula`
|
||||
+ `var`
|
||||
|
||||
diff.
|
||||
|
||||
*> host_diff formula=`formula` var=`var`*
|
||||
|
||||
## subs
|
||||
@@ -164,6 +226,8 @@ description: High-school math — num, random, formula, plot
|
||||
+ `var`
|
||||
+ `value`
|
||||
|
||||
subs.
|
||||
|
||||
*> host_subs formula=`formula` var=`var` value=`value`*
|
||||
|
||||
## eval
|
||||
@@ -171,6 +235,8 @@ description: High-school math — num, random, formula, plot
|
||||
+ `var`
|
||||
+ `value`
|
||||
|
||||
eval.
|
||||
|
||||
*> host_eval formula=`formula` var=`var` value=`value`*
|
||||
|
||||
## solve
|
||||
@@ -179,6 +245,8 @@ description: High-school math — num, random, formula, plot
|
||||
+ `min`=None
|
||||
+ `max`=None
|
||||
|
||||
solve.
|
||||
|
||||
*> host_solve formula=`formula` var=`var` min=`min` max=`max`*
|
||||
|
||||
## plot
|
||||
@@ -191,6 +259,8 @@ description: High-school math — num, random, formula, plot
|
||||
+ `derivative`=None
|
||||
+ `grid`=None
|
||||
|
||||
plot.
|
||||
|
||||
*> host_plot formula=`formula` var=`var` min=`min` max=`max` steps=`steps` path=`path` derivative=`derivative` grid=`grid`*
|
||||
|
||||
## plot_points
|
||||
@@ -199,6 +269,8 @@ description: High-school math — num, random, formula, plot
|
||||
+ `path`=None
|
||||
+ `grid`=None
|
||||
|
||||
plot_points.
|
||||
|
||||
*> host_plot_points xs=`xs` ys=`ys` path=`path` grid=`grid`*
|
||||
|
||||
## plot_conic
|
||||
@@ -210,4 +282,6 @@ description: High-school math — num, random, formula, plot
|
||||
+ `path`=None
|
||||
+ `grid`=None
|
||||
|
||||
plot_conic.
|
||||
|
||||
*> host_plot_conic kind=`kind` a=`a` b=`b` h=`h` k=`k` path=`path` grid=`grid`*
|
||||
@@ -3,6 +3,8 @@ title: lib/net
|
||||
description: English HTTP(S) wrappers. Optional headers / content_type via host aliases.
|
||||
---
|
||||
|
||||
English HTTP(S) wrappers. Optional headers / content_type via host aliases.
|
||||
|
||||
## http_get
|
||||
+ `url`
|
||||
+ `headers`=None
|
||||
@@ -54,6 +56,8 @@ Optional `body=` / `content_type=` / `headers=`.
|
||||
## url_encode
|
||||
+ `text`
|
||||
|
||||
Percent-encode a URL segment.
|
||||
|
||||
*> host_url_encode text=`text`*
|
||||
|
||||
## cookie_parse
|
||||
|
||||
@@ -3,38 +3,56 @@ title: lib/path
|
||||
description: Path algebra (Mid M2). No I/O; OS separators.
|
||||
---
|
||||
|
||||
Path algebra only. No I/O; separators follow the host OS.
|
||||
|
||||
## join
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
Join path segments a and b.
|
||||
|
||||
Caller: [path.join] a="a" b="b"
|
||||
|
||||
*> host_path_join a=`a` b=`b`*
|
||||
|
||||
## split
|
||||
+ `path`
|
||||
|
||||
Split path into parts.
|
||||
|
||||
*> host_path_split path=`path`*
|
||||
|
||||
## file_name
|
||||
+ `path`
|
||||
|
||||
Final file name of path.
|
||||
|
||||
*> host_path_file_name path=`path`*
|
||||
|
||||
## parent
|
||||
+ `path`
|
||||
|
||||
Parent directory of path.
|
||||
|
||||
*> host_path_parent path=`path`*
|
||||
|
||||
## extension
|
||||
+ `path`
|
||||
|
||||
File extension of path.
|
||||
|
||||
*> host_path_extension path=`path`*
|
||||
|
||||
## normalize
|
||||
+ `path`
|
||||
|
||||
Normalize path (dot segments).
|
||||
|
||||
*> host_path_normalize path=`path`*
|
||||
|
||||
## is_absolute
|
||||
+ `path`
|
||||
|
||||
Whether path is absolute.
|
||||
|
||||
*> host_path_is_absolute path=`path`*
|
||||
+11
-1
@@ -3,22 +3,32 @@ title: lib/plugin
|
||||
description: Load optional native ABI plugins (.dll / .so / .dylib)
|
||||
---
|
||||
|
||||
Load optional native ABI plugins (.dll / .so / .dylib).
|
||||
|
||||
## load
|
||||
+ `path`
|
||||
|
||||
Load a native plugin from path.
|
||||
|
||||
Caller: [plugin.load] path=`so`
|
||||
|
||||
*> host_plugin_load path=`path`*
|
||||
|
||||
## unload
|
||||
|
||||
Unload the current native plugin.
|
||||
|
||||
*> host_plugin_unload*
|
||||
|
||||
## list
|
||||
|
||||
List loaded native plugins.
|
||||
|
||||
*> host_plugin_list*
|
||||
|
||||
## native_path
|
||||
+ `name`
|
||||
|
||||
Resolve installed / local native plugin path (e.g. `agent`).
|
||||
Resolve installed or local native plugin path (e.g. agent).
|
||||
|
||||
*> host_ext_native_path name=`name`*
|
||||
+13
-1
@@ -3,22 +3,32 @@ title: lib/re
|
||||
description: Regular expressions (Mid M1). Unicode; no backreferences.
|
||||
---
|
||||
|
||||
Regular expressions. Unicode; no backreferences. Prefer lib/text for literal replace.
|
||||
|
||||
## is_match
|
||||
+ `text`
|
||||
+ `pattern`
|
||||
|
||||
Whether text matches pattern.
|
||||
|
||||
Caller: [re.is_match] text=`s` pattern="a+"
|
||||
|
||||
*> host_re_is_match text=`text` pattern=`pattern`*
|
||||
|
||||
## find
|
||||
+ `text`
|
||||
+ `pattern`
|
||||
|
||||
First match of pattern in text, or None.
|
||||
|
||||
*> host_re_find text=`text` pattern=`pattern`*
|
||||
|
||||
## find_all
|
||||
+ `text`
|
||||
+ `pattern`
|
||||
|
||||
All matches of pattern in text.
|
||||
|
||||
*> host_re_find_all text=`text` pattern=`pattern`*
|
||||
|
||||
## replace
|
||||
@@ -27,7 +37,7 @@ description: Regular expressions (Mid M1). Unicode; no backreferences.
|
||||
+ `with`
|
||||
+ `count`=None
|
||||
|
||||
Optional `count=` limits replacements (`None` = all).
|
||||
Replace matches of pattern in text with with; optional count limits replacements (None = all).
|
||||
|
||||
*> host_re_replace text=`text` pattern=`pattern` with=`with` count=`count`*
|
||||
|
||||
@@ -35,4 +45,6 @@ Optional `count=` limits replacements (`None` = all).
|
||||
+ `text`
|
||||
+ `pattern`
|
||||
|
||||
Split text on pattern.
|
||||
|
||||
*> host_re_split text=`text` pattern=`pattern`*
|
||||
+6
-2
@@ -3,16 +3,20 @@ title: lib/secrets
|
||||
description: Cryptographic tokens (Mid M3). Do not use math.random for secrets.
|
||||
---
|
||||
|
||||
Cryptographic tokens. Do not use math.random for secrets.
|
||||
|
||||
## token_hex
|
||||
+ `n`=None
|
||||
|
||||
Byte length `n` (default 16). Returns lowercase hex of length `2*n`.
|
||||
Byte length n (default 16). Returns lowercase hex of length 2*n.
|
||||
|
||||
Caller: [secrets.token_hex] n=16
|
||||
|
||||
*> host_secrets_token_hex n=`n`*
|
||||
|
||||
## token_urlsafe
|
||||
+ `n`=None
|
||||
|
||||
Byte length `n` (default 16). URL-safe Base64 without padding.
|
||||
Byte length n (default 16). URL-safe Base64 without padding.
|
||||
|
||||
*> host_secrets_token_urlsafe n=`n`*
|
||||
@@ -3,14 +3,22 @@ title: lib/stats
|
||||
description: Thin mean / median / sample stdev (Mid2 M10). Not a dataframe library.
|
||||
---
|
||||
|
||||
Thin numeric summaries. Not a dataframe library.
|
||||
|
||||
## mean
|
||||
+ `list`
|
||||
|
||||
Arithmetic mean of list.
|
||||
|
||||
Caller: [stats.mean] list=`xs`
|
||||
|
||||
*> host_stats_mean list=`list`*
|
||||
|
||||
## median
|
||||
+ `list`
|
||||
|
||||
Median of list.
|
||||
|
||||
*> host_stats_median list=`list`*
|
||||
|
||||
## stdev
|
||||
|
||||
+13
-4
@@ -3,6 +3,8 @@ title: lib/subtask
|
||||
description: Concurrent subtasks — file, function, or foreign code
|
||||
---
|
||||
|
||||
Concurrent subtasks: file, function, or foreign code.
|
||||
|
||||
## spawn
|
||||
+ `path`=None
|
||||
+ `fn`=None
|
||||
@@ -13,28 +15,35 @@ description: Concurrent subtasks — file, function, or foreign code
|
||||
+ `stdin`=None
|
||||
+ `quiet`=True
|
||||
|
||||
File children are silent by default (`quiet=True`: piped capture, no TTY noise).
|
||||
Set `quiet=False` to inherit parent stdout/stderr.
|
||||
File `wait` returns `{code, value}` plus optional `stdout`/`stderr` tails when quiet-captured.
|
||||
`value` is the child's `# main` return (not stdout).
|
||||
Start a subtask. File children are silent by default (quiet=True: piped capture). Set quiet=False to inherit parent stdout/stderr. File wait returns {code, value} plus optional stdout/stderr tails when quiet-captured. value is the child main return (not stdout).
|
||||
|
||||
Caller: [subtask.spawn] path="child.mq.md"
|
||||
|
||||
*> host_subtask_spawn path=`path` fn=`fn` args=`args` code=`code` lang=`lang` source=`source` stdin=`stdin` quiet=`quiet`*
|
||||
|
||||
## poll
|
||||
+ `id`
|
||||
|
||||
Non-blocking status for subtask id.
|
||||
|
||||
*> host_subtask_poll id=`id`*
|
||||
|
||||
## wait
|
||||
+ `id`
|
||||
|
||||
Block until subtask id finishes.
|
||||
|
||||
*> host_subtask_join id=`id`*
|
||||
|
||||
## kill
|
||||
+ `id`
|
||||
|
||||
Kill subtask id.
|
||||
|
||||
*> host_subtask_kill id=`id`*
|
||||
|
||||
## wait_all
|
||||
|
||||
Wait until every spawned subtask finishes.
|
||||
|
||||
*> host_subtask_wait_all*
|
||||
@@ -3,15 +3,21 @@ title: lib/sys
|
||||
description: English system wrappers (load_dotenv accepts optional path via host alias)
|
||||
---
|
||||
|
||||
English system wrappers (load_dotenv accepts optional path via host alias)
|
||||
|
||||
## env_get
|
||||
+ `name`
|
||||
|
||||
Get environment variable name.
|
||||
|
||||
*> host_env_get name=`name`*
|
||||
|
||||
## env_set
|
||||
+ `name`
|
||||
+ `value`
|
||||
|
||||
Set environment variable name to value.
|
||||
|
||||
*> host_env_set name=`name` value=`value`*
|
||||
|
||||
## load_dotenv
|
||||
@@ -23,15 +29,21 @@ Load `.env` (optional named arg `path=`). Existing process env is not overridden
|
||||
|
||||
## args
|
||||
|
||||
Process argv list.
|
||||
|
||||
*> host_args*
|
||||
|
||||
## cwd
|
||||
|
||||
Current working directory.
|
||||
|
||||
*> host_cwd*
|
||||
|
||||
## exit
|
||||
+ `code`
|
||||
|
||||
Exit process with code.
|
||||
|
||||
*> host_exit code=`code`*
|
||||
|
||||
## exec
|
||||
|
||||
@@ -3,27 +3,41 @@ title: lib/time
|
||||
description: English time wrappers
|
||||
---
|
||||
|
||||
Unix time, format, parse, and sleep helpers.
|
||||
|
||||
## now_unix
|
||||
|
||||
Current Unix time in seconds.
|
||||
|
||||
Caller: [time.now_unix]
|
||||
|
||||
*> host_now_unix*
|
||||
|
||||
## now_ms
|
||||
|
||||
Current Unix time in milliseconds.
|
||||
|
||||
*> host_now_ms*
|
||||
|
||||
## format
|
||||
+ `unix`
|
||||
+ `pattern`
|
||||
|
||||
Format unix seconds with pattern.
|
||||
|
||||
*> host_format_time unix=`unix` pattern=`pattern`*
|
||||
|
||||
## sleep_ms
|
||||
+ `ms`
|
||||
|
||||
Sleep for ms milliseconds.
|
||||
|
||||
*> host_sleep_ms ms=`ms`*
|
||||
|
||||
## parse
|
||||
+ `text`
|
||||
+ `pattern`
|
||||
|
||||
Parse text as time with pattern; returns unix seconds.
|
||||
|
||||
*> host_parse_time text=`text` pattern=`pattern`*
|
||||
@@ -3,7 +3,13 @@ title: lib/toml
|
||||
description: Read-only TOML subset parse (Mid2 M8). Tables, scalars, arrays; no array-of-tables.
|
||||
---
|
||||
|
||||
Read-only TOML subset. Prefer for config files; not a full TOML writer.
|
||||
|
||||
## parse
|
||||
+ `text`
|
||||
|
||||
Parse TOML text into maps/lists/scalars.
|
||||
|
||||
Caller: [toml.parse] text=`cfg`
|
||||
|
||||
*> host_toml_parse text=`text`*
|
||||
+8
-2
@@ -3,21 +3,27 @@ title: lib/url
|
||||
description: Parse URLs and query strings (Mid2 M7). Segment encoding stays in net.url_encode.
|
||||
---
|
||||
|
||||
Parse URLs and query strings. Segment encoding stays in net.url_encode.
|
||||
|
||||
## parse
|
||||
+ `text`
|
||||
|
||||
Returns `{scheme, userinfo, host, port, path, query, fragment}`.
|
||||
Parse URL text into scheme, userinfo, host, port, path, query, fragment.
|
||||
|
||||
Caller: [url.parse] text=`u`
|
||||
|
||||
*> host_url_parse text=`text`*
|
||||
|
||||
## query_parse
|
||||
+ `text`
|
||||
|
||||
Parse `a=1&b=2` into a map; repeated keys become a list.
|
||||
Parse a=1&b=2 into a map; repeated keys become a list.
|
||||
|
||||
*> host_url_query_parse text=`text`*
|
||||
|
||||
## query_stringify
|
||||
+ `map`
|
||||
|
||||
Build a query string from map.
|
||||
|
||||
*> host_url_query_stringify map=`map`*
|
||||
@@ -3,6 +3,12 @@ title: lib/uuid
|
||||
description: UUID v4 (Mid M6). Cryptographic random via getrandom.
|
||||
---
|
||||
|
||||
Random UUID helpers. Prefer this over rolling your own ids.
|
||||
|
||||
## v4
|
||||
|
||||
New UUID version 4 string.
|
||||
|
||||
Caller: [uuid.v4]
|
||||
|
||||
*> host_uuid_v4*
|
||||
@@ -3,6 +3,8 @@ title: lib/writeback
|
||||
description: Persist run output in .mq.md (Jupyter-style writeback)
|
||||
---
|
||||
|
||||
Persist run output in .mq.md (Jupyter-style writeback)
|
||||
|
||||
## record
|
||||
+ `value`
|
||||
+ `at_end`=False
|
||||
|
||||
+5
-1
@@ -3,9 +3,13 @@ title: lib/命令行
|
||||
description: 解析命令行参数(中层 M5)。--键 值 / --键=值 / --开关;位置参在 _。
|
||||
---
|
||||
|
||||
把进程参数解析成映射。开关与位置参(落在 _)。
|
||||
|
||||
## 解析
|
||||
+ `参数`=None
|
||||
|
||||
省略 `参数` 时用进程 argv(系统.参数表)。
|
||||
解析 --键 值 / --键=值 / --开关。裸 --开关 若当布尔,后面不要紧跟非选项词(开关放最后,或写 --开关=true)。位置参进 _。省略参数时用进程 argv(系统.参数表)。
|
||||
|
||||
调用例:[命令行.解析]
|
||||
|
||||
*> host_cli_parse args=`参数`*
|
||||
@@ -3,23 +3,35 @@ title: lib/哈希
|
||||
description: 摘要与 HMAC(中层 M3)。完整性 / 缓存键 — 非密码存储。
|
||||
---
|
||||
|
||||
摘要与 HMAC。用于完整性与缓存键 — 不是密码存储。
|
||||
|
||||
## 哈希256
|
||||
+ `内容`
|
||||
|
||||
内容的 SHA-256 十六进制摘要。
|
||||
|
||||
调用例:[哈希.哈希256] 内容=`s`
|
||||
|
||||
*> host_hash_sha256 text=`内容`*
|
||||
|
||||
## 哈希1
|
||||
+ `内容`
|
||||
|
||||
内容的 SHA-1 十六进制摘要。
|
||||
|
||||
*> host_hash_sha1 text=`内容`*
|
||||
|
||||
## md5
|
||||
+ `内容`
|
||||
|
||||
内容的 MD5 十六进制摘要。
|
||||
|
||||
*> host_hash_md5 text=`内容`*
|
||||
|
||||
## 密钥哈希256
|
||||
+ `密钥`
|
||||
+ `内容`
|
||||
|
||||
用密钥对内容做 HMAC-SHA256。
|
||||
|
||||
*> host_hash_hmac_sha256 key=`密钥` text=`内容`*
|
||||
+11
-1
@@ -1,19 +1,29 @@
|
||||
---
|
||||
title: lib/地址
|
||||
description: 解析 URL 与查询串(中层 Mid2 M7)。单段编码仍用 `网络.网址编码`。
|
||||
description: 解析 URL 与查询串(中层 Mid2 M7)。单段编码仍用网络.网址编码。
|
||||
---
|
||||
|
||||
解析 URL 与查询串。单段编码仍用网络.网址编码。
|
||||
|
||||
## 解析
|
||||
+ `内容`
|
||||
|
||||
把 URL 解析成 scheme / userinfo / host / port / path / query / fragment。
|
||||
|
||||
调用例:[地址.解析] 内容=`u`
|
||||
|
||||
*> host_url_parse text=`内容`*
|
||||
|
||||
## 查询解析
|
||||
+ `内容`
|
||||
|
||||
把 a=1&b=2 解析成映射;重复键变成列表。
|
||||
|
||||
*> host_url_query_parse text=`内容`*
|
||||
|
||||
## 查询串化
|
||||
+ `表`
|
||||
|
||||
把映射编成查询串。
|
||||
|
||||
*> host_url_query_stringify map=`表`*
|
||||
@@ -3,16 +3,24 @@ title: lib/外联
|
||||
description: 通过本机解释器运行绑定的代码围栏与内联源码
|
||||
---
|
||||
|
||||
通过本机解释器运行绑定的代码围栏与内联源码。
|
||||
|
||||
## 设置命令
|
||||
+ `语言`
|
||||
+ `命令`
|
||||
|
||||
为语言绑定解释器命令。
|
||||
|
||||
*> host_foreign_set_cmd lang=`语言` cmd=`命令`*
|
||||
|
||||
## 运行
|
||||
+ `代码`
|
||||
+ `标准输入`=None
|
||||
|
||||
运行已绑定的代码围栏值;可选标准输入。
|
||||
|
||||
调用例:[外联.运行] 代码=`块`
|
||||
|
||||
*> host_foreign_run code=`代码` stdin=`标准输入`*
|
||||
|
||||
## 按语言运行
|
||||
@@ -20,8 +28,12 @@ description: 通过本机解释器运行绑定的代码围栏与内联源码
|
||||
+ `源码`
|
||||
+ `标准输入`=None
|
||||
|
||||
用语言运行源码文本;可选标准输入。
|
||||
|
||||
*> host_foreign_run_lang lang=`语言` source=`源码` stdin=`标准输入`*
|
||||
|
||||
## 语言表
|
||||
|
||||
列出已配置的外联语言。
|
||||
|
||||
*> host_foreign_langs*
|
||||
+13
-3
@@ -3,6 +3,8 @@ title: lib/子任务
|
||||
description: 并发子任务 — 文件、函数或外联代码
|
||||
---
|
||||
|
||||
并发子任务:文件、函数或外联代码。
|
||||
|
||||
## 启动
|
||||
+ `路径`=None
|
||||
+ `函数`=None
|
||||
@@ -13,27 +15,35 @@ description: 并发子任务 — 文件、函数或外联代码
|
||||
+ `输入`=None
|
||||
+ `静默`=True
|
||||
|
||||
文件子任务默认静默(`静默=真`:管道捕获 stdout/stderr,不污染父终端)。
|
||||
`静默=假` 时继承父进程终端输出。
|
||||
文件 `等待` 返回 `{code, value}`,静默捕获时另含截断的 `stdout`/`stderr`;`value` 为子 `# main` 返回值。
|
||||
启动子任务。文件子任务默认静默(静默=真:管道捕获)。静默=假 时继承父终端。文件等待返回 {code, value},静默捕获时另含截断的 stdout/stderr;value 为子 main 返回值。
|
||||
|
||||
调用例:[子任务.启动] 路径="child.mq.md"
|
||||
|
||||
*> host_subtask_spawn path=`路径` fn=`函数` args=`参数` code=`代码` lang=`语言` source=`源码` stdin=`输入` quiet=`静默`*
|
||||
|
||||
## 探测
|
||||
+ `id`
|
||||
|
||||
非阻塞查看子任务 id 状态。
|
||||
|
||||
*> host_subtask_poll id=`id`*
|
||||
|
||||
## 等待
|
||||
+ `id`
|
||||
|
||||
阻塞直到子任务 id 结束。
|
||||
|
||||
*> host_subtask_join id=`id`*
|
||||
|
||||
## 终止
|
||||
+ `id`
|
||||
|
||||
终止子任务 id。
|
||||
|
||||
*> host_subtask_kill id=`id`*
|
||||
|
||||
## 等待全部
|
||||
|
||||
等待全部已启动子任务结束。
|
||||
|
||||
*> host_subtask_wait_all*
|
||||
+11
-1
@@ -3,22 +3,32 @@ title: lib/插件
|
||||
description: 加载可选原生 ABI 插件(.dll / .so / .dylib)
|
||||
---
|
||||
|
||||
加载可选原生 ABI 插件(.dll / .so / .dylib)。
|
||||
|
||||
## 加载
|
||||
+ `路径`
|
||||
|
||||
从路径加载原生插件。
|
||||
|
||||
调用例:[插件.加载] 路径=`so`
|
||||
|
||||
*> host_plugin_load path=`路径`*
|
||||
|
||||
## 卸载
|
||||
|
||||
卸载当前原生插件。
|
||||
|
||||
*> host_plugin_unload*
|
||||
|
||||
## 列出
|
||||
|
||||
列出已加载的原生插件。
|
||||
|
||||
*> host_plugin_list*
|
||||
|
||||
## 原生路径
|
||||
+ `名`
|
||||
|
||||
解析已安装或本地原生插件路径(如 `agent`)。
|
||||
解析已安装或本地原生插件路径(如 agent)。
|
||||
|
||||
*> host_ext_native_path name=`名`*
|
||||
@@ -3,160 +3,222 @@ title: lib/数学
|
||||
description: 高中数学 — 数值、随机、公式、作图
|
||||
---
|
||||
|
||||
高中数学 — 数值、随机、公式、作图
|
||||
|
||||
## 圆周率
|
||||
|
||||
圆周率。
|
||||
|
||||
*> host_pi*
|
||||
|
||||
## 自然底数
|
||||
|
||||
自然底数。
|
||||
|
||||
*> host_e*
|
||||
|
||||
## 数
|
||||
+ `value`
|
||||
|
||||
数。
|
||||
|
||||
*> host_num value=`value`*
|
||||
|
||||
## 加
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
加。
|
||||
|
||||
*> host_math_add a=`a` b=`b`*
|
||||
|
||||
## 减
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
减。
|
||||
|
||||
*> host_math_sub a=`a` b=`b`*
|
||||
|
||||
## 乘
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
乘。
|
||||
|
||||
*> host_math_mul a=`a` b=`b`*
|
||||
|
||||
## 除
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
除。
|
||||
|
||||
*> host_math_div a=`a` b=`b`*
|
||||
|
||||
## 幂
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
幂。
|
||||
|
||||
*> host_math_pow a=`a` b=`b`*
|
||||
|
||||
## 负
|
||||
+ `value`
|
||||
|
||||
负。
|
||||
|
||||
*> host_math_neg value=`value`*
|
||||
|
||||
## 正弦
|
||||
+ `value`
|
||||
|
||||
正弦。
|
||||
|
||||
*> host_math_sin value=`value`*
|
||||
|
||||
## 余弦
|
||||
+ `value`
|
||||
|
||||
余弦。
|
||||
|
||||
*> host_math_cos value=`value`*
|
||||
|
||||
## 正切
|
||||
+ `value`
|
||||
|
||||
正切。
|
||||
|
||||
*> host_math_tan value=`value`*
|
||||
|
||||
## 反正弦
|
||||
+ `value`
|
||||
|
||||
反正弦。
|
||||
|
||||
*> host_math_asin value=`value`*
|
||||
|
||||
## 反余弦
|
||||
+ `value`
|
||||
|
||||
反余弦。
|
||||
|
||||
*> host_math_acos value=`value`*
|
||||
|
||||
## 反正切
|
||||
+ `value`
|
||||
|
||||
反正切。
|
||||
|
||||
*> host_math_atan value=`value`*
|
||||
|
||||
## 平方根
|
||||
+ `value`
|
||||
|
||||
平方根。
|
||||
|
||||
*> host_math_sqrt value=`value`*
|
||||
|
||||
## 绝对值
|
||||
+ `value`
|
||||
|
||||
绝对值。
|
||||
|
||||
*> host_math_abs value=`value`*
|
||||
|
||||
## 对数
|
||||
+ `value`
|
||||
|
||||
对数。
|
||||
|
||||
*> host_math_ln value=`value`*
|
||||
|
||||
## 指数
|
||||
+ `value`
|
||||
|
||||
指数。
|
||||
|
||||
*> host_math_exp value=`value`*
|
||||
|
||||
## 向下取整
|
||||
+ `value`
|
||||
|
||||
向下取整。
|
||||
|
||||
*> host_math_floor value=`value`*
|
||||
|
||||
## 向上取整
|
||||
+ `value`
|
||||
|
||||
向上取整。
|
||||
|
||||
*> host_math_ceil value=`value`*
|
||||
|
||||
## 最小
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
最小。
|
||||
|
||||
*> host_math_min a=`a` b=`b`*
|
||||
|
||||
## 最大
|
||||
+ `a`
|
||||
+ `b`
|
||||
|
||||
最大。
|
||||
|
||||
*> host_math_max a=`a` b=`b`*
|
||||
|
||||
## 随机
|
||||
|
||||
随机。
|
||||
|
||||
*> host_random*
|
||||
|
||||
## 随机整数
|
||||
+ `min`
|
||||
+ `max`
|
||||
|
||||
随机整数。
|
||||
|
||||
*> host_random_int min=`min` max=`max`*
|
||||
|
||||
## 设种子
|
||||
+ `value`
|
||||
|
||||
设种子。
|
||||
|
||||
*> host_seed value=`value`*
|
||||
|
||||
## 公式
|
||||
+ `text`
|
||||
|
||||
公式。
|
||||
|
||||
*> host_formula value=`text`*
|
||||
|
||||
## 化简
|
||||
+ `formula`
|
||||
|
||||
化简。
|
||||
|
||||
*> host_simplify value=`formula`*
|
||||
|
||||
## 展开
|
||||
+ `formula`
|
||||
|
||||
展开。
|
||||
|
||||
*> host_expand value=`formula`*
|
||||
|
||||
## 求导
|
||||
+ `formula`
|
||||
+ `var`
|
||||
|
||||
求导。
|
||||
|
||||
*> host_diff formula=`formula` var=`var`*
|
||||
|
||||
## 代入
|
||||
@@ -164,6 +226,8 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `var`
|
||||
+ `value`
|
||||
|
||||
代入。
|
||||
|
||||
*> host_subs formula=`formula` var=`var` value=`value`*
|
||||
|
||||
## 求值
|
||||
@@ -171,6 +235,8 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `var`
|
||||
+ `value`
|
||||
|
||||
求值。
|
||||
|
||||
*> host_eval formula=`formula` var=`var` value=`value`*
|
||||
|
||||
## 求解
|
||||
@@ -179,6 +245,8 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `min`=None
|
||||
+ `max`=None
|
||||
|
||||
求解。
|
||||
|
||||
*> host_solve formula=`formula` var=`var` min=`min` max=`max`*
|
||||
|
||||
## 绘图
|
||||
@@ -191,6 +259,8 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `derivative`=None
|
||||
+ `grid`=None
|
||||
|
||||
绘图。
|
||||
|
||||
*> host_plot formula=`formula` var=`var` min=`min` max=`max` steps=`steps` path=`path` derivative=`derivative` grid=`grid`*
|
||||
|
||||
## 绘点列
|
||||
@@ -199,6 +269,8 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `path`=None
|
||||
+ `grid`=None
|
||||
|
||||
绘点列。
|
||||
|
||||
*> host_plot_points xs=`xs` ys=`ys` path=`path` grid=`grid`*
|
||||
|
||||
## 绘圆锥
|
||||
@@ -210,4 +282,6 @@ description: 高中数学 — 数值、随机、公式、作图
|
||||
+ `path`=None
|
||||
+ `grid`=None
|
||||
|
||||
绘圆锥。
|
||||
|
||||
*> host_plot_conic kind=`kind` a=`a` b=`b` h=`h` k=`k` path=`path` grid=`grid`*
|
||||
@@ -3,36 +3,50 @@ title: lib/文件
|
||||
description: 中文文件系统包装
|
||||
---
|
||||
|
||||
中文文件系统包装
|
||||
|
||||
## 读文本
|
||||
+ `路径`
|
||||
|
||||
从路径读取 UTF-8 文本。
|
||||
|
||||
*> host_read_text path=`路径`*
|
||||
|
||||
## 写文本
|
||||
+ `路径`
|
||||
+ `内容`
|
||||
|
||||
把文本写入路径(覆盖)。
|
||||
|
||||
*> host_write_text path=`路径` text=`内容`*
|
||||
|
||||
## 追加文本
|
||||
+ `路径`
|
||||
+ `内容`
|
||||
|
||||
向路径追加文本。
|
||||
|
||||
*> host_append_text path=`路径` text=`内容`*
|
||||
|
||||
## 存在
|
||||
+ `路径`
|
||||
|
||||
路径是否存在。
|
||||
|
||||
*> host_exists path=`路径`*
|
||||
|
||||
## 列目录
|
||||
+ `路径`
|
||||
|
||||
列出路径下的目录项。
|
||||
|
||||
*> host_list_dir path=`路径`*
|
||||
|
||||
## 建目录
|
||||
+ `路径`
|
||||
|
||||
创建目录。
|
||||
|
||||
*> host_make_dir path=`路径`*
|
||||
|
||||
## 建目录树
|
||||
@@ -45,6 +59,8 @@ description: 中文文件系统包装
|
||||
## 删除
|
||||
+ `路径`
|
||||
|
||||
删除路径上的文件或空目录。
|
||||
|
||||
*> host_remove path=`路径`*
|
||||
|
||||
## 删目录树
|
||||
|
||||
@@ -3,6 +3,8 @@ title: lib/日志
|
||||
description: 按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。默认级别 info。
|
||||
---
|
||||
|
||||
按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。默认级别 info。
|
||||
|
||||
## 设级别
|
||||
+ `级别`
|
||||
|
||||
@@ -14,6 +16,8 @@ description: 按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。
|
||||
+ `内容`
|
||||
+ `字段`=None
|
||||
|
||||
写出调试日志行;可选字段映射。
|
||||
|
||||
**line = > host_log_line level="debug" text=`内容` fields=`字段`**
|
||||
1. `line`
|
||||
> 打印 内容=`line`
|
||||
@@ -24,6 +28,8 @@ description: 按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。
|
||||
+ `内容`
|
||||
+ `字段`=None
|
||||
|
||||
写出信息日志行;可选字段映射。
|
||||
|
||||
**line = > host_log_line level="info" text=`内容` fields=`字段`**
|
||||
1. `line`
|
||||
> 打印 内容=`line`
|
||||
@@ -34,6 +40,8 @@ description: 按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。
|
||||
+ `内容`
|
||||
+ `字段`=None
|
||||
|
||||
写出警告日志行;可选字段映射。
|
||||
|
||||
**line = > host_log_line level="warn" text=`内容` fields=`字段`**
|
||||
1. `line`
|
||||
> 打印 内容=`line`
|
||||
@@ -44,6 +52,8 @@ description: 按级别过滤的一行日志(中层 M6 + Mid2 M10 字段)。
|
||||
+ `内容`
|
||||
+ `字段`=None
|
||||
|
||||
写出错误日志行;可选字段映射。
|
||||
|
||||
**line = > host_log_line level="error" text=`内容` fields=`字段`**
|
||||
1. `line`
|
||||
> 打印 内容=`line`
|
||||
|
||||
@@ -3,31 +3,43 @@ title: lib/日期时间
|
||||
description: 日历时刻 map `{unix, zone, iso}`(中层 Mid2 M7)。固定偏移与少量 IANA 别名。
|
||||
---
|
||||
|
||||
日历时刻 map `{unix, zone, iso}`(中层 Mid2 M7)。固定偏移与少量 IANA 别名。
|
||||
|
||||
## 现在
|
||||
|
||||
现在。
|
||||
|
||||
*> host_datetime_now*
|
||||
|
||||
## 自戳
|
||||
+ `秒`
|
||||
+ `区`=None
|
||||
|
||||
自戳。
|
||||
|
||||
*> host_datetime_from_unix unix=`秒` zone=`区`*
|
||||
|
||||
## 成戳
|
||||
+ `时刻`
|
||||
|
||||
成戳。
|
||||
|
||||
*> host_datetime_to_unix dt=`时刻`*
|
||||
|
||||
## 解析
|
||||
+ `内容`
|
||||
+ `格式`=None
|
||||
|
||||
解析。
|
||||
|
||||
*> host_datetime_parse text=`内容` pattern=`格式`*
|
||||
|
||||
## 格式化
|
||||
+ `时刻`
|
||||
+ `样式`=None
|
||||
|
||||
格式化。
|
||||
|
||||
*> host_datetime_format dt=`时刻` style=`样式`*
|
||||
|
||||
## 加
|
||||
@@ -37,10 +49,14 @@ description: 日历时刻 map `{unix, zone, iso}`(中层 Mid2 M7)。固定
|
||||
+ `分钟`=None
|
||||
+ `秒数`=None
|
||||
|
||||
加。
|
||||
|
||||
*> host_datetime_add dt=`时刻` days=`天` hours=`小时` minutes=`分钟` seconds=`秒数`*
|
||||
|
||||
## 时区
|
||||
+ `时刻`
|
||||
+ `区`
|
||||
|
||||
时区。
|
||||
|
||||
*> host_datetime_in_zone dt=`时刻` zone=`区`*
|
||||
@@ -3,27 +3,41 @@ title: lib/时间
|
||||
description: 中文时间包装
|
||||
---
|
||||
|
||||
Unix 时间、格式化、解析与睡眠。
|
||||
|
||||
## 此刻秒
|
||||
|
||||
当前 Unix 秒。
|
||||
|
||||
调用例:[时间.此刻秒]
|
||||
|
||||
*> host_now_unix*
|
||||
|
||||
## 此刻毫秒
|
||||
|
||||
当前 Unix 毫秒。
|
||||
|
||||
*> host_now_ms*
|
||||
|
||||
## 格式化
|
||||
+ `秒`
|
||||
+ `格式`
|
||||
|
||||
用格式把秒格式化成文本。
|
||||
|
||||
*> host_format_time unix=`秒` pattern=`格式`*
|
||||
|
||||
## 睡眠毫秒
|
||||
+ `毫秒`
|
||||
|
||||
睡眠指定的毫秒数。
|
||||
|
||||
*> host_sleep_ms ms=`毫秒`*
|
||||
|
||||
## 解析时间
|
||||
+ `内容`
|
||||
+ `格式`
|
||||
|
||||
按格式解析内容,得到 Unix 秒。
|
||||
|
||||
*> host_parse_time text=`内容` pattern=`格式`*
|
||||
+5
-1
@@ -3,10 +3,14 @@ title: lib/机密
|
||||
description: 安全随机令牌(中层 M3)。勿用 math.random 生成令牌。
|
||||
---
|
||||
|
||||
安全随机令牌。勿用 math.random 生成令牌。
|
||||
|
||||
## 十六进制令牌
|
||||
+ `字节数`=None
|
||||
|
||||
字节长度(默认 16),返回长度为 `2*字节数` 的小写 hex。
|
||||
字节长度(默认 16),返回长度为 2*字节数 的小写 hex。
|
||||
|
||||
调用例:[机密.十六进制令牌] 字节数=16
|
||||
|
||||
*> host_secrets_token_hex n=`字节数`*
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@ title: lib/标识
|
||||
description: UUID 版本 4(中层 M6)。经 getrandom 安全随机。
|
||||
---
|
||||
|
||||
随机 UUID。不要自己拼不可靠的标识。
|
||||
|
||||
## 版本4
|
||||
|
||||
生成 UUID 版本 4 字符串。
|
||||
|
||||
调用例:[标识.版本4]
|
||||
|
||||
*> host_uuid_v4*
|
||||
+13
-1
@@ -3,22 +3,32 @@ title: lib/正则
|
||||
description: 正则表达式(中层 M1)。Unicode;无回溯引用。
|
||||
---
|
||||
|
||||
正则表达式。Unicode;无回溯引用。字面替换请用 lib/文本。
|
||||
|
||||
## 匹配
|
||||
+ `内容`
|
||||
+ `模式`
|
||||
|
||||
内容是否匹配模式。
|
||||
|
||||
调用例:[正则.匹配] 内容=`s` 模式="a+"
|
||||
|
||||
*> host_re_is_match text=`内容` pattern=`模式`*
|
||||
|
||||
## 查找
|
||||
+ `内容`
|
||||
+ `模式`
|
||||
|
||||
在内容中查找模式的首个匹配;没有 → None。
|
||||
|
||||
*> host_re_find text=`内容` pattern=`模式`*
|
||||
|
||||
## 查找全部
|
||||
+ `内容`
|
||||
+ `模式`
|
||||
|
||||
在内容中查找模式的全部匹配。
|
||||
|
||||
*> host_re_find_all text=`内容` pattern=`模式`*
|
||||
|
||||
## 替换
|
||||
@@ -27,7 +37,7 @@ description: 正则表达式(中层 M1)。Unicode;无回溯引用。
|
||||
+ `为`
|
||||
+ `次数`=None
|
||||
|
||||
可选 `次数=` 限制替换次数(缺省 = 全部)。
|
||||
用为替换内容中匹配模式的部分;可选次数限制(缺省 = 全部)。
|
||||
|
||||
*> host_re_replace text=`内容` pattern=`模式` with=`为` count=`次数`*
|
||||
|
||||
@@ -35,4 +45,6 @@ description: 正则表达式(中层 M1)。Unicode;无回溯引用。
|
||||
+ `内容`
|
||||
+ `模式`
|
||||
|
||||
按模式拆分内容。
|
||||
|
||||
*> host_re_split text=`内容` pattern=`模式`*
|
||||
@@ -5,6 +5,8 @@ description: >-
|
||||
import table:lib/table.mq.md
|
||||
---
|
||||
|
||||
浏览器效应助手(WASM 客户端)。优先 GFM 表格 + 本库;勿用 json.set 链拼效应。
|
||||
|
||||
## 设文本
|
||||
+ `选择器`
|
||||
+ `文本`
|
||||
@@ -135,6 +137,8 @@ import table:lib/table.mq.md
|
||||
## 聚焦
|
||||
+ `选择器`
|
||||
|
||||
聚焦。
|
||||
|
||||
*> table.put in=None at="focus" value=选择器*
|
||||
|
||||
## 导航
|
||||
@@ -152,6 +156,8 @@ import table:lib/table.mq.md
|
||||
## 存储
|
||||
+ `规格`
|
||||
|
||||
存储。
|
||||
|
||||
*> table.put in=None at="storage" value=规格*
|
||||
|
||||
## 定时
|
||||
@@ -170,6 +176,8 @@ import table:lib/table.mq.md
|
||||
## 清定时
|
||||
+ `id`="default"
|
||||
|
||||
清定时。
|
||||
|
||||
**`spec` = > table.put in=None at="id" value=id**
|
||||
*> table.put in=None at="clear_interval" value=spec*
|
||||
|
||||
@@ -213,11 +221,15 @@ import table:lib/table.mq.md
|
||||
## 套接字
|
||||
+ `规格`
|
||||
|
||||
套接字。
|
||||
|
||||
*> table.put in=None at="ws" value=规格*
|
||||
|
||||
## 剪贴板
|
||||
+ `文本`
|
||||
|
||||
剪贴板。
|
||||
|
||||
**`spec` = > table.put in=None at="text" value=文本**
|
||||
*> table.put in=None at="clipboard" value=spec*
|
||||
|
||||
|
||||
@@ -3,15 +3,21 @@ title: lib/系统
|
||||
description: 中文系统包装(加载环境 可选 路径=)
|
||||
---
|
||||
|
||||
中文系统包装(加载环境 可选 路径=)
|
||||
|
||||
## 取环境
|
||||
+ `名`
|
||||
|
||||
读取环境变量名。
|
||||
|
||||
*> host_env_get name=`名`*
|
||||
|
||||
## 设环境
|
||||
+ `名`
|
||||
+ `值`
|
||||
|
||||
设置环境变量名的值。
|
||||
|
||||
*> host_env_set name=`名` value=`值`*
|
||||
|
||||
## 加载环境
|
||||
@@ -23,15 +29,21 @@ description: 中文系统包装(加载环境 可选 路径=)
|
||||
|
||||
## 参数表
|
||||
|
||||
进程参数表。
|
||||
|
||||
*> host_args*
|
||||
|
||||
## 工作目录
|
||||
|
||||
当前工作目录。
|
||||
|
||||
*> host_cwd*
|
||||
|
||||
## 退出
|
||||
+ `码`
|
||||
|
||||
以代码退出进程。
|
||||
|
||||
*> host_exit code=`码`*
|
||||
|
||||
## 执行
|
||||
|
||||
@@ -3,14 +3,22 @@ title: lib/统计
|
||||
description: 薄均值 / 中位数 / 样本标准差(中层 Mid2 M10)。非数据框库。
|
||||
---
|
||||
|
||||
薄数值摘要。不是数据框库。
|
||||
|
||||
## 均值
|
||||
+ `列表`
|
||||
|
||||
列表的算术均值。
|
||||
|
||||
调用例:[统计.均值] 列表=`xs`
|
||||
|
||||
*> host_stats_mean list=`列表`*
|
||||
|
||||
## 中位数
|
||||
+ `列表`
|
||||
|
||||
列表的中位数。
|
||||
|
||||
*> host_stats_median list=`列表`*
|
||||
|
||||
## 标准差
|
||||
|
||||
@@ -3,32 +3,48 @@ title: lib/编码
|
||||
description: Base64、十六进制与基32编解码(中层 M1 + Mid2 M8)。UTF-8 文本往返。
|
||||
---
|
||||
|
||||
Base64、十六进制与基32编解码。UTF-8 文本往返。
|
||||
|
||||
## 基64编码
|
||||
+ `内容`
|
||||
|
||||
对内容做 Base64 编码。
|
||||
|
||||
调用例:[编码.基64编码] 内容=`s`
|
||||
|
||||
*> host_encoding_base64_encode text=`内容`*
|
||||
|
||||
## 基64解码
|
||||
+ `内容`
|
||||
|
||||
对内容做 Base64 解码。
|
||||
|
||||
*> host_encoding_base64_decode text=`内容`*
|
||||
|
||||
## 十六进制编码
|
||||
+ `内容`
|
||||
|
||||
对内容做十六进制编码。
|
||||
|
||||
*> host_encoding_hex_encode text=`内容`*
|
||||
|
||||
## 十六进制解码
|
||||
+ `内容`
|
||||
|
||||
对内容做十六进制解码。
|
||||
|
||||
*> host_encoding_hex_decode text=`内容`*
|
||||
|
||||
## 基32编码
|
||||
+ `内容`
|
||||
|
||||
对内容做基32编码(RFC 4648;= 填充)。
|
||||
|
||||
*> host_encoding_base32_encode text=`内容`*
|
||||
|
||||
## 基32解码
|
||||
+ `内容`
|
||||
|
||||
对内容做基32解码。
|
||||
|
||||
*> host_encoding_base32_decode text=`内容`*
|
||||
@@ -3,6 +3,8 @@ title: lib/网络
|
||||
description: 中文 HTTP(S) 包装。可选 headers / content_type 经宿主别名绑定。
|
||||
---
|
||||
|
||||
中文 HTTP(S) 包装。可选 headers / content_type 经宿主别名绑定。
|
||||
|
||||
## 获取
|
||||
+ `地址`
|
||||
+ `headers`=None
|
||||
@@ -54,6 +56,8 @@ POST 并消费 OpenAI 兼容 SSE。返回 `{status, events}`(`delta` / `done`
|
||||
## 编码地址
|
||||
+ `内容`
|
||||
|
||||
对 URL 段做百分号编码。
|
||||
|
||||
*> host_url_encode text=`内容`*
|
||||
|
||||
## 解析Cookie
|
||||
|
||||
@@ -3,6 +3,8 @@ title: lib/自写回
|
||||
description: 将运行结果写回 .mq.md(Jupyter 式自写回)
|
||||
---
|
||||
|
||||
将运行结果写回 .mq.md(Jupyter 式自写回)
|
||||
|
||||
## 写回
|
||||
+ `值`
|
||||
+ `末尾`=False
|
||||
@@ -42,6 +44,8 @@ description: 将运行结果写回 .mq.md(Jupyter 式自写回)
|
||||
|
||||
## 列出
|
||||
|
||||
列出。
|
||||
|
||||
*> host_writeback_list*
|
||||
|
||||
## 扫描路径
|
||||
|
||||
@@ -3,12 +3,20 @@ title: lib/超文本
|
||||
description: HTML 转义 / 还原(中层 Mid2 M8)。拼装字符串时的 XSS 底线。
|
||||
---
|
||||
|
||||
HTML 转义助手。把不可信文本拼进标记前先转义。
|
||||
|
||||
## 转义
|
||||
+ `内容`
|
||||
|
||||
对内容做 HTML 转义。
|
||||
|
||||
调用例:[超文本.转义] 内容=`段`
|
||||
|
||||
*> host_html_escape text=`内容`*
|
||||
|
||||
## 还原
|
||||
+ `内容`
|
||||
|
||||
还原内容里的 HTML 实体。
|
||||
|
||||
*> host_html_unescape text=`内容`*
|
||||
@@ -3,38 +3,56 @@ title: lib/路径
|
||||
description: 路径代数(中层 M2)。无 I/O;分隔符随宿主 OS。
|
||||
---
|
||||
|
||||
只做路径代数。无 I/O;分隔符随宿主 OS。
|
||||
|
||||
## 拼接
|
||||
+ `甲`
|
||||
+ `乙`
|
||||
|
||||
拼接路径段甲与乙。
|
||||
|
||||
调用例:[路径.拼接] 甲="a" 乙="b"
|
||||
|
||||
*> host_path_join a=`甲` b=`乙`*
|
||||
|
||||
## 拆分
|
||||
+ `路径`
|
||||
|
||||
把路径拆成各段。
|
||||
|
||||
*> host_path_split path=`路径`*
|
||||
|
||||
## 文件名
|
||||
+ `路径`
|
||||
|
||||
路径的末段文件名。
|
||||
|
||||
*> host_path_file_name path=`路径`*
|
||||
|
||||
## 父目录
|
||||
+ `路径`
|
||||
|
||||
路径的父目录。
|
||||
|
||||
*> host_path_parent path=`路径`*
|
||||
|
||||
## 扩展名
|
||||
+ `路径`
|
||||
|
||||
路径的扩展名。
|
||||
|
||||
*> host_path_extension path=`路径`*
|
||||
|
||||
## 规范化
|
||||
+ `路径`
|
||||
|
||||
规范化路径(处理点段)。
|
||||
|
||||
*> host_path_normalize path=`路径`*
|
||||
|
||||
## 是绝对
|
||||
+ `路径`
|
||||
|
||||
路径是否为绝对路径。
|
||||
|
||||
*> host_path_is_absolute path=`路径`*
|
||||
@@ -3,12 +3,20 @@ title: lib/逗号表
|
||||
description: CSV 解析/序列化(中层 M4)。首行为表头 → 映射列表。
|
||||
---
|
||||
|
||||
CSV 解析与序列化。首行为表头;各行变成映射列表。
|
||||
|
||||
## 解析
|
||||
+ `内容`
|
||||
|
||||
把 CSV 文本解析成映射列表。
|
||||
|
||||
调用例:[逗号表.解析] 内容=`原文`
|
||||
|
||||
*> host_csv_parse text=`内容`*
|
||||
|
||||
## 序列化
|
||||
+ `行集`
|
||||
|
||||
把映射列表序列化成 CSV 文本。
|
||||
|
||||
*> host_csv_stringify rows=`行集`*
|
||||
@@ -3,7 +3,13 @@ title: lib/配置表
|
||||
description: 只读 TOML 子集解析(中层 Mid2 M8)。表 / 标量 / 数组;无数组表。
|
||||
---
|
||||
|
||||
只读 TOML 子集。适合配置;不做完整 TOML 写出。
|
||||
|
||||
## 解析
|
||||
+ `内容`
|
||||
|
||||
把 TOML 文本解析成映射/列表/标量。
|
||||
|
||||
调用例:[配置表.解析] 内容=`配置`
|
||||
|
||||
*> host_toml_parse text=`内容`*
|
||||
Reference in new issue
Block a user