Add syntax highlighting to readme's

This commit is contained in:
Daniel Rojas 2020-06-15 17:58:29 +02:00
parent 07fa0e2ee2
commit 37f0f8b408
3 changed files with 262 additions and 244 deletions

View File

@ -30,32 +30,34 @@ _Note_: WireViz is not designed to represent the complete wiring of a system. It
[WireViz input file](examples/demo01.yml): [WireViz input file](examples/demo01.yml):
connectors: ```yaml
X1: connectors:
type: D-Sub X1:
subtype: female type: D-Sub
pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] subtype: female
X2: pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI]
type: Molex KK 254 X2:
subtype: female type: Molex KK 254
pinout: [GND, RX, TX] subtype: female
pinout: [GND, RX, TX]
cables: cables:
W1: W1:
gauge: 0.25 mm2 gauge: 0.25 mm2
length: 0.2 length: 0.2
color_code: DIN color_code: DIN
wirecount: 3 wirecount: 3
shield: true shield: true
connections: connections:
- -
- X1: [5,2,1] - X1: [5,2,1]
- W1: [1,2,3] - W1: [1,2,3]
- X2: [1,3,2] - X2: [1,3,2]
- -
- X1: 5 - X1: 5
- W1: s - W1: s
```
Output file: Output file:

View File

@ -33,12 +33,14 @@ if tutorials:
with open(os.path.abspath('../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info: with open(os.path.abspath('../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info:
for line in info: for line in info:
file.write('{}'.format(line)) file.write(line)
file.write('\n[Source](tutorial{:02d}.yml):\n\n'.format(i)) file.write('\n[Source](tutorial{:02d}.yml):\n\n'.format(i))
with open(os.path.abspath('../tutorial/tutorial{:02d}.yml'.format(i)), 'r') as src: with open(os.path.abspath('../tutorial/tutorial{:02d}.yml'.format(i)), 'r') as src:
file.write('```yaml\n')
for line in src: for line in src:
file.write(' {}'.format(line)) file.write(line)
file.write('```\n')
file.write('\n') file.write('\n')
file.write('\nOutput:\n\n'.format(i)) file.write('\nOutput:\n\n'.format(i))

View File

@ -6,22 +6,24 @@
[Source](tutorial01.yml): [Source](tutorial01.yml):
connectors: ```yaml
X1: connectors:
pincount: 4 X1:
X2: pincount: 4
pincount: 4 X2:
pincount: 4
cables:
W1: cables:
wirecount: 4 W1:
length: 1 wirecount: 4
length: 1
connections:
- connections:
- X1: [1-4] -
- W1: [1-4] - X1: [1-4]
- X2: [1-4] - W1: [1-4]
- X2: [1-4]
```
Output: Output:
@ -36,32 +38,34 @@ Output:
[Source](tutorial02.yml): [Source](tutorial02.yml):
connectors: ```yaml
X1: connectors:
pincount: 4 X1:
# More connector parameters: pincount: 4
type: Molex KK 254 # More connector parameters:
subtype: female type: Molex KK 254
X2: subtype: female
pincount: 4 X2:
type: Molex KK 254 pincount: 4
subtype: female type: Molex KK 254
subtype: female
cables:
W1: cables:
wirecount: 4 W1:
# more cable parameters: wirecount: 4
length: 1 # more cable parameters:
gauge: 0.25 mm2 length: 1
show_equiv: true gauge: 0.25 mm2
colors: [WH, BN, GN, YE] show_equiv: true
colors: [WH, BN, GN, YE]
connections:
- connections:
- X1: [1-4] -
- W1: [1-4] - X1: [1-4]
# non-sequential wiring: - W1: [1-4]
- X2: [1,2,4,3] # non-sequential wiring:
- X2: [1,2,4,3]
```
Output: Output:
@ -78,31 +82,33 @@ Output:
[Source](tutorial03.yml): [Source](tutorial03.yml):
connectors: ```yaml
X1: &template1 # define a template for later use connectors:
pinout: [GND, VCC, RX, TX] # pincount implicit in pinout X1: &template1 # define a template for later use
type: Molex KK 254 pinout: [GND, VCC, RX, TX] # pincount implicit in pinout
subtype: female type: Molex KK 254
X2: subtype: female
<<: *template1 # reuse template X2:
<<: *template1 # reuse template
cables:
W1: cables:
wirecount: 4 W1:
length: 1 wirecount: 4
gauge: 0.25 mm2 length: 1
show_equiv: true gauge: 0.25 mm2
color_code: DIN # auto-assign colors based on DIN 47100 show_equiv: true
shield: true # add cable shielding color_code: DIN # auto-assign colors based on DIN 47100
shield: true # add cable shielding
connections:
- connections:
- X1: [1-4] -
- W1: [1-4] - X1: [1-4]
- X2: [1,2,4,3] - W1: [1-4]
- # connect the shielding to a pin - X2: [1,2,4,3]
- X1: 1 - # connect the shielding to a pin
- W1: s - X1: 1
- W1: s
```
Output: Output:
@ -117,40 +123,42 @@ Output:
[Source](tutorial04.yml): [Source](tutorial04.yml):
connectors: ```yaml
X1: &template_con connectors:
pinout: [GND, VCC, SCL, SDA] X1: &template_con
type: Molex KK 254 pinout: [GND, VCC, SCL, SDA]
subtype: male type: Molex KK 254
notes: to microcontroller # add notes subtype: male
X2: notes: to microcontroller # add notes
<<: *template_con # use template X2:
subtype: female # but override certain parameters <<: *template_con # use template
notes: to accelerometer subtype: female # but override certain parameters
X3: notes: to accelerometer
<<: *template_con X3:
subtype: female <<: *template_con
notes: to temperature sensor subtype: female
notes: to temperature sensor
cables:
W1: &template_cbl cables:
wirecount: 4 W1: &template_cbl
length: 0.3 wirecount: 4
gauge: 24 AWG # specifying guage in AWG directly length: 0.3
color_code: IEC # IEC 62 colors also supported gauge: 24 AWG # specifying guage in AWG directly
W2: color_code: IEC # IEC 62 colors also supported
<<: *template_cbl W2:
length: 0.1 <<: *template_cbl
length: 0.1
connections:
- connections:
- X1: [1-4] -
- W1: [1-4] - X1: [1-4]
- X2: [1-4] - W1: [1-4]
- # daisy chain connectors (in line) - X2: [1-4]
- X2: [1-4] - # daisy chain connectors (in line)
- W2: [1-4] - X2: [1-4]
- X3: [1-4] - W2: [1-4]
- X3: [1-4]
```
Output: Output:
@ -168,33 +176,35 @@ Output:
[Source](tutorial05.yml): [Source](tutorial05.yml):
connectors: ```yaml
X1: connectors:
pinout: [+12V, GND, GND, +5V] X1:
type: Molex 8981 pinout: [+12V, GND, GND, +5V]
subtype: female type: Molex 8981
subtype: female
ferrules: # ferrules
F1: ferrules: # ferrules
type: Ferrule, crimp F1:
subtype: 0.5 mm² type: Ferrule, crimp
color: OG # optional color subtype: 0.5 mm²
color: OG # optional color
cables:
W1: cables:
category: bundle # bundle W1:
length: 0.3 category: bundle # bundle
gauge: 0.5 mm length: 0.3
colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit gauge: 0.5 mm
notes: hello! colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit
notes: hello!
connections:
- # attach ferrules connections:
- F1 - # attach ferrules
- W1: [1-4] # a new ferrule is auto-generated for each wire - F1
- # attach connectors (separetely from ferrules) - W1: [1-4] # a new ferrule is auto-generated for each wire
- W1: [1-4] - # attach connectors (separetely from ferrules)
- X1: [1-4] - W1: [1-4]
- X1: [1-4]
```
Output: Output:
@ -208,44 +218,46 @@ Output:
[Source](tutorial06.yml): [Source](tutorial06.yml):
connectors: ```yaml
X1: connectors:
pinout: [+12V, GND, GND, +5V] X1:
type: Molex 8981 pinout: [+12V, GND, GND, +5V]
subtype: female type: Molex 8981
F_10_1: # manually define a ferrule (with unique identifier) subtype: female
category: ferrule F_10_1: # manually define a ferrule (with unique identifier)
type: Ferrule, crimp category: ferrule
subtype: 1.0 mm² type: Ferrule, crimp
color: YE subtype: 1.0 mm²
color: YE
ferrules: # ferrules
F_05: ferrules: # ferrules
type: Ferrule, crimp F_05:
subtype: 0.5 mm² type: Ferrule, crimp
color: OG # optional color subtype: 0.5 mm²
color: OG # optional color
cables:
W1: cables:
category: bundle # budnle W1:
length: 0.3 category: bundle # budnle
gauge: 0.5 mm length: 0.3
colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit gauge: 0.5 mm
colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit
connections:
- # attach ferrules connections:
- F_05 - # attach ferrules
- W1: [1,4] # a new ferrule is auto-generated for each wire - F_05
- # attach connectors (separetely from ferrules) - W1: [1,4] # a new ferrule is auto-generated for each wire
- W1: [1-4] - # attach connectors (separetely from ferrules)
- X1: [1-4] - W1: [1-4]
- - X1: [1-4]
- F_10_1: 1 # manually defined ferrules are treated like regular connectors, -
# thus requiring a pin number - F_10_1: 1 # manually defined ferrules are treated like regular connectors,
- W1: 2 # thus requiring a pin number
- - W1: 2
- F_10_1: 1 -
- W1: 3 - F_10_1: 1
- W1: 3
```
Output: Output:
@ -258,58 +270,60 @@ Output:
[Source](tutorial07.yml): [Source](tutorial07.yml):
connectors: ```yaml
X1: &template_con connectors:
type: Molex KK 254 X1: &template_con
subtype: female type: Molex KK 254
pinout: [GND, VCC, SCL, SDA] subtype: female
X2: pinout: [GND, VCC, SCL, SDA]
<<: *template_con X2:
X3: <<: *template_con
<<: *template_con X3:
X4: <<: *template_con
<<: *template_con X4:
X5: <<: *template_con
<<: *template_con X5:
X6: <<: *template_con
<<: *template_con X6:
<<: *template_con
cables:
W1: &template_wire cables:
gauge: 0.25 mm2 W1: &template_wire
length: 0.2 gauge: 0.25 mm2
colors: [TQ, PK, YE, VT] length: 0.2
category: bundle colors: [TQ, PK, YE, VT]
W2: category: bundle
<<: *template_wire W2:
W3: <<: *template_wire
<<: *template_wire W3:
W4: <<: *template_wire
<<: *template_wire W4:
W5: <<: *template_wire
<<: *template_wire W5:
<<: *template_wire
connections:
- connections:
- X1: [1-4] -
- W1: [1-4] - X1: [1-4]
- X2: [1-4] - W1: [1-4]
- - X2: [1-4]
- X3: [1-4] -
- W2: [1-4] - X3: [1-4]
- X2: [1-4] - W2: [1-4]
- - X2: [1-4]
- X3: [1-4] -
- W3: [1-4] - X3: [1-4]
- X4: [1-4] - W3: [1-4]
- - X4: [1-4]
- X5: [1-4] -
- W4: [1-4] - X5: [1-4]
- X4: [1-4] - W4: [1-4]
- - X4: [1-4]
- X5: [1-4] -
- W5: [1-4] - X5: [1-4]
- X6: [1-4] - W5: [1-4]
- X6: [1-4]
```
Output: Output: