MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / GenMarkdownTreeCustom

Function GenMarkdownTreeCustom

cmd/gen-docs/main.go:165–199  ·  view source on GitHub ↗
(cmd *cobra.Command, dir string, relativeBasePath string, positionCounter *int, pageCollection *PageCollection)

Source from the content-addressed store, hash-verified

163}
164
165func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, relativeBasePath string, positionCounter *int, pageCollection *PageCollection) error {
166 myPosition := *positionCounter
167 for _, c := range cmd.Commands() {
168 if !c.IsAvailableCommand() || c.IsAdditionalHelpTopicCommand() {
169 continue
170 }
171
172 *positionCounter++
173
174 if err := GenMarkdownTreeCustom(c, dir, relativeBasePath, positionCounter, pageCollection); err != nil {
175 return err
176 }
177
178 }
179
180 info := NewTemplateInformation(cmd, dir, relativeBasePath, myPosition)
181
182 *pageCollection.Pages = append(*pageCollection.Pages, info)
183
184 // Generate new content to buffer
185 var buf bytes.Buffer
186 if err := GenMarkdownCustom(cmd, &buf, info); err != nil {
187 return err
188 }
189 updatedContent := buf.Bytes()
190
191 // Only write if content actually changed (ignoring modDate line)
192 if existingContent, err := os.ReadFile(info.OutputFile); err == nil {
193 if contentEqualIgnoringModDate(existingContent, updatedContent) {
194 return nil
195 }
196 }
197
198 return os.WriteFile(info.OutputFile, updatedContent, 0644)
199}
200
201var modDatePattern = regexp.MustCompile(`(?m)^modDate: .+$`)
202

Callers 1

runFunction · 0.85

Calls 3

NewTemplateInformationFunction · 0.85
GenMarkdownCustomFunction · 0.85

Tested by

no test coverage detected