MCPcopy
hub / github.com/github/github-mcp-server / generateReadmeDocs

Function generateReadmeDocs

cmd/github-mcp-server/generate_docs.go:58–105  ·  view source on GitHub ↗
(readmePath string)

Source from the content-addressed store, hash-verified

56}
57
58func generateReadmeDocs(readmePath string) error {
59 // Create translation helper
60 t, _ := translations.TranslationHelper()
61
62 // The README documents the default user experience: tools that are
63 // enabled with no special flags set. Installing a checker that reports
64 // every flag as disabled excludes tools gated by FeatureFlagEnable and
65 // keeps the legacy variants of tools gated by FeatureFlagDisable, so
66 // flag-gated duplicates don't appear twice.
67 // Build() can only fail if WithTools specifies invalid tools - not used here
68 r, _ := github.NewInventory(t).
69 WithToolsets([]string{"all"}).
70 WithFeatureChecker(noFeatureFlagsChecker).
71 Build()
72
73 // Generate toolsets documentation
74 toolsetsDoc := generateToolsetsDoc(r)
75
76 // Generate tools documentation
77 toolsDoc := generateToolsDoc(r)
78
79 // Read the current README.md
80 // #nosec G304 - readmePath is controlled by command line flag, not user input
81 content, err := os.ReadFile(readmePath)
82 if err != nil {
83 return fmt.Errorf("failed to read README.md: %w", err)
84 }
85
86 // Replace toolsets section
87 updatedContent, err := replaceSection(string(content), "START AUTOMATED TOOLSETS", "END AUTOMATED TOOLSETS", toolsetsDoc)
88 if err != nil {
89 return err
90 }
91
92 // Replace tools section
93 updatedContent, err = replaceSection(updatedContent, "START AUTOMATED TOOLS", "END AUTOMATED TOOLS", toolsDoc)
94 if err != nil {
95 return err
96 }
97
98 // Write back to file
99 err = os.WriteFile(readmePath, []byte(updatedContent), 0600)
100 if err != nil {
101 return fmt.Errorf("failed to write README.md: %w", err)
102 }
103
104 return nil
105}
106
107func generateRemoteServerDocs(docsPath string) error {
108 content, err := os.ReadFile(docsPath) //#nosec G304

Callers

nothing calls this directly

Calls 8

TranslationHelperFunction · 0.92
NewInventoryFunction · 0.92
generateToolsetsDocFunction · 0.85
generateToolsDocFunction · 0.85
replaceSectionFunction · 0.85
BuildMethod · 0.80
WithFeatureCheckerMethod · 0.80
WithToolsetsMethod · 0.80

Tested by

no test coverage detected