Build hover content for a standalone function.
(
func: &FunctionInfo,
resolved_see: Option<&[ResolvedSeeRef]>,
)
| 321 | |
| 322 | /// Build hover content for a standalone function. |
| 323 | pub(crate) fn hover_for_function( |
| 324 | func: &FunctionInfo, |
| 325 | resolved_see: Option<&[ResolvedSeeRef]>, |
| 326 | ) -> Hover { |
| 327 | let native_params = format_native_params(&func.parameters); |
| 328 | |
| 329 | // Use native return type in the code block. |
| 330 | let native_ret = func |
| 331 | .native_return_type |
| 332 | .as_ref() |
| 333 | .map(|r| format!(": {}", r)) |
| 334 | .unwrap_or_default(); |
| 335 | |
| 336 | let signature = format!("function {}({}){}", func.name, native_params, native_ret); |
| 337 | let ns_line = namespace_line(func.namespace.as_deref()); |
| 338 | |
| 339 | let mut lines = Vec::new(); |
| 340 | |
| 341 | if let Some(ref desc) = func.description { |
| 342 | lines.push(desc.clone()); |
| 343 | } |
| 344 | |
| 345 | if let Some(ref msg) = func.deprecation_message { |
| 346 | lines.push(format_deprecation_line(msg)); |
| 347 | } |
| 348 | |
| 349 | for url in &func.links { |
| 350 | lines.push(format!("[{}]({})", url, url)); |
| 351 | } |
| 352 | |
| 353 | if let Some(refs) = resolved_see { |
| 354 | format_see_refs(refs, &func.links, &mut lines); |
| 355 | } else { |
| 356 | // Fallback: render raw @see refs without location links. |
| 357 | let unresolved: Vec<ResolvedSeeRef> = func |
| 358 | .see_refs |
| 359 | .iter() |
| 360 | .map(|raw| ResolvedSeeRef { |
| 361 | raw: raw.clone(), |
| 362 | location_uri: None, |
| 363 | }) |
| 364 | .collect(); |
| 365 | format_see_refs(&unresolved, &func.links, &mut lines); |
| 366 | } |
| 367 | |
| 368 | // Build the readable param/return section as markdown. |
| 369 | if let Some(section) = build_param_return_section( |
| 370 | &func.parameters, |
| 371 | func.return_type.as_ref(), |
| 372 | func.native_return_type.as_ref(), |
| 373 | func.return_description.as_deref(), |
| 374 | ) { |
| 375 | lines.push(section); |
| 376 | } |
| 377 | |
| 378 | // Build a clean code block with just the signature. |
| 379 | let code = format!("```php\n<?php\n{}{};\n```", ns_line, signature); |
| 380 | lines.push(code); |
no test coverage detected