Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions scripts/generate-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ function generateToolsTOC(
const categoryName = labels[category];
toc += `- **${categoryName}** (${categoryTools.length} tools)\n`;

// Sort tools within category for TOC
categoryTools.sort((a: Tool, b: Tool) => a.name.localeCompare(b.name));
// Sort tools within category for TOC: no-arg tools first, then with args
categoryTools.sort((a: Tool, b: Tool) => {
const aHasRequired = a.inputSchema?.required?.length ?? 0 > 0;
const bHasRequired = b.inputSchema?.required?.length ?? 0 > 0;
if (!aHasRequired && bHasRequired) return -1;
if (aHasRequired && !bHasRequired) return 1;
return a.name.localeCompare(b.name);
});
for (const tool of categoryTools) {
const anchorLink = tool.name.toLowerCase();
toc += ` - [\`${tool.name}\`](docs/tool-reference.md#${anchorLink})\n`;
Expand Down Expand Up @@ -361,8 +367,14 @@ async function generateReference(
markdown += `> NOTE: ${categoryName} are not active by default. Use the '${flagName}' flag\n\n`;
}

// Sort tools within category
categoryTools.sort((a: Tool, b: Tool) => a.name.localeCompare(b.name));
// Sort tools within category: no-arg tools first, then tools with required args, then optional-arg tools
categoryTools.sort((a: Tool, b: Tool) => {
const aHasRequired = a.inputSchema?.required?.length ?? 0 > 0;
const bHasRequired = b.inputSchema?.required?.length ?? 0 > 0;
if (!aHasRequired && bHasRequired) return -1;
if (aHasRequired && !bHasRequired) return 1;
return a.name.localeCompare(b.name);
});

for (const tool of categoryTools) {
markdown += `### \`${tool.name}\`\n\n`;
Expand Down