From 0864bd3fda3ae2b97362ae80691cd59ca9cf5090 Mon Sep 17 00:00:00 2001 From: gretzke Date: Wed, 30 Oct 2024 02:30:09 +0100 Subject: [PATCH] fix a few bugs with doc generation --- docs/autogen/book.toml | 2 +- .../IVersioned.sol/interface.IVersioned.md | 18 ------------- script/util/doc_gen.sh | 25 +++++++++++++------ 3 files changed, 18 insertions(+), 27 deletions(-) delete mode 100644 docs/autogen/src/src/interface/IVersioned.sol/interface.IVersioned.md diff --git a/docs/autogen/book.toml b/docs/autogen/book.toml index 5677d7a..9ef6709 100644 --- a/docs/autogen/book.toml +++ b/docs/autogen/book.toml @@ -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 diff --git a/docs/autogen/src/src/interface/IVersioned.sol/interface.IVersioned.md b/docs/autogen/src/src/interface/IVersioned.sol/interface.IVersioned.md deleted file mode 100644 index edc2c3e..0000000 --- a/docs/autogen/src/src/interface/IVersioned.sol/interface.IVersioned.md +++ /dev/null @@ -1,18 +0,0 @@ -# IVersioned -[Git Source](https://github.com/gretzke/foundry-template/blob/952489c408f511dc764c05d3a2a21ded78da224f/src/interface/IVersioned.sol) - - -## Functions -### version - - -```solidity -function version() external pure returns (string memory); -``` -**Returns** - -|Name|Type|Description| -|----|----|-----------| -|``|`string`|The version of the contract| - - diff --git a/script/util/doc_gen.sh b/script/util/doc_gen.sh index 15f35c5..c6f4eae 100755 --- a/script/util/doc_gen.sh +++ b/script/util/doc_gen.sh @@ -1,5 +1,7 @@ #!/bin/bash - +set -e +forge build +rm -rf docs/autogen # generate docs forge doc -b -o docs/autogen @@ -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 \ No newline at end of file