Skip to content

Improve readability of annotation syntaxes #7

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
carsakiller opened this issue Aug 11, 2023 · 4 comments
Open

Improve readability of annotation syntaxes #7

carsakiller opened this issue Aug 11, 2023 · 4 comments
Labels
help wanted Extra attention is needed wiki/improvement Larger improvement to existing documentation

Comments

@carsakiller
Copy link
Collaborator

The method currently used for describing how to use annotations can be easy to understand at times:
---@type <type>

And also impossible for mere mortals to understand:
---@cast <value_name> [+|-]<type|?>[, [+|-]<type|?>...]
---@overload fun([param: type[, param: type...]]): [return_value[,return_value]]

There must be a better way to represent these more complex syntaxes while also not using symbols regularly in use (<, >, (, ), [, ], {, }, @, #, -, +, =, :, ", ,, ., ?). Although now that I have listed some in-use symbols, I realize we really are quite limited. It is hard to explain a syntax that uses many symbols… using symbols.

I'm open to any suggestions on how this can be improved 🙂

@carsakiller carsakiller added wiki/improvement Larger improvement to existing documentation help wanted Extra attention is needed labels Aug 11, 2023
@CelDaemon
Copy link
Contributor

Maybe using colors to differentiate between placeholders and real syntax?
It doesn't have to just be colors, a hover card describing possible example values could also help.

@carsakiller
Copy link
Collaborator Author

My initial thought was to use colours, but there could be issues then with colourblind users. I think I'll give it a try using iWantHue and see how it looks.

@carsakiller
Copy link
Collaborator Author

I'm not really sure whether this is better 😆

image

image

It might just be slightly easier to read than the current definition:
image

I can try adding a colour specifically for the repeatable brackets… maybe that will help in the case of @cast.

@tomlau10
Copy link

Maybe define the [+|-]<type|?> part as a variable first?

<type_def> := [+|-]<type|?>
---@cast <value_name> <type_def>[, <type_def>...]

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed wiki/improvement Larger improvement to existing documentation
Projects
None yet
Development

No branches or pull requests

3 participants