MCPcopy Index your code
hub / github.com/github/github-mcp-server / octiconImg

Function octiconImg

cmd/github-mcp-server/generate_docs.go:135–148  ·  view source on GitHub ↗

octiconImg returns an img tag for an Octicon that works with GitHub's light/dark theme. Uses picture element with prefers-color-scheme for automatic theme switching. References icons from the repo's pkg/octicons/icons directory. Optional pathPrefix for files in subdirectories (e.g., "../" for docs/)

(name string, pathPrefix ...string)

Source from the content-addressed store, hash-verified

133// References icons from the repo's pkg/octicons/icons directory.
134// Optional pathPrefix for files in subdirectories (e.g., "../" for docs/).
135func octiconImg(name string, pathPrefix ...string) string {
136 if name == "" {
137 return ""
138 }
139 prefix := ""
140 if len(pathPrefix) > 0 {
141 prefix = pathPrefix[0]
142 }
143 // Use picture element with media queries for light/dark mode support
144 // GitHub renders these correctly in markdown
145 lightIcon := fmt.Sprintf("%spkg/octicons/icons/%s-light.png", prefix, name)
146 darkIcon := fmt.Sprintf("%spkg/octicons/icons/%s-dark.png", prefix, name)
147 return fmt.Sprintf(`<picture><source media="(prefers-color-scheme: dark)" srcset="%s"><source media="(prefers-color-scheme: light)" srcset="%s"><img src="%s" width="20" height="20" alt="%s"></picture>`, darkIcon, lightIcon, lightIcon, name)
148}
149
150func generateToolsetsDoc(i *inventory.Inventory) string {
151 var buf strings.Builder

Callers 4

generateToolsetsDocFunction · 0.85
generateToolsDocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected