Skip to content
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

Improve inline documentation #393

Open
jdevalk opened this issue Dec 7, 2023 · 0 comments
Open

Improve inline documentation #393

jdevalk opened this issue Dec 7, 2023 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@jdevalk
Copy link
Collaborator

jdevalk commented Dec 7, 2023

Every function/method should have a doc block that is simple to read and understand.

Doc blocks should be meaningful

Functions & methods don't properly document the return types.
For example, the edac_filter_by_value function says in the doc block that it returns an array. However, looking at the code, I see that it can return either an array or null. The same thing applies to many, many other functions & methods. Ideally, we should make sure that the functions always return the same type of value - so, for example, the edac_filter_by_value function should return array() instead of null, and then all cases where this function is used should be checked to ensure that they take that into account. If, for some reason, that is not possible, then the least we should do is properly document the return types. Again, a developer shouldn't need to read the whole function to understand it. The doc block should explain what it does, how to use the parameters, and what it returns.

Omit obvious inline docs

Some obvious inline documentation should be omitted. For example, this:

// Return success response.
wp_send_json( 'success' );

It's pretty obvious what it does; there's no reason to document it. It's just noise. Similarly, saying // Update user meta before calling update_user_meta adds no value. It's obvious. Noise should be removed, and more meaningful documentation should be added to the functions themselves. Doc blocks in functions are supposed to help developers understand what a function does without having to read the whole thing. Here, the function's doc block is just a copy of the function's name, and we need to read everything to understand what it does and how.

@jdevalk jdevalk added the documentation Improvements or additions to documentation label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant