Skip to content

Conversation

commit111
Copy link

@commit111 commit111 commented Apr 25, 2025

This PR changes GenMarkdownCustom() in doc/md_docs.go so it can print the list of Aliases of a command in the markdown of docs.

Related to #2223, but the difference is that this PR does not print it as a separate section.

@CLAassistant
Copy link

CLAassistant commented Apr 25, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the area/docs-generation Generation of docs via Cobra label Apr 25, 2025
@ccoVeille
Copy link
Contributor

Is this a WIP PR?

Unless I'm wrong, nothing calls this new method. So what is expected here?

doc/md_docs.go Outdated
Comment on lines 75 to 81
if len(cmd.Aliases) > 0 {
buf.WriteString("### Aliases\n\n")
for _, alias := range cmd.Aliases {
buf.WriteString(fmt.Sprintf("* `%s`\n", alias))
}
buf.WriteString("\n")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 this is a pure stylistic feedbacks.

It's open for debate.

Maybe the rendering could be different when there is only one alias.

Because this might seem empty as a section

### Aliases

* foobar

So, here maybe another rendering could be considered.

When multiple aliases are available

Aliases: foobar, fooquz

And when there is only one

Aliases: foobar

Please note, I didn't use a section on purpose

@commit111
Copy link
Author

Is this a WIP PR?

Unless I'm wrong, nothing calls this new method. So what is expected here?

Yes, I am still changing it. Sorry, I should've specified that earlier.

@commit111 commit111 changed the title Add function to print command aliases Print command aliases in one line Apr 25, 2025
@commit111 commit111 changed the title Print command aliases in one line Print command aliases, not as a section Apr 25, 2025
@commit111 commit111 changed the title Print command aliases, not as a section Print command aliases in docs, not as a section Apr 25, 2025
@commit111
Copy link
Author

Ok, I am done with changing it.

Co-authored-by: ccoVeille <[email protected]>
@commit111 commit111 requested a review from ccoVeille April 25, 2025 20:43
doc/md_docs.go Outdated
if i > 0 {
buf.WriteString(", ")
}
buf.WriteString(fmt.Sprintf("`%s`", alias))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'm surprised by this syntax, that was already used in the file I concede

I feel like this would be more natural.

Note

This is more a note to myself to look deeper than something I expect you to change

This could have been used

Suggested change
buf.WriteString(fmt.Sprintf("`%s`", alias))
fmt.Fprintf(buf, "`%s`", alias)

@commit111 please look at this that seems a better option

#2271 (comment)

Co-authored-by: ccoVeille <[email protected]>
@commit111 commit111 requested a review from ccoVeille April 25, 2025 22:05
Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Thanks

Let's now wait for @marckhouzam to review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs-generation Generation of docs via Cobra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants