Skip to content

Commit

Permalink
[nfc] Improve how formatting works
Browse files Browse the repository at this point in the history
Change formatting from overwriting the original file to computing a diff
and then applying it.  This improves the workflow in two ways: (1) editors
better handle a patch application as opposed to a file rewrite and (2) if
there is no formatting change, then a rebuild is no longer required.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
seldridge committed Feb 9, 2024
1 parent db25895 commit 061ce5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clean:
rm -rf build

format:
find . -type f -name '*.md' | xargs -IX pandoc -o X --wrap=preserve -t markdown+pipe_tables-multiline_tables-grid_tables X
find . -type f -name '*.md' -exec ./scripts/format.sh {} ';'

images: $(IMG_EPSS) $(IMG_PNGS)

Expand Down
4 changes: 4 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

diff $1 <(pandoc --wrap=preserve -t markdown+pipe_tables-multiline_tables-grid_tables $1) | \
patch $1 -

0 comments on commit 061ce5f

Please sign in to comment.