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

Document errors #440

Open
tobiasvl opened this issue Jul 24, 2022 · 0 comments
Open

Document errors #440

tobiasvl opened this issue Jul 24, 2022 · 0 comments

Comments

@tobiasvl
Copy link

After #98, Result is returned in a lot of new places. These functions should probably document when errors can occur, and why.

According to clippy's missing_errors_doc lint, "Documenting the type of errors that can be returned from a function can help callers write code to handle the errors appropriately." It suggests doing this with a /// # Errors section in the rustdoc comments. I suggest following this suggestion.


Background: I just upgraded to syntect 5.0.0, and I got a warning that HighlightLines::highlight had been "renamed" to HighlightLines::highlight_line. However, when I changed the function name, I noticed that the new function returned a Result, unlike the old function, and it wasn't readily apparent why. I checked the documentation to see if there were any new failure states, but didn't find any documentation. Only by checking the source code did I learn that the old function would panic, but I still don't know what could cause that to happen.

(Note that missing_panics_doc is a similar lint for panics, which also would have helped in this case, although I understand syntect has eliminated most/all panics by now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants