Skip to content

Commit

Permalink
Merge pull request #33 from terrastruct/whitespace-2eec
Browse files Browse the repository at this point in the history
fmt: trailing whitespace fixes
  • Loading branch information
nhooyr authored Dec 16, 2022
2 parents 7cca792 + 1004eb7 commit d5277a8
Show file tree
Hide file tree
Showing 118 changed files with 901 additions and 1,480 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

.PHONY: all
all: fmt build
ifndef CI
all: gen
endif

.PHONY: fmt
fmt: node_modules
prefix "$@" ./ci/sub/bin/fmt.sh
.PHONY: gen
gen:
prefix "$@" ./ci/render.sh
.PHONY: build
build: node_modules
prefix "$@" yarn build
ifndef CI
build: gen
endif
.PHONY: node_modules
node_modules:
prefix "$@" yarn $${CI:+--immutable} $${CI:+--immutable-cache}
78 changes: 53 additions & 25 deletions ci/render.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,58 @@
#!/bin/sh
set -eu
. "$(dirname "$0")/../ci/sub/lib.sh"
cd -- "$(dirname "$0")/.."
examples=()

_d2() {
sh_c D2_LAYOUT=tala hide d2 ./src/examples/"$ex"/syntax/d2.d2 ./src/examples/"$ex"/render/d2_tala.svg
sh_c D2_LAYOUT=dagre hide d2 ./src/examples/"$ex"/syntax/d2.d2 ./src/examples/"$ex"/render/d2_dagre.svg
sh_c D2_LAYOUT=elk hide d2 ./src/examples/"$ex"/syntax/d2.d2 ./src/examples/"$ex"/render/d2_elk.svg
}

if [ -z "$1" ]
then
# Rendering for all examples
search_dir=./src/examples
for f in "$search_dir"/*
do
filename=$(basename -- "$f")
examples+=("$filename")
mmdc() {
config=$(mktempd)/mmdc-config
echo '{"deterministicIds": true}' >$config
npx --package @mermaid-js/[email protected] -- mmdc -c"$config" "$@"
}

_mmdc() {
sh_c mmdc -i ./src/examples/"$ex"/syntax/mermaid.mmd -o ./src/examples/"$ex"/render/mermaid_dagre.svg
}

_dot() {
sh_c dot -Tsvg ./src/examples/"$ex"/syntax/graphviz.dot >src/examples/"$ex"/render/graphviz_dot.svg
sh_c dot -Kneato -Tsvg ./src/examples/"$ex"/syntax/graphviz.dot >src/examples/"$ex"/render/graphviz_neato.svg
}

_plantuml() {
sh_c plantuml -Tsvg ./src/examples/"$ex"/syntax/plantuml.puml -o ../render
mv ./src/examples/"$ex"/render/plantuml.svg ./src/examples/"$ex"/render/plantuml_dot.svg
}

main() {
job_parseflags "$@"
for ex in $(find ./src/examples -mindepth 1 -maxdepth 1 | sort -V); do
ex=${ex#./src/examples/}
export JOBNAME=$ex
if ! _runjob_filter; then
continue
fi

bigheader "$ex"
if [ -f ./src/examples/"$ex"/syntax/d2.d2 ]; then
runjob _d2 &
fi
if [ -f ./src/examples/"$ex"/syntax/mermaid.mmd ]; then
runjob _mmdc &
fi
if [ -f ./src/examples/"$ex"/syntax/graphviz.dot ]; then
[ "$ex" != 8_text ] && runjob _dot &
fi
if [ -f ./src/examples/"$ex"/syntax/plantuml.puml ]; then
runjob _plantuml &
fi
waitjobs
done
else
# Rendering for a specific example
examples+=($1)
fi

for ex in ${examples[@]}
do
D2_LAYOUT=tala d2 src/examples/$ex/syntax/d2 src/examples/$ex/render/d2_tala.svg
D2_LAYOUT=dagre d2 src/examples/$ex/syntax/d2 src/examples/$ex/render/d2_dagre.svg
D2_LAYOUT=elk d2 src/examples/$ex/syntax/d2 src/examples/$ex/render/d2_elk.svg
mmdc -i src/examples/$ex/syntax/mermaid -o src/examples/$ex/render/mermaid_dagre.svg
dot -Tsvg src/examples/$ex/syntax/graphviz > src/examples/$ex/render/graphviz_dot.svg
dot -Kneato -Tsvg src/examples/$ex/syntax/graphviz > src/examples/$ex/render/graphviz_neato.svg
plantuml -Tsvg src/examples/$ex/syntax/plantuml -o ../render
mv src/examples/$ex/render/plantuml.svg src/examples/$ex/render/plantuml_dot.svg
done
}

main "$@"
2 changes: 1 addition & 1 deletion ci/sub
Submodule sub updated 6 files
+3 −3 examples/date.sh
+54 −8 lib.sh
+8 −1 lib/job.sh
+1 −1 lib/log.sh
+1 −6 lib/misc.sh
+46 −0 lib/ssh.sh
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ if [ ! -e "$(dirname "$0")/ci/sub/.git" ]; then
fi
. "$(dirname "$0")/ci/sub/lib.sh"
PATH="$(cd -- "$(dirname "$0")" && pwd)/ci/sub/bin:$PATH"
cd "$(dirname "$0")"
cd -- "$(dirname "$0")"

_make "$@"
42 changes: 20 additions & 22 deletions src/examples/0_basic/render/d2_dagre.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 9 additions & 5 deletions src/examples/0_basic/render/d2_elk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 18 additions & 20 deletions src/examples/0_basic/render/d2_tala.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/examples/0_basic/render/graphviz_dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/examples/0_basic/render/graphviz_neato.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d5277a8

Please sign in to comment.