From 37f0f8b408993ace59575fced8c44ee2da9dffce Mon Sep 17 00:00:00 2001 From: Daniel Rojas Date: Mon, 15 Jun 2020 17:58:29 +0200 Subject: [PATCH] Add syntax highlighting to readme's --- readme.md | 50 ++--- src/batch.py | 6 +- tutorial/readme.md | 450 +++++++++++++++++++++++---------------------- 3 files changed, 262 insertions(+), 244 deletions(-) diff --git a/readme.md b/readme.md index b6373f3..d62936b 100644 --- a/readme.md +++ b/readme.md @@ -30,32 +30,34 @@ _Note_: WireViz is not designed to represent the complete wiring of a system. It [WireViz input file](examples/demo01.yml): - connectors: - X1: - type: D-Sub - subtype: female - pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] - X2: - type: Molex KK 254 - subtype: female - pinout: [GND, RX, TX] +```yaml +connectors: + X1: + type: D-Sub + subtype: female + pinout: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI] + X2: + type: Molex KK 254 + subtype: female + pinout: [GND, RX, TX] - cables: - W1: - gauge: 0.25 mm2 - length: 0.2 - color_code: DIN - wirecount: 3 - shield: true +cables: + W1: + gauge: 0.25 mm2 + length: 0.2 + color_code: DIN + wirecount: 3 + shield: true - connections: - - - - X1: [5,2,1] - - W1: [1,2,3] - - X2: [1,3,2] - - - - X1: 5 - - W1: s +connections: + - + - X1: [5,2,1] + - W1: [1,2,3] + - X2: [1,3,2] + - + - X1: 5 + - W1: s +``` Output file: diff --git a/src/batch.py b/src/batch.py index 6718452..6b24189 100644 --- a/src/batch.py +++ b/src/batch.py @@ -33,12 +33,14 @@ if tutorials: with open(os.path.abspath('../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info: for line in info: - file.write('{}'.format(line)) + file.write(line) 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: + file.write('```yaml\n') for line in src: - file.write(' {}'.format(line)) + file.write(line) + file.write('```\n') file.write('\n') file.write('\nOutput:\n\n'.format(i)) diff --git a/tutorial/readme.md b/tutorial/readme.md index cdc9be5..9f73220 100644 --- a/tutorial/readme.md +++ b/tutorial/readme.md @@ -6,22 +6,24 @@ [Source](tutorial01.yml): - connectors: - X1: - pincount: 4 - X2: - pincount: 4 - - cables: - W1: - wirecount: 4 - length: 1 - - connections: - - - - X1: [1-4] - - W1: [1-4] - - X2: [1-4] +```yaml +connectors: + X1: + pincount: 4 + X2: + pincount: 4 + +cables: + W1: + wirecount: 4 + length: 1 + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1-4] +``` Output: @@ -36,32 +38,34 @@ Output: [Source](tutorial02.yml): - connectors: - X1: - pincount: 4 - # More connector parameters: - type: Molex KK 254 - subtype: female - X2: - pincount: 4 - type: Molex KK 254 - subtype: female - - cables: - W1: - wirecount: 4 - # more cable parameters: - length: 1 - gauge: 0.25 mm2 - show_equiv: true - colors: [WH, BN, GN, YE] - - connections: - - - - X1: [1-4] - - W1: [1-4] - # non-sequential wiring: - - X2: [1,2,4,3] +```yaml +connectors: + X1: + pincount: 4 + # More connector parameters: + type: Molex KK 254 + subtype: female + X2: + pincount: 4 + type: Molex KK 254 + subtype: female + +cables: + W1: + wirecount: 4 + # more cable parameters: + length: 1 + gauge: 0.25 mm2 + show_equiv: true + colors: [WH, BN, GN, YE] + +connections: + - + - X1: [1-4] + - W1: [1-4] + # non-sequential wiring: + - X2: [1,2,4,3] +``` Output: @@ -78,31 +82,33 @@ Output: [Source](tutorial03.yml): - connectors: - X1: &template1 # define a template for later use - pinout: [GND, VCC, RX, TX] # pincount implicit in pinout - type: Molex KK 254 - subtype: female - X2: - <<: *template1 # reuse template - - cables: - W1: - wirecount: 4 - length: 1 - gauge: 0.25 mm2 - show_equiv: true - color_code: DIN # auto-assign colors based on DIN 47100 - shield: true # add cable shielding - - connections: - - - - X1: [1-4] - - W1: [1-4] - - X2: [1,2,4,3] - - # connect the shielding to a pin - - X1: 1 - - W1: s +```yaml +connectors: + X1: &template1 # define a template for later use + pinout: [GND, VCC, RX, TX] # pincount implicit in pinout + type: Molex KK 254 + subtype: female + X2: + <<: *template1 # reuse template + +cables: + W1: + wirecount: 4 + length: 1 + gauge: 0.25 mm2 + show_equiv: true + color_code: DIN # auto-assign colors based on DIN 47100 + shield: true # add cable shielding + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1,2,4,3] + - # connect the shielding to a pin + - X1: 1 + - W1: s +``` Output: @@ -117,40 +123,42 @@ Output: [Source](tutorial04.yml): - connectors: - X1: &template_con - pinout: [GND, VCC, SCL, SDA] - type: Molex KK 254 - subtype: male - notes: to microcontroller # add notes - X2: - <<: *template_con # use template - subtype: female # but override certain parameters - notes: to accelerometer - X3: - <<: *template_con - subtype: female - notes: to temperature sensor - - cables: - W1: &template_cbl - wirecount: 4 - length: 0.3 - gauge: 24 AWG # specifying guage in AWG directly - color_code: IEC # IEC 62 colors also supported - W2: - <<: *template_cbl - length: 0.1 - - connections: - - - - X1: [1-4] - - W1: [1-4] - - X2: [1-4] - - # daisy chain connectors (in line) - - X2: [1-4] - - W2: [1-4] - - X3: [1-4] +```yaml +connectors: + X1: &template_con + pinout: [GND, VCC, SCL, SDA] + type: Molex KK 254 + subtype: male + notes: to microcontroller # add notes + X2: + <<: *template_con # use template + subtype: female # but override certain parameters + notes: to accelerometer + X3: + <<: *template_con + subtype: female + notes: to temperature sensor + +cables: + W1: &template_cbl + wirecount: 4 + length: 0.3 + gauge: 24 AWG # specifying guage in AWG directly + color_code: IEC # IEC 62 colors also supported + W2: + <<: *template_cbl + length: 0.1 + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1-4] + - # daisy chain connectors (in line) + - X2: [1-4] + - W2: [1-4] + - X3: [1-4] +``` Output: @@ -168,33 +176,35 @@ Output: [Source](tutorial05.yml): - connectors: - X1: - pinout: [+12V, GND, GND, +5V] - type: Molex 8981 - subtype: female - - ferrules: # ferrules - F1: - type: Ferrule, crimp - subtype: 0.5 mm² - color: OG # optional color - - cables: - W1: - category: bundle # bundle - length: 0.3 - gauge: 0.5 mm - colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit - notes: hello! - - connections: - - # attach ferrules - - F1 - - W1: [1-4] # a new ferrule is auto-generated for each wire - - # attach connectors (separetely from ferrules) - - W1: [1-4] - - X1: [1-4] +```yaml +connectors: + X1: + pinout: [+12V, GND, GND, +5V] + type: Molex 8981 + subtype: female + +ferrules: # ferrules + F1: + type: Ferrule, crimp + subtype: 0.5 mm² + color: OG # optional color + +cables: + W1: + category: bundle # bundle + length: 0.3 + gauge: 0.5 mm + colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit + notes: hello! + +connections: + - # attach ferrules + - F1 + - W1: [1-4] # a new ferrule is auto-generated for each wire + - # attach connectors (separetely from ferrules) + - W1: [1-4] + - X1: [1-4] +``` Output: @@ -208,44 +218,46 @@ Output: [Source](tutorial06.yml): - connectors: - X1: - pinout: [+12V, GND, GND, +5V] - type: Molex 8981 - subtype: female - F_10_1: # manually define a ferrule (with unique identifier) - category: ferrule - type: Ferrule, crimp - subtype: 1.0 mm² - color: YE - - ferrules: # ferrules - F_05: - type: Ferrule, crimp - subtype: 0.5 mm² - color: OG # optional color - - cables: - W1: - category: bundle # budnle - length: 0.3 - gauge: 0.5 mm - colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit - - connections: - - # attach ferrules - - F_05 - - W1: [1,4] # a new ferrule is auto-generated for each wire - - # attach connectors (separetely from ferrules) - - W1: [1-4] - - X1: [1-4] - - - - F_10_1: 1 # manually defined ferrules are treated like regular connectors, - # thus requiring a pin number - - W1: 2 - - - - F_10_1: 1 - - W1: 3 +```yaml +connectors: + X1: + pinout: [+12V, GND, GND, +5V] + type: Molex 8981 + subtype: female + F_10_1: # manually define a ferrule (with unique identifier) + category: ferrule + type: Ferrule, crimp + subtype: 1.0 mm² + color: YE + +ferrules: # ferrules + F_05: + type: Ferrule, crimp + subtype: 0.5 mm² + color: OG # optional color + +cables: + W1: + category: bundle # budnle + length: 0.3 + gauge: 0.5 mm + colors: [YE, BK, BK, RD] # custom colors, wirecount is implicit + +connections: + - # attach ferrules + - F_05 + - W1: [1,4] # a new ferrule is auto-generated for each wire + - # attach connectors (separetely from ferrules) + - W1: [1-4] + - X1: [1-4] + - + - F_10_1: 1 # manually defined ferrules are treated like regular connectors, + # thus requiring a pin number + - W1: 2 + - + - F_10_1: 1 + - W1: 3 +``` Output: @@ -258,58 +270,60 @@ Output: [Source](tutorial07.yml): - connectors: - X1: &template_con - type: Molex KK 254 - subtype: female - pinout: [GND, VCC, SCL, SDA] - X2: - <<: *template_con - X3: - <<: *template_con - X4: - <<: *template_con - X5: - <<: *template_con - X6: - <<: *template_con - - cables: - W1: &template_wire - gauge: 0.25 mm2 - length: 0.2 - colors: [TQ, PK, YE, VT] - category: bundle - W2: - <<: *template_wire - W3: - <<: *template_wire - W4: - <<: *template_wire - W5: - <<: *template_wire - - connections: - - - - X1: [1-4] - - W1: [1-4] - - X2: [1-4] - - - - X3: [1-4] - - W2: [1-4] - - X2: [1-4] - - - - X3: [1-4] - - W3: [1-4] - - X4: [1-4] - - - - X5: [1-4] - - W4: [1-4] - - X4: [1-4] - - - - X5: [1-4] - - W5: [1-4] - - X6: [1-4] +```yaml +connectors: + X1: &template_con + type: Molex KK 254 + subtype: female + pinout: [GND, VCC, SCL, SDA] + X2: + <<: *template_con + X3: + <<: *template_con + X4: + <<: *template_con + X5: + <<: *template_con + X6: + <<: *template_con + +cables: + W1: &template_wire + gauge: 0.25 mm2 + length: 0.2 + colors: [TQ, PK, YE, VT] + category: bundle + W2: + <<: *template_wire + W3: + <<: *template_wire + W4: + <<: *template_wire + W5: + <<: *template_wire + +connections: + - + - X1: [1-4] + - W1: [1-4] + - X2: [1-4] + - + - X3: [1-4] + - W2: [1-4] + - X2: [1-4] + - + - X3: [1-4] + - W3: [1-4] + - X4: [1-4] + - + - X5: [1-4] + - W4: [1-4] + - X4: [1-4] + - + - X5: [1-4] + - W5: [1-4] + - X6: [1-4] +``` Output: