summaryrefslogtreecommitdiffstats
path: root/2020/subtitles/emacsconf-2020--14-readme-driven-design--adam-ard-autogen.sbv
blob: 506a26eb88be2169cd809439170d0807b2e7c040 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
0:00:03.600,0:00:06.560
hello

0:00:04.400,0:00:08.400
welcome to readme driven design in Emacs

0:00:06.560,0:00:10.800
by adam aard

0:00:08.400,0:00:12.559
if you're a programmer you're accustomed

0:00:10.800,0:00:13.759
to putting a readme file at the root of

0:00:12.559,0:00:16.400
your project

0:00:13.759,0:00:17.600
and it's usually a markdown file but if

0:00:16.400,0:00:20.720
you use an org

0:00:17.600,0:00:22.560
more an org mode file instead you can

0:00:20.720,0:00:24.400
take advantage of the great features

0:00:22.560,0:00:25.920
that org mode provides including

0:00:24.400,0:00:28.000
literate programming

0:00:25.920,0:00:31.840
which lets you generate your source code

0:00:28.000,0:00:34.719
and markdown documentation dynamically

0:00:31.840,0:00:37.120
I want to walk you through a little bit

0:00:34.719,0:00:39.440
of what this looks like

0:00:37.120,0:00:41.280
when you start a project especially if

0:00:39.440,0:00:43.320
if you use something like github you

0:00:41.280,0:00:47.039
begin with an automatically generated

0:00:43.320,0:00:50.239
readme.md file so just delete that

0:00:47.039,0:00:51.920
and instead create a readme.org file

0:00:50.239,0:00:54.800
starting with an empty org file like you

0:00:51.920,0:00:56.559
see here you can begin

0:00:54.800,0:00:59.440
by recording important information about

0:00:56.559,0:01:01.920
your project goals you can add diagrams

0:00:59.440,0:01:03.520
code snippets to-do lists time tracking

0:01:01.920,0:01:05.360
and much more

0:01:03.520,0:01:07.760
I'm going to drop in some documentation

0:01:05.360,0:01:10.840
that I r that I've written about

0:01:07.760,0:01:12.240
about my project here so you can kind of

0:01:10.840,0:01:15.280
see

0:01:12.240,0:01:17.119
what this would look like

0:01:15.280,0:01:20.320
so as you can see I have a title and a

0:01:17.119,0:01:23.840
description and then a sub section

0:01:20.320,0:01:25.520
as well as some code snippets

0:01:23.840,0:01:28.240
and you can see that orgmo does a great

0:01:25.520,0:01:31.280
job of formatting lists and

0:01:28.240,0:01:33.920
code sections diagrams and so forth

0:01:31.280,0:01:35.040
it's good or it's as good or better than

0:01:33.920,0:01:37.520
markdown

0:01:35.040,0:01:38.880
but when you use it in the Emacs you can

0:01:37.520,0:01:40.479
do a lot more

0:01:38.880,0:01:43.360
for example you can dynamically create

0:01:40.479,0:01:45.200
diagrams using graphviz

0:01:43.360,0:01:46.560
from a text description so if you go to

0:01:45.200,0:01:49.439
this source block here

0:01:46.560,0:01:51.439
and hit control c control c you'll see

0:01:49.439,0:01:55.439
that we generate a

0:01:51.439,0:01:59.200
diagram dynamically you can run

0:01:55.439,0:02:00.799
so you can run these code snippets in

0:01:59.200,0:02:03.040
place and get the results

0:02:00.799,0:02:06.640
to show up inside of your your file

0:02:03.040,0:02:06.640
which is a really powerful paradigm

0:02:08.000,0:02:11.520
but most important most importantly for

0:02:10.640,0:02:14.800
the

0:02:11.520,0:02:17.200
purposes my purpose is here

0:02:14.800,0:02:19.520
orgmo provides you the ability to do

0:02:17.200,0:02:21.440
literate programming

0:02:19.520,0:02:23.200
so take a quick look at this diagram

0:02:21.440,0:02:25.360
that I generated here

0:02:23.200,0:02:27.520
and gives you a quick overview of what I

0:02:25.360,0:02:31.200
mean by literate programming

0:02:27.520,0:02:33.920
and how I'm using it you can see

0:02:31.200,0:02:34.720
that we start with a readme.org file on

0:02:33.920,0:02:36.879
top

0:02:34.720,0:02:37.920
at this point we can do one of two

0:02:36.879,0:02:41.280
things

0:02:37.920,0:02:42.720
tangle or weave tangle is used to

0:02:41.280,0:02:46.319
describe the process of

0:02:42.720,0:02:47.599
generating source code while weave

0:02:46.319,0:02:49.840
is the process of generating

0:02:47.599,0:02:51.920
documentation these are terms that

0:02:49.840,0:02:53.840
donald knuth used

0:02:51.920,0:02:55.519
and he's the one that came up with the

0:02:53.840,0:02:59.920
idea of literate programming

0:02:55.519,0:03:01.519
in the early 1980s

0:02:59.920,0:03:04.480
but this is really all that there is to

0:03:01.519,0:03:06.400
it you just

0:03:04.480,0:03:07.840
who are simply using literate illiterate

0:03:06.400,0:03:10.319
source file

0:03:07.840,0:03:11.680
in this case the readme.org to generate

0:03:10.319,0:03:15.680
the rest of the project

0:03:11.680,0:03:15.680
the rest of the project files basically

0:03:17.120,0:03:22.640
so let's dig in to the details of how

0:03:20.959,0:03:24.560
this works

0:03:22.640,0:03:26.159
and I hope you hopefully you'll see how

0:03:24.560,0:03:28.959
cool this is

0:03:26.159,0:03:31.120
so returning to the file here let's

0:03:28.959,0:03:32.080
assume we have enough documentation now

0:03:31.120,0:03:34.159
that we want to get started

0:03:32.080,0:03:35.519
coding so maybe we'll just start with

0:03:34.159,0:03:38.159
like a hello world

0:03:35.519,0:03:41.519
app just so we can make sure that our

0:03:38.159,0:03:47.120
environment is set up correctly

0:03:41.519,0:03:49.519
so let's get started with a code block

0:03:47.120,0:03:50.319
so I created a little snippet to help me

0:03:49.519,0:03:52.239
add

0:03:50.319,0:03:53.599
a source block for literate programming

0:03:52.239,0:03:56.959
quickly

0:03:53.599,0:03:58.799
and there's not much to it

0:03:56.959,0:04:01.599
but there is some important annotations

0:03:58.799,0:04:04.080
here so there's

0:04:01.599,0:04:05.200
excuse me there's a there's a property

0:04:04.080,0:04:09.360
called tangle

0:04:05.200,0:04:13.280
and that takes a value of a file name

0:04:09.360,0:04:16.560
and then there's also a no web property

0:04:13.280,0:04:16.560
called no export

0:04:18.880,0:04:22.000
and basically

0:04:23.759,0:04:28.639
basically the no export will explain

0:04:26.800,0:04:32.080
that a little bit

0:04:28.639,0:04:33.919
more later um it has has to do with how

0:04:32.080,0:04:37.600
the tangling

0:04:33.919,0:04:39.280
is uh done in the tangle step versus the

0:04:37.600,0:04:41.199
weave step and I'll explain that a

0:04:39.280,0:04:45.199
little bit more but the tangle

0:04:41.199,0:04:48.320
field just simply tells tells uh

0:04:45.199,0:04:50.320
Emacs where it needs to generate the

0:04:48.320,0:04:53.280
main.go file and where it needs to put

0:04:50.320,0:04:53.280
it on the file system

0:04:55.360,0:04:59.040
uh you'll you'll notice that we we're

0:04:57.680,0:05:01.440
going to use go

0:04:59.040,0:05:02.160
that's just the language that I've been

0:05:01.440,0:05:05.360
using

0:05:02.160,0:05:07.360
the most lately uh but

0:05:05.360,0:05:08.400
this programming strategy is language

0:05:07.360,0:05:12.080
agnostic

0:05:08.400,0:05:14.720
you could use any language or any mix

0:05:12.080,0:05:16.560
of languages you could create some files

0:05:14.720,0:05:19.520
in python some files and go

0:05:16.560,0:05:21.520
some files in in lisp or whatever you

0:05:19.520,0:05:24.720
want

0:05:21.520,0:05:28.000
and so but let's

0:05:24.720,0:05:29.440
uh let's create just a little hello

0:05:28.000,0:05:32.320
world

0:05:29.440,0:05:33.520
let's use another snippet here to

0:05:32.320,0:05:36.560
generate

0:05:33.520,0:05:39.840
the basics of a go program

0:05:36.560,0:05:39.840
so I'm just going to print

0:05:40.240,0:05:42.960
hello world

0:05:44.960,0:05:48.240
so that's and then

0:05:48.560,0:05:55.280
let's make it a section in our

0:05:52.320,0:05:56.400
file so now you can see we've got this

0:05:55.280,0:05:59.600
snippet

0:05:56.400,0:06:01.600
um when you have a source block in

0:05:59.600,0:06:02.880
inside of org mode you can easily pop

0:06:01.600,0:06:04.960
into a

0:06:02.880,0:06:07.680
language specific buffer by typing

0:06:04.960,0:06:10.240
control c single quote

0:06:07.680,0:06:12.160
so you can see now I have a a go a

0:06:10.240,0:06:14.240
buffer that's in go mode

0:06:12.160,0:06:15.520
and gives you all the ability to edit

0:06:14.240,0:06:18.800
like you would

0:06:15.520,0:06:20.800
normally if you hit ctrl c

0:06:18.800,0:06:22.639
single quote again then it goes back and

0:06:20.800,0:06:25.280
any changes you

0:06:22.639,0:06:26.160
make would will be updated there but you

0:06:25.280,0:06:28.000
can do quite a bit

0:06:26.160,0:06:29.199
just inside of here too there's quite a

0:06:28.000,0:06:32.400
bit of

0:06:29.199,0:06:32.400
language specific

0:06:33.360,0:06:36.880
functionality just in place and so you

0:06:35.440,0:06:38.080
don't always have to go over to a

0:06:36.880,0:06:42.319
separate buffer

0:06:38.080,0:06:44.319
but it's a it's a nice option sometimes

0:06:42.319,0:06:46.720
but now that you have the code in here

0:06:44.319,0:06:48.560
you're going to want to run it

0:06:46.720,0:06:50.240
but right now it just lives here in this

0:06:48.560,0:06:52.160
documentation

0:06:50.240,0:06:53.840
so you need to get a copy of it into a

0:06:52.160,0:06:57.440
separate file

0:06:53.840,0:07:01.360
and that's the tangle process that you

0:06:57.440,0:07:03.360
you need to follow there so I'm gonna

0:07:01.360,0:07:05.280
drop in a little bit more doc a little

0:07:03.360,0:07:08.960
bit more

0:07:05.280,0:07:08.960
documentation really quick here

0:07:12.240,0:07:21.520
okay all right so just kind of as a

0:07:17.360,0:07:24.800
kind of as a side note I like to follow

0:07:21.520,0:07:26.639
this process uh whenever having whenever

0:07:24.800,0:07:28.880
I have an operation to perform I

0:07:26.639,0:07:31.680
I'd like to document it here with a

0:07:28.880,0:07:33.280
snippet that can be executed in line

0:07:31.680,0:07:34.639
then I don't have to leave org mode and

0:07:33.280,0:07:36.800
I don't have to try to remember what I

0:07:34.639,0:07:38.960
did later so instead of just

0:07:36.800,0:07:40.319
trying to do an operation the first time

0:07:38.960,0:07:41.680
I do something I take the

0:07:40.319,0:07:43.440
take the time to figure out what it is

0:07:41.680,0:07:44.879
and document it and so then it's

0:07:43.440,0:07:48.400
recorded

0:07:44.879,0:07:49.120
and so here we find that to do a tangle

0:07:48.400,0:07:51.680
operation

0:07:49.120,0:07:52.560
you run the command or babel tangled

0:07:51.680,0:07:55.840
which is a

0:07:52.560,0:07:59.199
e-list command so if you hit ctrl c

0:07:55.840,0:08:00.080
ctrl c to run it in place you get the

0:07:59.199,0:08:02.720
result

0:08:00.080,0:08:03.759
of main dot go which basically is

0:08:02.720,0:08:07.680
telling us that

0:08:03.759,0:08:11.039
we've tangled one file called main.go

0:08:07.680,0:08:14.000
and you can see that that's true

0:08:11.039,0:08:14.400
if you go to the file system and you

0:08:14.000,0:08:17.840
look

0:08:14.400,0:08:20.960
so now in uh in our demo directory

0:08:17.840,0:08:22.479
we have a readme.org we have that png

0:08:20.960,0:08:23.440
that we generated but we also have a

0:08:22.479,0:08:26.080
main.go

0:08:23.440,0:08:27.759
and if you if you visit that file you'll

0:08:26.080,0:08:29.280
see that it's just the source code that

0:08:27.759,0:08:31.039
was in our documentation which is

0:08:29.280,0:08:32.880
exactly what we expected and what we

0:08:31.039,0:08:36.000
wanted so that's good

0:08:32.880,0:08:36.000
so if we return to

0:08:36.560,0:08:39.919
to where we are at

0:08:41.120,0:08:44.640
now we're we're at the point where we

0:08:42.959,0:08:45.760
have a file on the file system so now we

0:08:44.640,0:08:48.959
need

0:08:45.760,0:08:53.600
um now we need to build it and to

0:08:48.959,0:08:57.040
run it so let's follow the same

0:08:53.600,0:08:58.720
philosophy where let's document

0:08:57.040,0:09:00.160
these operations that we're going to

0:08:58.720,0:09:03.920
perform

0:09:00.160,0:09:03.920
so I'm dropping in a

0:09:04.560,0:09:11.200
a build instruction section and a run

0:09:07.839,0:09:11.200
instruction section

0:09:13.360,0:09:17.839
so as you can see here we have a little

0:09:15.279,0:09:20.000
a bash source block

0:09:17.839,0:09:22.000
and another batch source block this one

0:09:20.000,0:09:25.440
compiles the go build command is what

0:09:22.000,0:09:26.880
compiles a file and then

0:09:25.440,0:09:29.519
the file that gets generated should be

0:09:26.880,0:09:29.519
called demo

0:09:30.080,0:09:34.000
and uh so we just run it here so if if I

0:09:32.959,0:09:37.839
type control c

0:09:34.000,0:09:40.640
control c we get an empty results block

0:09:37.839,0:09:41.360
when you compile things no news is good

0:09:40.640,0:09:44.399
news

0:09:41.360,0:09:46.560
so it means there's no errors so

0:09:44.399,0:09:48.000
presumably we've created an executable

0:09:46.560,0:09:51.440
that's called demo

0:09:48.000,0:09:54.560
so let's uh

0:09:51.440,0:09:57.519
let's look again at the file system and

0:09:54.560,0:09:57.519
regenerate

0:10:02.480,0:10:07.200
yep and what we have here is a demo

0:10:05.760,0:10:07.760
executable which is exactly what we

0:10:07.200,0:10:12.079
wanted

0:10:07.760,0:10:14.160
so let's go back

0:10:12.079,0:10:16.079
so now we should be able to run it so

0:10:14.160,0:10:20.320
ctrl c ctrl c

0:10:16.079,0:10:20.320
and we get hello world as a result

0:10:20.399,0:10:26.560
which was exactly what we were expecting

0:10:23.440,0:10:30.240
so that's already pretty cool

0:10:26.560,0:10:30.240
you can you can do that much

0:10:30.839,0:10:34.560
um but

0:10:33.040,0:10:37.839
that's really just kind of the tip of

0:10:34.560,0:10:41.040
the iceberg to uh to really

0:10:37.839,0:10:43.440
kind of um

0:10:41.040,0:10:46.160
use the more impressive features of

0:10:43.440,0:10:49.519
literate programming we need to uh

0:10:46.160,0:10:49.519
we need to do a little bit more

0:10:49.920,0:10:55.519
so or at least

0:10:53.200,0:10:56.480
at least really to get the full benefit

0:10:55.519,0:10:59.120
of it then

0:10:56.480,0:10:59.120
we need to do

0:10:59.600,0:11:06.320
add some sections that will cause uh

0:11:02.959,0:11:06.720
Emacs to have to to tangle or assemble

0:11:06.320,0:11:09.760
this

0:11:06.720,0:11:13.120
this file from different pieces so

0:11:09.760,0:11:16.720
imagine that we wanted to take this file

0:11:13.120,0:11:19.120
and maybe kind of templatize it

0:11:16.720,0:11:21.279
so using literature programming syntax

0:11:19.120,0:11:24.399
this angle bracket syntax

0:11:21.279,0:11:29.360
let's say that we want to create an in

0:11:24.399,0:11:32.399
imports section

0:11:29.360,0:11:35.040
in a functions section

0:11:32.399,0:11:36.240
and then maybe just a main section and

0:11:35.040,0:11:37.920
we'll get rid of this

0:11:36.240,0:11:39.760
so now you see we've created something

0:11:37.920,0:11:42.000
that looks a little bit like a

0:11:39.760,0:11:42.880
like a template or a scaffolding or

0:11:42.000,0:11:46.000
outline

0:11:42.880,0:11:48.399
for what what our file is going to be it

0:11:46.000,0:11:50.800
looks a little bit like pseudocode

0:11:48.399,0:11:52.399
and what we're going to have literate

0:11:50.800,0:11:54.800
programming do

0:11:52.399,0:11:56.639
is dynamically insert those things into

0:11:54.800,0:12:00.079
those slots

0:11:56.639,0:12:03.200
so the first thing we need to do

0:12:00.079,0:12:08.079
is so let's create a section

0:12:03.200,0:12:09.519
maybe called say hello so we want

0:12:08.079,0:12:12.720
we want to add some functionality that

0:12:09.519,0:12:15.680
makes our program say hello

0:12:12.720,0:12:17.600
so using a different snippet that I have

0:12:15.680,0:12:20.800
for creating something

0:12:17.600,0:12:24.079
that I call like a literate section

0:12:20.800,0:12:26.000
um basically we create a

0:12:24.079,0:12:27.839
another source block that's almost the

0:12:26.000,0:12:31.040
same as the one for the file but it's

0:12:27.839,0:12:31.680
it just has a few differences so say we

0:12:31.040,0:12:34.160
want to

0:12:31.680,0:12:36.639
drop code into the import section and we

0:12:34.160,0:12:39.120
want it to be in go

0:12:36.639,0:12:40.720
here we use the same noed no web no

0:12:39.120,0:12:43.200
export syntax

0:12:40.720,0:12:44.560
but then we've added this no web refs

0:12:43.200,0:12:48.240
imports

0:12:44.560,0:12:51.120
and this ties that slot

0:12:48.240,0:12:53.760
basically to this reference it tells

0:12:51.120,0:12:56.880
Emacs that when you tangle

0:12:53.760,0:12:58.240
we want to stick whatever's in here in

0:12:56.880,0:13:02.079
that spot

0:12:58.240,0:13:03.279
so you skip the tangle file name section

0:13:02.079,0:13:04.240
because you're not actually creating a

0:13:03.279,0:13:06.160
file name you're

0:13:04.240,0:13:07.680
you're putting information into an

0:13:06.160,0:13:10.720
existing file

0:13:07.680,0:13:13.680
so here we would just add the fmt

0:13:10.720,0:13:13.680
for the imports

0:13:14.399,0:13:22.240
so let's add another section for uh

0:13:18.839,0:13:25.519
functions and let's create a

0:13:22.240,0:13:30.240
let's just create a function called

0:13:25.519,0:13:32.839
say hello that

0:13:30.240,0:13:34.000
doesn't have any arguments no return

0:13:32.839,0:13:35.760
types

0:13:34.000,0:13:37.440
all it does is kind of pretty much the

0:13:35.760,0:13:39.199
same thing as we did before

0:13:37.440,0:13:41.360
just print something but let's just say

0:13:39.199,0:13:45.760
hello

0:13:41.360,0:13:49.519
Emacs comp this time

0:13:45.760,0:13:51.040
okay so now we have a function and now

0:13:49.519,0:13:52.720
the function won't do anything unless we

0:13:51.040,0:13:56.000
invoke it so let's do

0:13:52.720,0:13:59.920
one last literate section

0:13:56.000,0:14:03.519
called main make that go

0:13:59.920,0:14:06.399
source block and then let's

0:14:03.519,0:14:06.399
just invoke

0:14:06.560,0:14:13.360
that that function

0:14:10.320,0:14:15.600
so now you can see that we've got

0:14:13.360,0:14:17.199
our scaffolding scaffolding kind of

0:14:15.600,0:14:20.079
outline and then we have

0:14:17.199,0:14:21.360
the sections that we want to get tangled

0:14:20.079,0:14:25.440
or inserted

0:14:21.360,0:14:27.199
so I I've kind of used this syntax

0:14:25.440,0:14:28.560
it's it's kind of borrowed from

0:14:27.199,0:14:30.320
literature programming a little bit with

0:14:28.560,0:14:32.480
a plus equals so really it's just saying

0:14:30.320,0:14:35.760
that I want to append

0:14:32.480,0:14:37.600
this item into the import section so

0:14:35.760,0:14:39.839
it's really just to make a little bit

0:14:37.600,0:14:41.519
more clear what's going on

0:14:39.839,0:14:43.519
when you generate documentation you

0:14:41.519,0:14:46.160
won't see these

0:14:43.519,0:14:49.360
these these particular property

0:14:46.160,0:14:51.440
annotations and so you won't know

0:14:49.360,0:14:53.839
immediately that this section goes in

0:14:51.440,0:14:55.440
the imports area and so I usually put

0:14:53.839,0:14:57.760
a little bit of documentation on top

0:14:55.440,0:15:01.120
there so that it's easy to see

0:14:57.760,0:15:03.040
and you would probably if this was very

0:15:01.120,0:15:06.399
complicated you'd put some

0:15:03.040,0:15:07.360
documentation above to explain what you

0:15:06.399,0:15:10.320
were doing

0:15:07.360,0:15:10.320
maybe right here

0:15:11.519,0:15:15.040
you could you could picture yourself

0:15:13.279,0:15:17.440
maybe explaining

0:15:15.040,0:15:18.079
a complicated algorithm or something up

0:15:17.440,0:15:21.120
here

0:15:18.079,0:15:22.959
and having a nice way to document it

0:15:21.120,0:15:25.600
so now that we've got that here in the

0:15:22.959,0:15:27.040
documentation we need to figure out

0:15:25.600,0:15:29.920
we need to make sure that it's going to

0:15:27.040,0:15:33.519
tangle properly so your best friend

0:15:29.920,0:15:35.680
at this point is is uh

0:15:33.519,0:15:38.240
is a keyboard shortcut that lets you

0:15:35.680,0:15:38.959
preview the tangled operation so if you

0:15:38.240,0:15:42.560
say control

0:15:38.959,0:15:45.120
c control v control v

0:15:42.560,0:15:46.480
it will create a new buffer with the

0:15:45.120,0:15:49.360
tangled

0:15:46.480,0:15:50.639
contents and so you can see here that

0:15:49.360,0:15:53.199
the fmt

0:15:50.639,0:15:54.720
import went to the right place that

0:15:53.199,0:15:56.160
function went to the right place the

0:15:54.720,0:15:58.480
function invocation went to the right

0:15:56.160,0:16:01.279
place and so we're feeling good

0:15:58.480,0:16:02.800
you can nest these things many layers

0:16:01.279,0:16:04.800
deep

0:16:02.800,0:16:07.199
actually so like if you came into the

0:16:04.800,0:16:10.160
say hello function you could add

0:16:07.199,0:16:10.160
more sections

0:16:10.560,0:16:13.759
you know and it gets and it'll go

0:16:12.160,0:16:15.680
through and it'll

0:16:13.759,0:16:16.959
keep track of all that and tangle it for

0:16:15.680,0:16:18.320
you so you really get a lot of freedom

0:16:16.959,0:16:19.600
and flexibility for how you want to

0:16:18.320,0:16:22.320
document things

0:16:19.600,0:16:25.839
by doing this so now that we've

0:16:22.320,0:16:28.639
previewed it and we feel good about it

0:16:25.839,0:16:31.440
we need to uh we need to tangle so we

0:16:28.639,0:16:34.480
get the file on the file system

0:16:31.440,0:16:37.199
so ctrl c ctrl c and

0:16:34.480,0:16:37.920
get just main.go comes back again

0:16:37.199,0:16:40.959
control c

0:16:37.920,0:16:43.839
control c and no errors come back

0:16:40.959,0:16:45.600
and then if we did this right when we

0:16:43.839,0:16:47.199
when we run this we should get hello

0:16:45.600,0:16:51.199
Emacs comp so ctrl c

0:16:47.199,0:16:54.800
ctrl c hello Emacs comp

0:16:51.199,0:16:57.120
so I uh

0:16:54.800,0:16:58.240
I think that's pretty pretty cool

0:16:57.120,0:17:00.160
actually so we've got

0:16:58.240,0:17:02.399
kind of the breadcrumbs of the process

0:17:00.160,0:17:05.520
we've gone through to get to this point

0:17:02.399,0:17:08.000
this initial this initial

0:17:05.520,0:17:09.919
document that has some tangling in it we

0:17:08.000,0:17:12.799
have documentation for how to tangle

0:17:09.919,0:17:14.079
how to build how to run it's we've

0:17:12.799,0:17:17.760
really built a nice

0:17:14.079,0:17:20.160
foundation for

0:17:17.760,0:17:21.439
moving forward on our project and a nice

0:17:20.160,0:17:23.280
way of breaking things out and

0:17:21.439,0:17:27.120
documenting further

0:17:23.280,0:17:30.559
the last piece that we need to

0:17:27.120,0:17:34.799
take care of is the weave that I

0:17:30.559,0:17:38.640
that's I showed you in the diagram above

0:17:34.799,0:17:41.760
so one more time we'll drop in

0:17:38.640,0:17:42.400
some documentation so this time on how

0:17:41.760,0:17:44.400
to weave

0:17:42.400,0:17:47.520
so it's really just an export function

0:17:44.400,0:17:49.280
it's not there's not a separate weave

0:17:47.520,0:17:50.640
command going on here we're just going

0:17:49.280,0:17:52.799
to export

0:17:50.640,0:17:55.200
what we've got here into a markdown

0:17:52.799,0:17:57.440
format so we're using org

0:17:55.200,0:17:58.880
gfm export to markdown which is the

0:17:57.440,0:18:02.160
github style

0:17:58.880,0:18:05.440
markdown you can use the other just

0:18:02.160,0:18:10.320
more standard type as well so hit ctrl c

0:18:05.440,0:18:15.280
ctrl c now you see we've got a readme

0:18:10.320,0:18:17.440
file and if you look

0:18:15.280,0:18:19.120
in the file system we've got that right

0:18:17.440,0:18:23.120
there and so

0:18:19.120,0:18:29.840
if you go to something like ghostwriter

0:18:23.120,0:18:29.840
and open that file

0:18:31.679,0:18:35.520
now you can see that it's generated some

0:18:34.559,0:18:38.320
documentation

0:18:35.520,0:18:39.679
it puts a index at top at the top I

0:18:38.320,0:18:42.000
usually just

0:18:39.679,0:18:43.679
I usually turn that off it's easy to do

0:18:42.000,0:18:44.559
that by putting a property at the top of

0:18:43.679,0:18:46.880
your

0:18:44.559,0:18:48.559
your org file but some people like to

0:18:46.880,0:18:50.799
have an index

0:18:48.559,0:18:52.160
but here you can see that it's generated

0:18:50.799,0:18:55.200
pretty nicely and

0:18:52.160,0:18:56.880
formatted snippets well

0:18:55.200,0:18:58.240
put the diagram in there and then it's

0:18:56.880,0:19:01.039
preserved

0:18:58.240,0:19:02.799
it's preserved this literate programming

0:19:01.039,0:19:04.960
syntax

0:19:02.799,0:19:06.480
which is important because that's how we

0:19:04.960,0:19:07.200
want to view the documentation that's

0:19:06.480,0:19:10.559
what the no

0:19:07.200,0:19:13.360
exports um

0:19:10.559,0:19:14.000
property was was trying to maintain so

0:19:13.360,0:19:16.080
that

0:19:14.000,0:19:18.400
no exports means when you export do not

0:19:16.080,0:19:20.559
try to tangle so that's

0:19:18.400,0:19:22.240
hopefully that makes more sense now but

0:19:20.559,0:19:26.080
now you can see all the documentation

0:19:22.240,0:19:29.919
and I think it demonstrates a

0:19:26.080,0:19:33.520
pretty useful feature that's inside of

0:19:29.919,0:19:35.039
Emacs and and hopefully

0:19:33.520,0:19:39.840
hopefully you'll have as much fun using

0:19:35.039,0:19:39.840
that as I have

0:19:39.919,0:19:43.600
so thanks