Docs: Links and desciptions for number types (#6752)

Links and desciptions for number types

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-05-08 11:05:57 +12:00
committed by GitHub
parent e9f6ebb6d1
commit f01957edc7
29 changed files with 57 additions and 53 deletions

View File

@ -664,7 +664,9 @@ fn cleanup_type_string(input: &str, fmt_for_text: bool) -> String {
// If we can handle signatures more manually we could get highlighting and links and
// we might want to restore the links by not checking `fmt_for_text` here.
if fmt_for_text && SPECIAL_TYPES.contains(&ty) {
if fmt_for_text && ty.starts_with("number") {
format!("[{prefix}{ty}{suffix}](/docs/kcl-std/types/std-types-number)")
} else if fmt_for_text && SPECIAL_TYPES.contains(&ty) {
format!("[{prefix}{ty}{suffix}](/docs/kcl-lang/types#{ty})")
} else if fmt_for_text && DECLARED_TYPES.contains(&ty) {
format!("[{prefix}{ty}{suffix}](/docs/kcl-std/types/std-types-{ty})")

View File

@ -398,8 +398,10 @@ impl From<StdLibFnArg> for ParameterInformation {
}
fn docs_for_type(ty: &str, kcl_std: &ModData) -> Option<String> {
if DECLARED_TYPES.contains(&ty) {
if let Some(data) = kcl_std.find_by_name(ty) {
let key = if ty.starts_with("number") { "number" } else { ty };
if DECLARED_TYPES.contains(&key) {
if let Some(data) = kcl_std.find_by_name(key) {
return data.summary().cloned();
}
}