Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clidocstool.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func copyFile(src string, dst string) error {
func getAliases(cmd *cobra.Command) []string {
if a := cmd.Annotations["aliases"]; a != "" {
aliases := strings.Split(a, ",")
for i := 0; i < len(aliases); i++ {
for i := range aliases {
aliases[i] = strings.TrimSpace(aliases[i])
}
return aliases
Expand Down
6 changes: 3 additions & 3 deletions clidocstool_md.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {

cs := string(content)

start := strings.Index(cs, "<!---MARKER_GEN_START-->")
before, _, ok := strings.Cut(cs, "<!---MARKER_GEN_START-->")
end := strings.Index(cs, "<!---MARKER_GEN_END-->")

if start == -1 {
if !ok {
return fmt.Errorf("no start marker in %s", mdFile)
}
if end == -1 {
Expand All @@ -124,7 +124,7 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
if err != nil {
return err
}
cont := cs[:start] + "<!---MARKER_GEN_START-->" + "\n" + out + "\n" + cs[end:]
cont := before + "<!---MARKER_GEN_START-->" + "\n" + out + "\n" + cs[end:]

fi, err := os.Stat(targetPath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func cleanupMarkDown(mdString string) (md string, anchors []string) {
var id string
// replace trailing whitespace per line, and handle custom anchors
lines := strings.Split(mdString, "\n")
for i := 0; i < len(lines); i++ {
for i := range lines {
lines[i] = strings.TrimRightFunc(lines[i], unicode.IsSpace)
lines[i], id = convertHTMLAnchor(lines[i])
if id != "" {
Expand Down
2 changes: 0 additions & 2 deletions markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ Last line.`,
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.doc, func(t *testing.T) {
out, _ := cleanupMarkDown(tc.in)
if out != tc.expected {
Expand Down Expand Up @@ -147,7 +146,6 @@ func TestConvertHTMLAnchor(t *testing.T) {
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.in, func(t *testing.T) {
out, id := convertHTMLAnchor(tc.in)
if id != tc.id {
Expand Down
Loading