make sure docs don't show up for globals that aren't commands

pull/8675/merge^2
Matt Paras 2025-05-19 06:56:12 -07:00
parent e6b0badcd0
commit 94927711b4
2 changed files with 28 additions and 22 deletions

24
Cargo.lock generated
View File

@ -612,7 +612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2228,7 +2228,7 @@ dependencies = [
"portable-atomic",
"portable-atomic-util",
"serde",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2898,7 +2898,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -2911,7 +2911,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys 0.9.4",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -3125,7 +3125,7 @@ dependencies = [
"cfg-if",
"libc",
"psm",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -3137,7 +3137,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "steel-core"
version = "0.6.0"
source = "git+https://github.com/mattwparas/steel.git#e308663bcb50275288261a37659c9562909246e0"
source = "git+https://github.com/mattwparas/steel.git#a81a2b6ca26c5cd64de908bcf1c680b49deb5710"
dependencies = [
"abi_stable",
"anyhow",
@ -3189,7 +3189,7 @@ dependencies = [
[[package]]
name = "steel-derive"
version = "0.5.0"
source = "git+https://github.com/mattwparas/steel.git#e308663bcb50275288261a37659c9562909246e0"
source = "git+https://github.com/mattwparas/steel.git#a81a2b6ca26c5cd64de908bcf1c680b49deb5710"
dependencies = [
"proc-macro2",
"quote",
@ -3199,7 +3199,7 @@ dependencies = [
[[package]]
name = "steel-doc"
version = "0.6.0"
source = "git+https://github.com/mattwparas/steel.git#e308663bcb50275288261a37659c9562909246e0"
source = "git+https://github.com/mattwparas/steel.git#a81a2b6ca26c5cd64de908bcf1c680b49deb5710"
dependencies = [
"steel-core",
]
@ -3207,7 +3207,7 @@ dependencies = [
[[package]]
name = "steel-gen"
version = "0.2.0"
source = "git+https://github.com/mattwparas/steel.git#e308663bcb50275288261a37659c9562909246e0"
source = "git+https://github.com/mattwparas/steel.git#a81a2b6ca26c5cd64de908bcf1c680b49deb5710"
dependencies = [
"codegen",
"serde",
@ -3216,7 +3216,7 @@ dependencies = [
[[package]]
name = "steel-parser"
version = "0.6.0"
source = "git+https://github.com/mattwparas/steel.git#e308663bcb50275288261a37659c9562909246e0"
source = "git+https://github.com/mattwparas/steel.git#a81a2b6ca26c5cd64de908bcf1c680b49deb5710"
dependencies = [
"compact_str",
"fxhash",
@ -3291,7 +3291,7 @@ dependencies = [
"getrandom 0.3.2",
"once_cell",
"rustix 1.0.5",
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]
@ -3757,7 +3757,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.52.0",
]
[[package]]

View File

@ -2200,15 +2200,21 @@ impl HelixConfiguration {
// Get doc from function ptr table, hack
fn get_doc_for_global(engine: &mut Engine, ident: &str) -> Option<String> {
if engine.global_exists(ident) {
let expr = format!("(#%function-ptr-table-get #%function-ptr-table {})", ident);
Some(
engine
.run(expr)
.ok()
.and_then(|x| x.first().cloned())
.and_then(|x| x.as_string().map(|x| x.as_str().to_string()))
.unwrap_or_else(|| "Undocumented plugin command".to_string()),
)
let readable_globals = engine.readable_globals(*GLOBAL_OFFSET.get().unwrap());
for global in readable_globals {
if global.resolve() == ident {
let expr = format!("(#%function-ptr-table-get #%function-ptr-table {})", ident);
let doc = engine.run(expr).ok().and_then(|x| x.first().cloned());
if let Some(doc) = doc {
return doc.as_string().map(|x| x.as_str().to_string());
}
}
}
None
} else {
None
}
@ -3504,7 +3510,7 @@ fn configure_engine_impl(mut engine: Engine) -> Engine {
// Create directory since we can't do that in the current state
engine.register_fn("hx.create-directory", create_directory);
GLOBAL_OFFSET.set(engine.readable_globals(0).len()).unwrap();
GLOBAL_OFFSET.set(engine.globals().len()).unwrap();
engine
}