Browse Source

add scripts and stuff necessary to automatically generate the diagram using graph-easy...

required writting a simple awk script to add the necessary border for MarkDeep..
haven't integrated the diagram generation into the file yet..
main
John-Mark Gurney 5 years ago
parent
commit
cb870fadaa
4 changed files with 72 additions and 0 deletions
  1. +6
    -0
      Makefile
  2. +32
    -0
      box.sh
  3. +25
    -0
      diag.txt
  4. +9
    -0
      diag_inp.txt

+ 6
- 0
Makefile View File

@@ -0,0 +1,6 @@
# https://github.com/ironcamel/Graph-Easy
diag.txt: diag_inp.txt box.sh
graph-easy < $< | sh box.sh > $@

diagtest:
ls box.sh diag_inp.txt Makefile | entr sh -c 'make diag.txt && cat diag.txt'

+ 32
- 0
box.sh View File

@@ -0,0 +1,32 @@
#!/bin/sh
fname=$(mktemp foobar.XXXXX)
cat > "$fname"
awk '
maxline == 1 {
if (maxlength < length)
maxlength = length
}

function printtop () {
blank = ""
for (i = 0; i < maxlength + 4; i++)
blank = blank "*"
printf("%s\n", blank)
}

output == 1 && FNR == 1 {
printtop()
printf("* %*s *\n", maxlength, "")
}

output == 1 {
printf("* %s%*s *\n", $0, maxlength - length, "")
}

END {
printf("* %*s *\n", maxlength, "")
printtop()
}
' maxline=1 "$fname" maxline=0 output=1 "$fname"

rm "$fname"

+ 25
- 0
diag.txt View File

@@ -0,0 +1,25 @@
*********************************************************************************
* *
* +-------------+ *
* | Internet | *
* +-------------+ *
* | *
* | *
* | *
* +----------------+ +-------------+ *
* | Host machine |-----------------------------| VLAN Switch | *
* +----------------+ +-------------+ *
* | | *
* | | *
* | | *
* +----------------+ +-----------------+ +-------------+ +--------+ *
* | USB Hub | --- | Power Controler | --- | RockPro64 | | 12V PS | *
* +----------------+ +-----------------+ +-------------+ +--------+ *
* | | | | *
* | +-----------------------+-------------------+ *
* | | *
* +----------------+ | *
* | Serial adapter |-------------------------------+ *
* +----------------+ *
* *
*********************************************************************************

+ 9
- 0
diag_inp.txt View File

@@ -0,0 +1,9 @@
[ Internet ] { flow: north } -- [ VLAN Switch ]
[ Host machine ] -- [ VLAN Switch ]
[ Host machine ] { flow: south } -- [ USB Hub ]
[ RockPro64 ] { flow: north } -- [ VLAN Switch ]
[ USB Hub ] -- [ Power Controler ]
[ USB Hub ] -- [ Serial adapter ]
[ Serial adapter ] -- [ RockPro64 ]
[ Power Controler ] -- [ 12V PS ]
[ Power Controler ] { flow: east } -- [ RockPro64 ]

Loading…
Cancel
Save