Something went wrong. Try again.
Documentation website about Ruby gems for ATProto ruby.sdk.blue
atprotocol bluesky ruby atproto
Something went wrong. Try again.
ruby.sdk.blue gen_examples.sh
1.0 kB · 38 lines
Shell
at master
123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash
files=$(find examples -name '*.rb' | sort)outdir="src/examples"index="$outdir/index.md"mkdir -p $outdir
echo "---" > $indexecho "prev: 'Tapfall | Changelog'" >> $indexecho "---" >> $indexecho "" >> $indexecho "# Examples" >> $indexecho "" >> $index
for file in $files; do filename=$(basename "$file") title=$(basename "$file" .rb) output="$outdir/$title.md"
echo "---" > $output echo "pageClass: 'examples-page'" >> $output echo "---" >> $output echo "" >> $output echo "# $filename" >> $output echo "" >> $output
description=$(cat $file | tail +3 | awk '/^#/ { print; next } { exit }' | sed -Ee 's/^# ?//') echo "$description" >> $output
code=$(cat $file | tail +3 | awk 'started { print; next } !/^#/ { end_hash = 1 } /^[[:space:]]*$/ { next } end_hash { started = 1; print }')
echo "" >> $output echo "\`\`\`rb" >> $output echo "$code" | grep -v "'bundler/setup'" >> $output echo "\`\`\`" >> $output
echo "- [$filename](/examples/$title)" >> $indexdone