(cmd *cobra.Command, dir string, relativeBasePath string, positionCounter *int, pageCollection *PageCollection)
| 163 | } |
| 164 | |
| 165 | func 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 | |
| 201 | var modDatePattern = regexp.MustCompile(`(?m)^modDate: .+$`) |
| 202 |
no test coverage detected