MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / buildCommandSection

Function buildCommandSection

scripts/docs/src/generate-cli-docs.ts:382–485  ·  view source on GitHub ↗
({
  command,
  rootName,
  ancestors,
  depth,
  useRootIntro,
}: BuildCommandSectionOptions)

Source from the content-addressed store, hash-verified

380};
381
382function buildCommandSection({
383 command,
384 rootName,
385 ancestors,
386 depth,
387 useRootIntro,
388}: BuildCommandSectionOptions): Content[] {
389 const nodes: Content[] = [];
390 const commandPath = getCommandPath(rootName, ancestors, command);
391 const isRootCommand = ancestors.length === 0;
392 const shouldUseIntro = isRootCommand && useRootIntro;
393 const headingContent = shouldUseIntro
394 ? "Introduction"
395 : [createInlineCode(commandPath)];
396
397 nodes.push(createHeading(depth, headingContent));
398
399 const description = command.description();
400 if (description) {
401 nodes.push(createParagraph(description));
402 }
403
404 const usage = buildUsage(command);
405 if (usage) {
406 const sectionDepth = shouldUseIntro ? depth : Math.min(depth + 1, 6);
407 nodes.push(createHeading(sectionDepth, "Usage"));
408 nodes.push({
409 type: "paragraph",
410 children: [createInlineCode(usage)],
411 });
412 }
413
414 const aliases = command.aliases();
415 if (aliases.length > 0) {
416 const sectionDepth = shouldUseIntro ? depth : Math.min(depth + 1, 6);
417 nodes.push(createHeading(sectionDepth, "Aliases"));
418 nodes.push(
419 createList(
420 aliases.map((alias) => createListItem([createInlineCode(alias)])),
421 ),
422 );
423 }
424
425 const args = command.registeredArguments ?? [];
426 if (args.length > 0) {
427 const sectionDepth = shouldUseIntro ? depth : Math.min(depth + 1, 6);
428 nodes.push(createHeading(sectionDepth, "Arguments"));
429 nodes.push(createList(buildArgumentListItems(args)));
430 }
431
432 const visibleOptions = command.options.filter((option) => !option.hidden);
433 if (visibleOptions.length > 0) {
434 const { flags, valueOptions } = partitionOptions(visibleOptions);
435 const sectionDepth = shouldUseIntro ? depth : Math.min(depth + 1, 6);
436
437 if (valueOptions.length > 0) {
438 nodes.push(createHeading(sectionDepth, "Options"));
439 nodes.push(

Callers 2

buildCommandDocFunction · 0.85
buildIndexDocFunction · 0.85

Calls 13

getCommandPathFunction · 0.85
createInlineCodeFunction · 0.85
createHeadingFunction · 0.85
createParagraphFunction · 0.85
buildUsageFunction · 0.85
createListFunction · 0.85
createListItemFunction · 0.85
buildArgumentListItemsFunction · 0.85
partitionOptionsFunction · 0.85
buildOptionEntriesFunction · 0.85
isHiddenCommandFunction · 0.85
isHelpCommandFunction · 0.85

Tested by

no test coverage detected