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

Include /// and //! comments when searching for TODOs #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

squeek502
Copy link

Also trim : if it's found after the TODO (e.g. // TODO: something)


Note: The logic for skipping : is a little verbose to avoid the (admittedly unlikely) situation where it could trim too many colons from something like // TODO ::SomeWeirdThing

Also trim `:` if it's found after the TODO (e.g. `// TODO: something`)
@nektro
Copy link
Owner

nektro commented Jan 12, 2022

TODO comments are for the developer and should not be in the documentation

@squeek502
Copy link
Author

squeek502 commented Jan 12, 2022

I'm fine with maintaining a fork for this feature if you don't want to merge this, but here's some reasoning for why it should be considered:

  • Zig source code has many instances of /// TODO (169 matches across 71 files) and some of //! TODO (7 matches across 3 files)
  • The line between developer and someone reading documentation is fairly blurry, and it's not always fully certain that the target audience of a TODO is only developers

An example from std.ascii.indexOfIgnoreCasePos:

/// Finds `substr` in `container`, ignoring case, starting at `start_index`.
/// TODO boyer-moore algorithm
pub fn indexOfIgnoreCasePos(container: []const u8, start_index: usize, substr: []const u8) ?usize {

I'd argue that seeing this TODO would potentially be useful to a user, as it can give some information about how efficient the function is, and that there are plans for making it more efficient. This could be communicated in a different way while moving the TODO outside of the doc comment, but I think it's not fully clear that that'd be an unambiguous good (and leaving it up to the developer whether or not they want the TODO included in the documentation seems okay to me).


Note that if /// TODO and //! TODO are not included in the TODO linting, then there should probably be a linting rule that specifically warns about their existence (if you want to codify 'TODO comments are for the developer and should not be in the documentation')

Comment on lines +22 to +26
const todo_msg = msg: {
// skip colon character if it's immediately after TODO
const msg_start: usize = if (std.mem.startsWith(u8, comment_str[4..], ":")) 5 else 4;
break :msg std.mem.trim(u8, comment_str[msg_start..], " ");
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be replaced with std.mem.trimLeft(u8, msg, ": ");

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally avoided that. From the OP:

Note: The logic for skipping : is a little verbose to avoid the (admittedly unlikely) situation where it could trim too many colons from something like // TODO ::SomeWeirdThing

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

Successfully merging this pull request may close these issues.

2 participants