(md *moduleDef, fn *modFunction)
| 382 | } |
| 383 | |
| 384 | func (h *shellCallHandler) FunctionDoc(md *moduleDef, fn *modFunction) string { |
| 385 | var doc ShellDoc |
| 386 | |
| 387 | if fn.Description != "" { |
| 388 | doc.Add("", fn.Description) |
| 389 | } |
| 390 | |
| 391 | usage := h.FunctionUseLine(md, fn) |
| 392 | if usage != "" { |
| 393 | doc.Add("Usage", usage) |
| 394 | } |
| 395 | |
| 396 | if args := fn.RequiredArgs(); len(args) > 0 { |
| 397 | doc.Add( |
| 398 | "Required Arguments", |
| 399 | nameShortWrapped(args, func(a *modFunctionArg) (string, string) { |
| 400 | return strings.TrimPrefix(a.Usage(), "--"), a.Long() |
| 401 | }), |
| 402 | ) |
| 403 | } |
| 404 | |
| 405 | if args := fn.OptionalArgs(); len(args) > 0 { |
| 406 | doc.Add( |
| 407 | "Optional Arguments", |
| 408 | nameShortWrapped(args, func(a *modFunctionArg) (string, string) { |
| 409 | return a.Usage(), a.Long() |
| 410 | }), |
| 411 | ) |
| 412 | } |
| 413 | |
| 414 | usage = strings.TrimSuffix(usage, " [options]") |
| 415 | |
| 416 | doc.Add( |
| 417 | "Returns", |
| 418 | fmt.Sprintf(`%s |
| 419 | |
| 420 | Use "%s | .help" for more details.`, |
| 421 | fn.ReturnType.Short(), |
| 422 | strings.TrimSuffix(usage, " [options]"), |
| 423 | )) |
| 424 | |
| 425 | return doc.String() |
| 426 | } |
| 427 | |
| 428 | func shellTypeDoc(t *modTypeDef) string { |
| 429 | var doc ShellDoc |
no test coverage detected