Skip to content

Commit

Permalink
Fix script and add button image
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesbvll committed Apr 4, 2024
1 parent 81bb4a1 commit 491fdc8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
49 changes: 27 additions & 22 deletions dev/update-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,35 @@ rm -f "examples/doc/source/*.md"
cd examples/
for d in $(printf '%s\n' */ | sort -V); do
example=${d%/}
# For each example, copy the README into the source of the Example docs
[[ $example != doc ]] && cp $example/README.md $ROOT/examples/doc/source/$example.md 2>&1 >/dev/null

gh_text="[<img src=\"_static/view-gh.png\" alt=\"View on GitHub\" width=\"200\"/>](https://github.com/adap/flower/blob/main/$example)"
readme_file="$ROOT/examples/doc/source/$example.md"

if ! grep -Fq "$gh_text" "$readme_file"; then
awk -v text="$gh_text" '
/^# / && !found {
print $0 "\n" text;
found=1;
next;

if [[ $example != doc ]]; then

# For each example, copy the README into the source of the Example docs
cp $example/README.md $ROOT/examples/doc/source/$example.md 2>&1 >/dev/null

gh_text="[<img src=\"_static/view-gh.png\" alt=\"View on GitHub\" width=\"200\"/>](https://github.com/adap/flower/blob/main/examples/$example)"
readme_file="$ROOT/examples/doc/source/$example.md"

if ! grep -Fq "$gh_text" "$readme_file"; then
awk -v text="$gh_text" '
/^# / && !found {
print $0 "\n" text;
found=1;
next;
}
{ print }
' "$readme_file" > tmpfile && mv tmpfile "$readme_file"
fi

# For each example, copy all images of the _static folder into the examples
# docs static folder
[ -d "$example/_static" ] && {
cp $example/_static/**.{jpg,png,jpeg} $ROOT/examples/doc/source/_static/ 2>/dev/null || true
}
{ print }
' "$readme_file" > tmpfile && mv tmpfile "$readme_file"
# For each example, insert the name of the example into the index file
(echo $INSERT_LINE; echo a; echo $example; echo .; echo wq) | ed $INDEX 2>&1 >/dev/null

fi

# For each example, copy all images of the _static folder into the examples
# docs static folder
[[ $example != doc ]] && [ -d "$example/_static" ] && {
cp $example/_static/**.{jpg,png,jpeg} $ROOT/examples/doc/source/_static/ 2>/dev/null || true
}
# For each example, insert the name of the example into the index file
[[ $example != doc ]] && (echo $INSERT_LINE; echo a; echo $example; echo .; echo wq) | ed $INDEX 2>&1 >/dev/null
done

echo "\`\`\`" >> $INDEX
Expand Down
1 change: 1 addition & 0 deletions examples/doc/source/_static/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
!favicon.ico
!flower-logo.png
!tmux_jtop_view.gif
!view-gh.png
Binary file added examples/doc/source/_static/view-gh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 491fdc8

Please sign in to comment.