Skip to content

Conversation

bouweandela
Copy link
Contributor

This could be a way to add a yapf-diff command. I took the latest copy of clang-format-diff.py, took the required changes from this gist #190 (comment), tried to align the command line arguments with the yapf arguments and formatted the result with yapf 0.30.0.

Does this look reasonable, or would you like a more integrated argument in the existing yapf command?

I would be happy to add some unit tests if this looks like something that could be merged.

Closes #190

@google-cla google-cla bot added the cla: yes label Oct 16, 2020
@coveralls
Copy link

coveralls commented Oct 16, 2020

Coverage Status

Coverage decreased (-1.2%) to 94.542% when pulling a96eff4 on bouweandela:yapf-diff into 489fbd9 on google:master.

@bwendling
Copy link
Member

This looks good. It needs a bit of cleanup. The top-level comment in yapf-diff shouldn't be about clang-diff, and it needs the copyright header. Should also be mentioned in CHANGES.

@bwendling
Copy link
Member

Hold on. Ignore what I said about the header stuff. Copyright stuff is more complex. :-) I'll need to check about whether we can do this.

@bouweandela
Copy link
Contributor Author

Thanks! Do you have any news about the legal question already? The alternative would be to implement something from scratch, but because the script is fairly simple the difference between the two options might be pretty small in the end.

@bwendling
Copy link
Member

Thanks! Do you have any news about the legal question already?

I've gotten the info on how to proceed. We need to ensure that the licensing for this tool is retained. So please add it to a subdirectory called third_party. The structure will look something like this:

yapf/
  |
  ` third_party/
    |
    ` yapf_diff/
      |
      - LICENSE
      |
      - ... (whatever files belong here)

The LICENSE file should have a copy of the full license text under which clang-format was released. (Assuming this is clang's general license.) Because we're modifying the name, please add a comment at the top of yapf-diff that it's a modified copy of clang-format.

@bwendling bwendling merged commit b88e2ab into google:master Nov 8, 2020
@bouweandela bouweandela deleted the yapf-diff branch November 9, 2020 08:39
Andrea-Oliveri pushed a commit to Andrea-Oliveri/yapf that referenced this pull request Aug 13, 2025
* Add yapf-diff command

Modified https://github.com/llvm/llvm-project/blob/master/clang/tools/clang-format/clang-format-diff.py to work with yapf

* format with yapf 0.30.0

* Move script to third_party and add license
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yapf-diff (similar to clang-format-diff) ?
3 participants