-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tool] Document with all RPC endpoints #1256
Conversation
Quality Gate passedIssues Measures |
EndpointGroups []keyValue | ||
} | ||
|
||
type keyValue struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyValue seems too general name to me. Maybe use endpointGroup
?
} | ||
|
||
endpointGroups := []keyValue{} | ||
for _, apiInterface := range apiInterfaces { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this for loop be extracted as function for better readability? Maybe endpointGroups()
and have eg := endpointGroups(apiInterfaces)
} | ||
|
||
fileName := "endpoints.md" | ||
fmt.Println(os.Args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this println needed?
endpointGroups = append(endpointGroups, endpointGroup) | ||
} | ||
|
||
fileName := "endpoints.md" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can one more function be created for getting the filename - fileName()
that also contains the check
if len(os.Args) > 1 { fileName = os.Args[1] }
} | ||
|
||
f, err := createOrOpen(fileName) | ||
checkErr(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if checkErr function is needed. There aren't complex checks for error behavior. It's pretty common to use if err != nil {
} | ||
|
||
type keyValue struct { | ||
Key any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to avoid using any as type. Could the key
be string
and the value
[]string
?
} | ||
} | ||
|
||
func createOrOpen(name string) (*os.File, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally rename this to createOrTruncateFile
to better describe the behavior
f, err := createOrOpen(fileName) | ||
checkErr(err) | ||
|
||
t := template.Must(template.New("template.md").ParseFiles("template.md")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move "template.md" and the default fileName to constants
return os.Create(name) | ||
} | ||
|
||
func firstToLower(s string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to
func firstLetterToLower(s string) string {
if s == "" {
return s
}
return strings.ToLower(s[:1]) + s[1:]
}
Hey @MorettiGeorgiev, thanks for the feedback. |
adds a tool to generate a markdown document with all implemented rpc endpoints