MCPcopy
hub / github.com/Kong/insomnia / generateDocumentation

Function generateDocumentation

packages/insomnia-inso/src/scripts/docs.ts:86–139  ·  view source on GitHub ↗
(program: commander.Command)

Source from the content-addressed store, hash-verified

84}
85
86export function generateDocumentation(program: commander.Command): void {
87 if (!fs.existsSync(DOCS_DIR)) {
88 fs.mkdirSync(DOCS_DIR, { recursive: true });
89 }
90
91 const allCommands: any[] = [];
92
93 program.commands.forEach(command => {
94 const commandData = generateCommandMarkdown(command, program.options, '');
95
96 allCommands.push({
97 name: commandData.name,
98 description: commandData.description,
99 fileName: commandData.fileName,
100 subcommands: commandData.subcommands.map(sub => ({
101 name: sub.name(),
102 description: sub.description() || 'No description available',
103 fileName: `${commandData.name.replace(/\s+/g, '_')}_${sub.name().replace(/\s+/g, '_')}.md`,
104 })),
105 });
106
107 commandData.subcommands.forEach(sub => {
108 generateCommandMarkdown(sub, program.options, commandData.name);
109 });
110 });
111
112 writeMarkdownFile(
113 'index.md',
114 `---
115title: CLI Documentation
116---
117
118${generateOptionsMarkdown(program.options, 'Global Flags')}
119
120## Commands
121
122${allCommands
123 .map(
124 ({
125 name,
126 description,
127 fileName,
128 }) => `- [\`${name}\`](/inso-cli/reference/${fileName.replace('.md', '')}/{{page.release}}/): ${description}
129`,
130 )
131 .join('')}
132${allCommands
133 .map(
134 ({ name, subcommands }) => `${generateSubcommandsMarkdown(name, subcommands)}
135`,
136 )
137 .join('')}`,
138 );
139}

Callers 1

goFunction · 0.90

Calls 8

generateCommandMarkdownFunction · 0.85
writeMarkdownFileFunction · 0.85
generateOptionsMarkdownFunction · 0.85
mapMethod · 0.80
nameMethod · 0.80
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected