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

tango comment interaction with rustfmt indentation rules in CI #24

Open
platy opened this issue Sep 20, 2023 · 2 comments
Open

tango comment interaction with rustfmt indentation rules in CI #24

platy opened this issue Sep 20, 2023 · 2 comments

Comments

@platy
Copy link

platy commented Sep 20, 2023

If I break within a function, then tango needs to add it's comments inline within the function. rustfmt indents these lines, but as I'm not checking in the *.rs files, this formatting correction is not seen by CI checks. In CI, I do a build in order to tangle the files and then run rustfmt check to verify that the source is formatted properly.

Example:

fn main() {
//@ In the main fn
}

Wont pass the rustfmt check.

Options

  1. Change tango to indent the comments in these cases. I don't know how complicated this is, I'd imagine getting it to work for most cases would not be so hard, but getting it to work in the general case would be complicated as it'd require implementing rustfmts rules.
  2. Ignore fmt in CI, either the tangled files or this specific indentation rule. I'm not sure how specific I could be about ignoring, but I'm sure I can't just ignore the cases with tango comments without ignoring the format of other comments
  3. Check in the *.rs files as well as the *.md files (and the tango.stamp file) - this seems like the simplest option, but I'm not sure what the implication is, as it is recommended not to do this in the tango-demo
@pnkfelix
Copy link
Owner

pnkfelix commented Apr 1, 2024

Thanks for the bug report. You're discovering that I'm one of those bad programmers who doesn't apply rustfmt to their pet projects.

I'll see what I can do about this.

(The main problem I can recall about checking in the *.rs files along with the *.md files is that when you pull out the files, the local file system will assign timestamps based on those files being created locally. Though if the two files are actually consistent, this wouldn't be a problem, except that I think I currently bail out eagerly if the target file has a newer timestamp of any kind, rather than optimistically attempting the transformation and then seeing if the result matches up, see also issue #17 which seems related...)

@pnkfelix
Copy link
Owner

pnkfelix commented Apr 1, 2024

What you can do is check in your *.rs files instead of your *.md files. That use case is supposed to be supported; i.e., you're supposed to be able to choose, for each file, whether its master copy belong as markdown or as rust source.

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

No branches or pull requests

2 participants