Skip to content

Commit 6f7bf27

Browse files
mattdhollowaySamMorrowDrums
authored andcommitted
refactor docs toolset gen
1 parent cac11f2 commit 6f7bf27

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

cmd/github-mcp-server/generate_docs.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"net/url"
67
"os"
@@ -50,8 +51,10 @@ func generateReadmeDocs(readmePath string) error {
5051
// Create translation helper
5152
t, _ := translations.TranslationHelper()
5253

53-
// Build inventory - stateless, no dependencies needed for doc generation
54-
r := github.NewInventory(t).Build()
54+
// Build inventory with all toolsets enabled and no feature checker (all flags return false).
55+
// This includes tools from all toolsets, but excludes tools with FeatureFlagEnable
56+
// (not available to regular users) while including tools with FeatureFlagDisable.
57+
r := github.NewInventory(t).WithToolsets([]string{"all"}).Build()
5558

5659
// Generate toolsets documentation
5760
toolsetsDoc := generateToolsetsDoc(r)
@@ -153,10 +156,10 @@ func generateToolsetsDoc(i *inventory.Inventory) string {
153156
}
154157

155158
func generateToolsDoc(r *inventory.Inventory) string {
156-
// AllToolsForDocs() returns tools sorted by toolset ID then tool name,
157-
// excluding tools that require feature flags (not available to regular users).
158-
// We iterate once, grouping by toolset as we encounter them.
159-
tools := r.AllToolsForDocs()
159+
// Use AvailableTools with the inventory's feature checker (returns false for all flags),
160+
// which excludes tools requiring a feature flag (FeatureFlagEnable) while keeping
161+
// tools that are disabled by feature flags (available by default).
162+
tools := r.AvailableTools(context.Background())
160163
if len(tools) == 0 {
161164
return ""
162165
}

pkg/inventory/registry.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -266,33 +266,6 @@ func (r *Inventory) AllTools() []ServerTool {
266266
return result
267267
}
268268

269-
// AllToolsForDocs returns tools suitable for documentation, sorted deterministically.
270-
// This excludes tools that require a feature flag to be enabled (FeatureFlagEnable),
271-
// since those are not available to regular users and shouldn't appear in public docs.
272-
// Tools that are disabled by a feature flag (FeatureFlagDisable) are still included
273-
// since they are available by default.
274-
func (r *Inventory) AllToolsForDocs() []ServerTool {
275-
var result []ServerTool
276-
for i := range r.tools {
277-
tool := &r.tools[i]
278-
// Skip tools that require a feature flag to enable
279-
if tool.FeatureFlagEnable != "" {
280-
continue
281-
}
282-
result = append(result, *tool)
283-
}
284-
285-
// Sort deterministically: by toolset ID, then by tool name
286-
sort.Slice(result, func(i, j int) bool {
287-
if result[i].Toolset.ID != result[j].Toolset.ID {
288-
return result[i].Toolset.ID < result[j].Toolset.ID
289-
}
290-
return result[i].Tool.Name < result[j].Tool.Name
291-
})
292-
293-
return result
294-
}
295-
296269
// AvailableToolsets returns the unique toolsets that have tools, in sorted order.
297270
// This is the ordered intersection of toolsets with reality - only toolsets that
298271
// actually contain tools are returned, sorted by toolset ID.

0 commit comments

Comments
 (0)