MCPcopy
hub / github.com/dagger/dagger / FunctionDoc

Method FunctionDoc

cmd/dagger/shell_help.go:384–426  ·  view source on GitHub ↗
(md *moduleDef, fn *modFunction)

Source from the content-addressed store, hash-verified

382}
383
384func (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
420Use "%s | .help" for more details.`,
421 fn.ReturnType.Short(),
422 strings.TrimSuffix(usage, " [options]"),
423 ))
424
425 return doc.String()
426}
427
428func shellTypeDoc(t *modTypeDef) string {
429 var doc ShellDoc

Callers 1

registerCommandsMethod · 0.95

Calls 9

AddMethod · 0.95
FunctionUseLineMethod · 0.95
StringMethod · 0.95
nameShortWrappedFunction · 0.85
RequiredArgsMethod · 0.80
OptionalArgsMethod · 0.80
UsageMethod · 0.65
ShortMethod · 0.65
LongMethod · 0.45

Tested by

no test coverage detected