Skip to content

Commit

Permalink
fix a few bugs with doc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed Oct 30, 2024
1 parent 6a2ccb4 commit 0864bd3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/autogen/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title = ""
no-section-label = true
additional-js = ["solidity.min.js"]
additional-css = ["book.css"]
git-repository-url = "https://github.com/gretzke/foundry-template"
git-repository-url = "https://github.com/Uniswap/foundry-template"

[output.html.fold]
enable = true

This file was deleted.

25 changes: 17 additions & 8 deletions script/util/doc_gen.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e
forge build
rm -rf docs/autogen
# generate docs
forge doc -b -o docs/autogen

Expand All @@ -9,12 +11,19 @@ files=$(git diff --name-only -- 'docs/autogen/*')

# Loop over each file
for file in $files; do
# Get the diff for the file, only lines that start with - or +
diff=$(git diff $file | grep '^[+-][^+-]')
# Check if there are any other changes in the diff besides the commit hash (in that case the file has more than 1 line that changed, one minus one plus)
if [[ $(echo "$diff" | wc -l) -eq 2 ]]; then
# If there are no other changes, discard the changes for the file
git reset HEAD $file
git checkout -- $file
# Check if the file exists
if [[ -f $file ]]; then
# Get the diff for the file, strip metadata and only keep lines that start with - or +
diff=$(git diff $file | sed '/^diff --git/d; /^index /d; /^--- /d; /^\+\+\+ /d; /^@@ /d' | grep '^[+-]')

# Filter lines that start with -[Git Source] or +[Git Source]
filtered_diff=$(echo "$diff" | grep '^\-\[Git Source\]\|^\+\[Git Source\]' || true)

# Compare the original diff with the filtered diff
if [[ "$diff" == "$filtered_diff" ]]; then
# If they are equal, discard the changes for the file
git reset HEAD $file
git checkout -- $file
fi
fi
done

0 comments on commit 0864bd3

Please sign in to comment.