Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Feature] Comment doc block

Open Mte90 opened this issue 1 year ago • 8 comments

So right now we have tons of function in stdlib.

Can be handy to document them in the file itself, in this way the documentation can generated aautomatically. So I was thinking something for that.

In Amber looking at the doc there is no way right now for commenting, so we need to choose what is the best way.

Rust uses /** like PHP (https://doc.rust-lang.org/reference/comments.html), python instead use """the sentence""".

Mte90 avatar Jun 24 '24 16:06 Mte90

i think we should use /// and /** */ for doc strings to be consistent with rust

also we should think through tags like this:

/**
    @return It will return none if has failed
*/
async fn get_user() -> Option<User> { ... }

b1ek avatar Jun 24 '24 23:06 b1ek

id say we go with these:

tag desc
@return {desc} is used to describe a function's return value
@param {paramName} {desc} is used to describe a function's param
@author {name} is used to describe the author
@license {SPDXID} to describe the license

b1ek avatar Jun 24 '24 23:06 b1ek

Seems the best way, maybe with https://docs.rs/comment-parser/latest/comment_parser/ we can implement easily?

Mte90 avatar Jun 25 '24 08:06 Mte90

At https://github.com/Ph0enixKM/Amber/pull/62 I used /// syntax for doc comments. We could use the @param etc. just like in JSDoc to document particular params and the return type. Not sure if @author and @license are necessary at this stage but yeah

Ph0enixKM avatar Jun 30 '24 16:06 Ph0enixKM

So we want follow the jsdoc standard or one c style?

Mte90 avatar Jun 30 '24 17:06 Mte90

Oh yeah we could add the /** */ syntax - I just forgot to add the multiline comments. I didn't the need to implement them - now it's the good time

Ph0enixKM avatar Jul 01 '24 14:07 Ph0enixKM

If we will go on /** */ syntax we can approve? https://github.com/Ph0enixKM/Amber/pull/238

So in the way I will add all the comments in the stdlib

Mte90 avatar Jul 02 '24 08:07 Mte90

I think that also comments can include parameters.

I think that can be interesting define script parameters like wp-cli does in a comment: https://github.com/wp-cli/wp-cli/blob/main/php/commands/src/Help_Command.php#L9 In this way the help is automatic for the script but also improve the readability.

Mte90 avatar Jul 16 '24 13:07 Mte90

We have now documentation with \\\ and is not added in the bash file but with 2 ues

Mte90 avatar Sep 10 '24 10:09 Mte90