]> git.lyx.org Git - wiki-uploads.git/blob - noweb/noweb-lyx.lyx
Update copies following NeedCProtect documentation
[wiki-uploads.git] / noweb / noweb-lyx.lyx
1 #LyX 1.6.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 345
3 \begin_document
4 \begin_header
5 \textclass literate-article
6 \begin_preamble
7 \usepackage{noweb}
8 \end_preamble
9 \use_default_options true
10 \begin_modules
11 logicalmkup
12 \end_modules
13 \language english
14 \inputencoding auto
15 \font_roman default
16 \font_sans default
17 \font_typewriter default
18 \font_default_family default
19 \font_sc false
20 \font_osf false
21 \font_sf_scale 100
22 \font_tt_scale 100
23
24 \graphics default
25 \paperfontsize default
26 \spacing single
27 \use_hyperref false
28 \papersize a4paper
29 \use_geometry false
30 \use_amsmath 1
31 \use_esint 1
32 \cite_engine basic
33 \use_bibtopic false
34 \paperorientation portrait
35 \secnumdepth 3
36 \tocdepth 3
37 \paragraph_separation skip
38 \defskip medskip
39 \quotes_language english
40 \papercolumns 1
41 \papersides 2
42 \paperpagestyle fancy
43 \tracking_changes false
44 \output_changes false
45 \author "" 
46 \author "" 
47 \end_header
48
49 \begin_body
50
51 \begin_layout Title
52 Using Lyx and Noweb
53 \end_layout
54
55 \begin_layout Author
56 Sam Liddicott <sam@liddicott.com>
57 \end_layout
58
59 \begin_layout Date
60 9 July 2009
61 \end_layout
62
63 \begin_layout Standard
64 \begin_inset CommandInset toc
65 LatexCommand tableofcontents
66
67 \end_inset
68
69
70 \end_layout
71
72 \begin_layout Section*
73 Introduction
74 \end_layout
75
76 \begin_layout aphorism
77 noweb 2.11b and lyx 2.6.2 nearly play together nicely.
78 \end_layout
79
80 \begin_layout Standard
81 This document talks about finishing the job.
82  To run these examples you will need Lyx 2.6.2 and noweb 2.11b, and a copy
83  of notanglefix in the same folder as this document noweb-lyx.lyx
84 \end_layout
85
86 \begin_layout Part
87 \begin_inset CommandInset label
88 LatexCommand label
89 name "cha:noweb"
90
91 \end_inset
92
93 Fixing Lyx and Noweb
94 \end_layout
95
96 \begin_layout Standard
97 According to the Extended Lyx Features 
98 \begin_inset CommandInset citation
99 LatexCommand cite
100 key "lyx-noweb"
101
102 \end_inset
103
104  which you should read, we use notangle to derive the 
105 \emph on
106 source files
107 \emph default
108 , and Lyx automatically uses noweave to generate the 
109 \emph on
110 output document
111 \emph default
112 .
113 \end_layout
114
115 \begin_layout Standard
116 There are, sadly, some serious problems with noweb and Lyx.
117 \end_layout
118
119 \begin_layout Section
120 <
121 \begin_inset space \hspace*{}
122 \length 0in
123 \end_inset
124
125 < in document chunks
126 \end_layout
127
128 \begin_layout Standard
129 notangle complains when a double chevron <
130 \begin_inset space \hspace*{}
131 \length 0in
132 \end_inset
133
134 < occurs in non code chunk portions of the input document.
135  These are supposed to be escaped with @, requiring me to enter @
136 \begin_inset space \hspace*{}
137 \length 0in
138 \end_inset
139
140 <
141 \begin_inset space \hspace*{}
142 \length 0in
143 \end_inset
144
145 <, however the @ is not being removed by noweave when it generates the output
146  document.
147  
148 \end_layout
149
150 \begin_layout Standard
151 To solve this problem and have more normal looking lyx at edit time, I tried
152  inserting a zero-width space between the chevrons, looking somewhat like
153  this in Lyx: <␣<, but being represented as <
154 \backslash
155 hspace*{0in}< internally.
156 \end_layout
157
158 \begin_layout Standard
159 Sadly this does not work in the Lyx-Code environment, where the zero width
160  space is presented a literal space character, and so < < is emitted in
161  the document with a space between the chevrons.
162 \end_layout
163
164 \begin_layout Standard
165 This sed applied 
166 \emph on
167 after
168 \emph default
169  noweave attempts to remove the extra @, detecting the 
170 \backslash
171 textcompwordmark{} that noweave inserts between the chevrons:
172 \end_layout
173
174 \begin_layout Scrap
175 <<fix-noweave-at>>=
176 \begin_inset Newline newline
177 \end_inset
178
179 sed 's/@<
180 \backslash
181
182 \backslash
183 textcompwordmark{}</<
184 \backslash
185
186 \backslash
187 textcompwordmark{}</g;'
188 \begin_inset Newline newline
189 \end_inset
190
191 @
192 \end_layout
193
194 \begin_layout Standard
195 When <
196 \begin_inset space \hspace*{}
197 \length 0in
198 \end_inset
199
200 <chunk-name>
201 \begin_inset space \hspace*{}
202 \length 0in
203 \end_inset
204
205 > is used in the Lyx-Code environment to demonstrate a code chunk as in
206  section 
207 \begin_inset CommandInset ref
208 LatexCommand ref
209 reference "lyx:example-scrap"
210
211 \end_inset
212
213 , no special behaviour is needed -- in fact a real noweb code chunk is being
214  declared, and so as long as the chunk name does not conflict it is acceptable.
215  Although notangle sees a real code chunk, noweave does not -- no doubt
216  because noweave only detects chunks in a Lyx Scrap.
217  In any case the sed on the previous line permits @
218 \begin_inset space \hspace*{}
219 \length 0in
220 \end_inset
221
222 <
223 \begin_inset space \hspace*{}
224 \length 0in
225 \end_inset
226
227 < to be used in the Lyx-Code environment.
228 \end_layout
229
230 \begin_layout Section
231 <
232 \begin_inset space \hspace*{}
233 \length 0in
234 \end_inset
235
236 < in code chunks
237 \end_layout
238
239 \begin_layout Standard
240 When a double chrevron occurs within a code chunk it us usually must also
241  be escaped with @, but it is shown in the generated document as a double
242  chevron 
243 \begin_inset ERT
244 status open
245
246 \begin_layout Plain Layout
247
248 @<<, or >>
249 \end_layout
250
251 \end_inset
252
253 .
254  If it is not escaped with @, then it shows in the document as the angle
255  bracket ⟨.
256  
257 \end_layout
258
259 \begin_layout Standard
260 This seems to be a noweave bug which should replace non-special <
261 \begin_inset space \hspace*{}
262 \length 0in
263 \end_inset
264
265 < in noweb chunks with <
266 \backslash
267 textcompwordmark<
268 \end_layout
269
270 \begin_layout Standard
271 The following sed must run 
272 \emph on
273 after
274 \emph default
275  noweave and prevents <
276 \begin_inset space \hspace*{}
277 \length 0in
278 \end_inset
279
280 < and >
281 \begin_inset space \hspace*{}
282 \length 0in
283 \end_inset
284
285 > from being interpreted as 
286 \begin_inset ERT
287 status open
288
289 \begin_layout Plain Layout
290
291 @<<, or >>
292 \end_layout
293
294 \end_inset
295
296 .
297 \end_layout
298
299 \begin_layout Standard
300 First we detect when begincode environment starts or ends by coping those
301  lines to the hold space with the sed h command.
302 \end_layout
303
304 \begin_layout Scrap
305 <<fix-noweave-chevron>>=
306 \begin_inset Newline newline
307 \end_inset
308
309 sed '/[^
310 \backslash
311
312 \backslash
313 ]
314 \backslash
315
316 \backslash
317 nwbegincode/h;
318 \begin_inset Newline newline
319 \end_inset
320
321      /[^
322 \backslash
323
324 \backslash
325 ]
326 \backslash
327
328 \backslash
329 nwendcode/h;
330 \begin_inset Newline newline
331 \end_inset
332
333 @
334 \end_layout
335
336 \begin_layout Standard
337 The [^
338 \backslash
339
340 \backslash
341 ] is required to prevent the literal 
342 \backslash
343 nwendcode in this code chunk from triggering the nwbegincode and nwendcode
344  detectors when this document is processed.
345  It doesn't work by merely avoiding nwbegincode preceded by two slashes
346  
347 \emph on
348 because
349 \emph default
350  it appears that way in this code chunk.
351 \end_layout
352
353 \begin_layout Standard
354 It is because noweave is escaping back-slashes with another back-slash anyway
355  so a double backslash signifies a literal document backslash, and it is
356  these that we wish to avoid.
357  In fact the noweave output of this chunk looks like this now: [^
358 \backslash
359
360 \backslash
361
362 \backslash
363
364 \backslash
365 ]
366 \backslash
367
368 \backslash
369
370 \backslash
371
372 \backslash
373 nwbegincode?
374 \end_layout
375
376 \begin_layout Standard
377 Then, for lines that contain <
378 \begin_inset space \hspace*{}
379 \length 0in
380 \end_inset
381
382 < or >
383 \begin_inset space \hspace*{}
384 \length 0in
385 \end_inset
386
387 > we check that the line in the hold space contains 
388 \emph on
389 begincode
390 \emph default
391 , by using the sed x command to exchange the current line in pattern space
392  with the saved line in hold space and then doing a match.
393  
394 \end_layout
395
396 \begin_layout Standard
397 If there is a match, then we know that we are in the begincode environment,
398  and we do a replace to insert 
399 \backslash
400
401 \backslash
402 textcompwordmark between them.
403  The sed /g makes sure we do this for all occurances on the line.
404 \end_layout
405
406 \begin_layout Scrap
407 <<fix-noweave-chevron>>=
408 \begin_inset Newline newline
409 \end_inset
410
411      /<</{x;/begincode/{x;s/<</<
412 \backslash
413
414 \backslash
415 textcompwordmark</g;x};x};
416 \begin_inset Newline newline
417 \end_inset
418
419      />>/{x;/begincode/{x;s/>>/>
420 \backslash
421
422 \backslash
423 textcompwordmark>/g;x};x}'
424 \begin_inset Newline newline
425 \end_inset
426
427 @
428 \end_layout
429
430 \begin_layout Section
431 Underscore in chunk names
432 \end_layout
433
434 \begin_layout Standard
435 Underscores cannot be expressed in the fragment name; e.g.
436 \end_layout
437
438 \begin_layout LyX-Code
439 <<file_name.h>>=
440 \begin_inset Newline newline
441 \end_inset
442
443 @
444 \end_layout
445
446 \begin_layout Standard
447 otherwise the document refuses to generate.
448  I believe this is a noweave bug, it should escape any _ in the <
449 \begin_inset space \hspace*{}
450 \length 0in
451 \end_inset
452
453 < chunk >
454 \begin_inset space \hspace*{}
455 \length 0in
456 \end_inset
457
458 > line with a 
459 \backslash
460 .
461 \end_layout
462
463 \begin_layout Standard
464 The following sed must be run 
465 \emph on
466 before
467 \emph default
468  noweave to fix this: 
469 \end_layout
470
471 \begin_layout Scrap
472 <<fix-noweave-underscore>>=
473 \begin_inset Newline newline
474 \end_inset
475
476 sed '/^<
477 \begin_inset space \hspace*{}
478 \length 0in
479 \end_inset
480
481 </s/_/
482 \backslash
483
484 \backslash
485 _/g'
486 \begin_inset Newline newline
487 \end_inset
488
489 @
490 \end_layout
491
492 \begin_layout Standard
493 This makes the noweave output conversion filter set in Tools\SpecialChar \menuseparator
494 Preferences\SpecialChar \menuseparator
495 File
496  Handling\SpecialChar \menuseparator
497 Converters\SpecialChar \menuseparator
498 NoWeb -> Latex something like this
499 \begin_inset Note Note
500 status open
501
502 \begin_layout Plain Layout
503 I would have used @<<fix-noweave-underscore>> but I wanted the entire code
504  to output in the document.
505  I wish there was a @<<>> variant that showed the included text in the output
506  document.
507 \end_layout
508
509 \end_inset
510
511 :
512 \end_layout
513
514 \begin_layout Scrap
515 <<fix-noweave>>=
516 \begin_inset Newline newline
517 \end_inset
518
519 sed '/^<</s/_/
520 \backslash
521
522 \backslash
523 _/g' $$i |
524 \begin_inset Newline newline
525 \end_inset
526
527 noweave -delay -index - |
528 \begin_inset Newline newline
529 \end_inset
530
531 sed 's/@<
532 \backslash
533
534 \backslash
535 textcompwordmark{}</<
536 \backslash
537
538 \backslash
539 textcompwordmark{}</g;' |
540 \begin_inset Newline newline
541 \end_inset
542
543 sed '/[^
544 \backslash
545
546 \backslash
547 ]
548 \backslash
549
550 \backslash
551 nwbegincode/h;
552 \begin_inset Newline newline
553 \end_inset
554
555      /[^
556 \backslash
557
558 \backslash
559 ]
560 \backslash
561
562 \backslash
563 nwendcode/h; 
564 \begin_inset Newline newline
565 \end_inset
566
567      /<</{x;/begincode/{x;s/<</<
568 \backslash
569
570 \backslash
571 textcompwordmark</g;x};x};
572 \begin_inset Newline newline
573 \end_inset
574
575      />>/{x;/begincode/{x;s/>>/>
576 \backslash
577
578 \backslash
579 textcompwordmark>/g;x};x}' > $$o
580 \begin_inset Newline newline
581 \end_inset
582
583 @
584 \end_layout
585
586 \begin_layout Section
587 \begin_inset CommandInset label
588 LatexCommand label
589 name "sub:notangle--L-breaks"
590
591 \end_inset
592
593 notangle -L breaks indentation
594 \end_layout
595
596 \begin_layout Standard
597 Normally we would generate the source using someting like:
598 \end_layout
599
600 \begin_layout LyX-Code
601 notangle -L'#line %L "%F"%N' -Rexample-print-loop noweb-lyx.lyx
602 \end_layout
603
604 \begin_layout Standard
605 Although -L'#line %L "%F"%N' is required to aid tracing compile errors back
606  to the lyx document, it also spoils the indentation of the C output.
607 \end_layout
608
609 \begin_layout Standard
610 Normally the indent before the chunk include is applied to each line of
611  the included chunk; e.g.
612 \end_layout
613
614 \begin_layout LyX-Code
615 \begin_inset CommandInset label
616 LatexCommand label
617 name "lyx:example-scrap"
618
619 \end_inset
620
621 @<<example-print>>=
622 \end_layout
623
624 \begin_layout LyX-Code
625      printf 
626 \begin_inset Quotes eld
627 \end_inset
628
629 Hello
630 \backslash
631 n
632 \begin_inset Quotes erd
633 \end_inset
634
635 ;
636 \end_layout
637
638 \begin_layout LyX-Code
639      @ 
640 \end_layout
641
642 \begin_layout LyX-Code
643  
644 \end_layout
645
646 \begin_layout LyX-Code
647 \begin_inset CommandInset label
648 LatexCommand label
649 name "lyx:example-print-loop"
650
651 \end_inset
652
653 @<<example-print-loop>>=
654 \end_layout
655
656 \begin_layout LyX-Code
657      int main() {
658 \end_layout
659
660 \begin_layout LyX-Code
661      ␣␣int a;
662 \end_layout
663
664 \begin_layout LyX-Code
665      ␣␣for(a=0; a<5; a++) {
666 \end_layout
667
668 \begin_layout LyX-Code
669      ␣␣␣␣@<<example-print>>
670 \end_layout
671
672 \begin_layout LyX-Code
673      ␣␣}
674 \end_layout
675
676 \begin_layout LyX-Code
677      }
678 \end_layout
679
680 \begin_layout LyX-Code
681      @ 
682 \end_layout
683
684 \begin_layout Standard
685 Would generate something like this if the -L argument were not used
686 \begin_inset Foot
687 status collapsed
688
689 \begin_layout Plain Layout
690 although the output looks only 
691 \emph on
692 somewhat
693 \emph default
694  like this on account of other notangle problems, see section 
695 \begin_inset CommandInset ref
696 LatexCommand vref
697 reference "sub:Generally-mangled-notangle"
698
699 \end_inset
700
701
702 \end_layout
703
704 \end_inset
705
706 :
707 \end_layout
708
709 \begin_layout LyX-Code
710 int main() {
711 \end_layout
712
713 \begin_layout LyX-Code
714 ␣␣int a;
715 \end_layout
716
717 \begin_layout LyX-Code
718 ␣␣for(a=0; a<5; a++) {
719 \end_layout
720
721 \begin_layout LyX-Code
722 ␣␣␣␣printf "Hello ";
723 \end_layout
724
725 \begin_layout LyX-Code
726 ␣␣␣␣printf 
727 \begin_inset Quotes eld
728 \end_inset
729
730 there
731 \backslash
732 n
733 \begin_inset Quotes erd
734 \end_inset
735
736 ;
737 \end_layout
738
739 \begin_layout LyX-Code
740 ␣␣}
741 \end_layout
742
743 \begin_layout LyX-Code
744 }
745 \end_layout
746
747 \begin_layout Standard
748 Here is an extract of the C it generates when the argument -L'#line %L "%F"%N'
749  is used:
750 \end_layout
751
752 \begin_layout LyX-Code
753 #line 509 "noweb-lyx.lyx"
754 \end_layout
755
756 \begin_layout LyX-Code
757 int main() {
758 \end_layout
759
760 \begin_layout LyX-Code
761 ␣␣int a;
762 \end_layout
763
764 \begin_layout LyX-Code
765 ␣␣for(a=0; a<5; a++) {
766 \end_layout
767
768 \begin_layout LyX-Code
769 ␣␣␣␣
770 \end_layout
771
772 \begin_layout LyX-Code
773 #line 491 "noweb-lyx.lyx"
774 \end_layout
775
776 \begin_layout LyX-Code
777 printf "Hello ";
778 \end_layout
779
780 \begin_layout LyX-Code
781 printf "there
782 \backslash
783 n";
784 \end_layout
785
786 \begin_layout LyX-Code
787 #line 525 "noweb-lyx.lyx"
788 \end_layout
789
790 \begin_layout LyX-Code
791 ␣␣}
792 \end_layout
793
794 \begin_layout LyX-Code
795 }
796 \end_layout
797
798 \begin_layout Standard
799 We see that the correct indent is emitted on the line before the #line statement
800 , but the rest of the block is not indented.
801  We must fix this by storing any non-newline white space before a line matching
802  /^#line/ and inserting it before each line.
803 \end_layout
804
805 \begin_layout Standard
806 We do this in section 
807 \begin_inset CommandInset ref
808 LatexCommand vref
809 reference "notanglefix-leading-space"
810
811 \end_inset
812
813
814 \end_layout
815
816 \begin_layout Section
817 \begin_inset CommandInset label
818 LatexCommand label
819 name "sub:Generally-mangled-notangle"
820
821 \end_inset
822
823 Generally mangled notangle output
824 \end_layout
825
826 \begin_layout Standard
827 There also is serious problem with either noweb or Lyx's Scrap handling.
828  For instance, when the code block 
829 \emph on
830 example-print-loop
831 \emph default
832  (see section 
833 \begin_inset CommandInset ref
834 LatexCommand ref
835 reference "lyx:example-print-loop"
836
837 \end_inset
838
839 ) is untangled we see mangled output like this:
840 \end_layout
841
842 \begin_layout LyX-Code
843
844 \backslash
845 begin_inset Newline newline
846 \end_layout
847
848 \begin_layout LyX-Code
849
850 \backslash
851 end_inset
852 \end_layout
853
854 \begin_layout LyX-Code
855
856 \end_layout
857
858 \begin_layout LyX-Code
859 int main() {
860 \end_layout
861
862 \begin_layout LyX-Code
863
864 \backslash
865 begin_inset Newline newline
866 \end_layout
867
868 \begin_layout LyX-Code
869
870 \backslash
871 end_inset
872 \end_layout
873
874 \begin_layout LyX-Code
875
876 \end_layout
877
878 \begin_layout LyX-Code
879 ␣␣int a;
880 \end_layout
881
882 \begin_layout LyX-Code
883
884 \backslash
885 begin_inset Newline newline
886 \end_layout
887
888 \begin_layout LyX-Code
889
890 \backslash
891 end_inset
892 \end_layout
893
894 \begin_layout LyX-Code
895 ...
896 \end_layout
897
898 \begin_layout LyX-Code
899 ␣␣␣␣printf 
900 \end_layout
901
902 \begin_layout LyX-Code
903 ␣␣␣␣
904 \backslash
905 begin_inset "
906 \end_layout
907
908 \begin_layout LyX-Code
909 ␣␣␣␣
910 \backslash
911 end_inset
912 \end_layout
913
914 \begin_layout LyX-Code
915 ␣␣␣␣Hello
916 \end_layout
917
918 \begin_layout LyX-Code
919 ␣␣␣␣
920 \backslash
921 backslash
922 \end_layout
923
924 \begin_layout LyX-Code
925 ␣␣␣␣n
926 \end_layout
927
928 \begin_layout LyX-Code
929 ␣␣␣␣
930 \backslash
931 begin_inset "
932 \end_layout
933
934 \begin_layout LyX-Code
935 ␣␣␣␣
936 \backslash
937 end_inset
938 \end_layout
939
940 \begin_layout Standard
941 Line-breaks occur freely, and backslash characters come out as 
942 \backslash
943 backslash on a new line, sometimes with a blank line following.
944  In fact the output has not been properly un-lyx-ified.
945 \end_layout
946
947 \begin_layout Standard
948 An awk helper script 
949 \emph on
950 notanglefix
951 \emph default
952  is used to replace 
953 \backslash
954 backslash with an actual backslash and to remove newline characters altogether,
955  and instead insert newlines where 
956 \emph on
957
958 \backslash
959 begin_inset Newline newline
960 \emph default
961  occurs.
962  (I also note that the promised [[ ]] for quoting code doesn't work).
963 \end_layout
964
965 \begin_layout Standard
966 We call this 
967 \emph on
968 notanglefix
969 \emph default
970  because it fixes the output from notangle.
971 \end_layout
972
973 \begin_layout Standard
974 Note the space after #! which makes the first four characters #! /, and
975  aids BSD systems which use the first four characters of a file as the magic
976  number for script handling.
977 \end_layout
978
979 \begin_layout Scrap
980 <<notanglefix>>=
981 \begin_inset Newline newline
982 \end_inset
983
984 #! /usr/bin/awk -f
985 \begin_inset Newline newline
986 \end_inset
987
988 @
989 \end_layout
990
991 \begin_layout Standard
992 emit_buffer simply outputs the newline-less buffer of accumulated text.
993  AWK's print adds a newline on the end automatically.
994  The buffer is then cleared ready for more data.
995 \end_layout
996
997 \begin_layout Scrap
998 <<notanglefix>>=
999 \begin_inset Newline newline
1000 \end_inset
1001
1002 function emit_buffer() {
1003 \begin_inset Newline newline
1004 \end_inset
1005
1006   print indent buffer;
1007 \begin_inset Newline newline
1008 \end_inset
1009
1010   buffer = "";
1011 \begin_inset Newline newline
1012 \end_inset
1013
1014 }
1015 \begin_inset Newline newline
1016 \end_inset
1017
1018 @
1019 \end_layout
1020
1021 \begin_layout Standard
1022 The BEGIN block is used to initialize the buffer, although this isn't required
1023  by AWK.
1024  The indent is used to fixup indenting when the -L argument has been used
1025  for notangle as mentioned in section 
1026 \begin_inset CommandInset ref
1027 LatexCommand ref
1028 reference "sub:notangle--L-breaks"
1029
1030 \end_inset
1031
1032 .
1033 \end_layout
1034
1035 \begin_layout Scrap
1036 <<notanglefix>>=
1037 \begin_inset Newline newline
1038 \end_inset
1039
1040 BEGIN {
1041 \begin_inset Newline newline
1042 \end_inset
1043
1044   buffer = "";
1045 \begin_inset Newline newline
1046 \end_inset
1047
1048   indent = "";
1049 \begin_inset Newline newline
1050 \end_inset
1051
1052 }
1053 \begin_inset Newline newline
1054 \end_inset
1055
1056 @
1057 \end_layout
1058
1059 \begin_layout Standard
1060 As notanges -L output the indent once only before the #line, we need to
1061  store this indent when we see #line.
1062  We also match a digit after the token #line in order to avoid wrongly detecting
1063  files (like Makefile.inc in section 
1064 \begin_inset CommandInset ref
1065 LatexCommand ref
1066 reference "sub:Keeping-extracted-files"
1067
1068 \end_inset
1069
1070 ) which might specify -L'#line %L "%F"%N'
1071 \end_layout
1072
1073 \begin_layout Scrap
1074 <<notanglefix>>=
1075 \begin_inset Newline newline
1076 \end_inset
1077
1078 /^ *#line [0-9]/ {
1079 \begin_inset Newline newline
1080 \end_inset
1081
1082   indent = buffer;
1083 \begin_inset Newline newline
1084 \end_inset
1085
1086   buffer = "";
1087 \begin_inset Newline newline
1088 \end_inset
1089
1090 }
1091 \begin_inset Newline newline
1092 \end_inset
1093
1094 @
1095 \end_layout
1096
1097 \begin_layout Standard
1098 \begin_inset CommandInset label
1099 LatexCommand label
1100 name "notanglefix-leading-space"
1101
1102 \end_inset
1103
1104 We want to trim leading white-space on each line -- unless we haven't accumulate
1105 d any output yet.
1106  This permits us to preserve notangles indent at the start of each proper
1107  line, without caring when lyx starts a new line for things like 
1108 \backslash
1109 backslash.
1110  Because we preserve the first chunk of white space, the #line matching
1111  code is able to take this and store it when -L mode is used.
1112 \end_layout
1113
1114 \begin_layout Scrap
1115 <<notanglefix>>=
1116 \begin_inset Newline newline
1117 \end_inset
1118
1119 /^  */ {
1120 \begin_inset Newline newline
1121 \end_inset
1122
1123   if (length(buffer) > 0) gsub("^ *", "");
1124 \begin_inset Newline newline
1125 \end_inset
1126
1127 }
1128 \begin_inset Newline newline
1129 \end_inset
1130
1131 @
1132 \end_layout
1133
1134 \begin_layout Standard
1135 The inset 
1136 \begin_inset Quotes eld
1137 \end_inset
1138
1139 Newline newline
1140 \begin_inset Quotes erd
1141 \end_inset
1142
1143  was determined to be emitted by notangle everywhere ctrl+enter was used
1144  in the lyx Scrap style, so we use this pattern to emit the buffer (with
1145  a trailing newline).
1146  We avoid doing this on the first line of the document in order to prevent
1147  all generate files starting with a blank line.
1148  This would otherwise occur, because I press ctrl+enter after the 
1149 \emph on
1150 <
1151 \begin_inset space \hspace*{}
1152 \length 0in
1153 \end_inset
1154
1155 <chunk>
1156 \begin_inset space \hspace*{}
1157 \length 0in
1158 \end_inset
1159
1160 >=
1161 \emph default
1162  line before typing code in a code chunk in order to get a common indent
1163 \begin_inset Foot
1164 status collapsed
1165
1166 \begin_layout Plain Layout
1167 Sadly if the first line of a chunk includes another chunk then we still
1168  get blank lines at the top of the document.
1169  The fix is probably to remove any Newline insets immediately after the
1170  chunk starts.
1171 \end_layout
1172
1173 \end_inset
1174
1175 .
1176  
1177 \end_layout
1178
1179 \begin_layout Scrap
1180 <<notanglefix>>=
1181 \begin_inset Newline newline
1182 \end_inset
1183
1184 /
1185 \backslash
1186
1187 \backslash
1188 begin_inset Newline newline$/ {
1189 \begin_inset Newline newline
1190 \end_inset
1191
1192   if (NR > 1) emit_buffer();
1193 \begin_inset Newline newline
1194 \end_inset
1195
1196 }
1197 \begin_inset Newline newline
1198 \end_inset
1199
1200 @
1201 \end_layout
1202
1203 \begin_layout Standard
1204 A line containing only 
1205 \backslash
1206 backslash is emitted by lyx where an actual backslash was present in the
1207  chunk, so we convert this back into a literal backslash.
1208  No other special character treatment has been observed as yet.
1209 \end_layout
1210
1211 \begin_layout Scrap
1212 <<notanglefix>>=
1213 \begin_inset Newline newline
1214 \end_inset
1215
1216 /^ *
1217 \backslash
1218
1219 \backslash
1220 backslash/ {
1221 \begin_inset Newline newline
1222 \end_inset
1223
1224   buffer = buffer "
1225 \backslash
1226
1227 \backslash
1228 ";
1229 \begin_inset Newline newline
1230 \end_inset
1231
1232   $0 = "";
1233 \begin_inset Newline newline
1234 \end_inset
1235
1236 }
1237 \begin_inset Newline newline
1238 \end_inset
1239
1240 @
1241 \end_layout
1242
1243 \begin_layout Standard
1244 Other lines observed that contain sections with a backslash don't seem relevant
1245  to the Scrap and so are removed.
1246 \end_layout
1247
1248 \begin_layout Scrap
1249 <<notanglefix>>=
1250 \begin_inset Newline newline
1251 \end_inset
1252
1253 /
1254 \backslash
1255
1256 \backslash
1257 / {
1258 \begin_inset Newline newline
1259 \end_inset
1260
1261   gsub("
1262 \backslash
1263
1264 \backslash
1265
1266 \backslash
1267
1268 \backslash
1269 .*$", "");
1270 \begin_inset Newline newline
1271 \end_inset
1272
1273 }
1274 \begin_inset Newline newline
1275 \end_inset
1276
1277 @
1278 \end_layout
1279
1280 \begin_layout Standard
1281 The default action is to append the line to the buffer.
1282  In AWK (unlike PERL's $_) the trailing newline is not part of $0 so we
1283  don't need to explicitly strip the newline at the end of $0.
1284  This also means that blank lines in the input are ignored.
1285 \end_layout
1286
1287 \begin_layout Scrap
1288 <<notanglefix>>=
1289 \begin_inset Newline newline
1290 \end_inset
1291
1292 {
1293 \begin_inset Newline newline
1294 \end_inset
1295
1296   buffer = buffer $0;
1297 \begin_inset Newline newline
1298 \end_inset
1299
1300 }
1301 \begin_inset Newline newline
1302 \end_inset
1303
1304 @
1305 \end_layout
1306
1307 \begin_layout Standard
1308 At the end of the file we emit_buffer, but only if it is not empty.
1309  This stops a blank line being emitted at the end of the output file.
1310  It also means that if the final line of the Lyx Scrap was didn't have a
1311  newline, that a newline will still be appended by emit_buffer.
1312  This is not considered a bug.
1313 \end_layout
1314
1315 \begin_layout Scrap
1316 <<notanglefix>>=
1317 \begin_inset Newline newline
1318 \end_inset
1319
1320 END {
1321 \begin_inset Newline newline
1322 \end_inset
1323
1324   if (length(buffer) > 0) emit_buffer();
1325 \begin_inset Newline newline
1326 \end_inset
1327
1328 }
1329 \begin_inset Newline newline
1330 \end_inset
1331
1332 @
1333 \end_layout
1334
1335 \begin_layout Standard
1336 The irony is in getting notanglefix out of this noweb document, as notanglefix
1337  is also required in order to get notanglefix out of this document.
1338 \end_layout
1339
1340 \begin_layout Standard
1341 A shorter (but perhaps not faster) variation could be based on this older
1342  but more confusing version, by defining the record separator as the same
1343  as the Lyx line separator, and otherwise treating embedded newlines as
1344  superfluous.
1345  This example is not complete.
1346 \end_layout
1347
1348 \begin_layout Scrap
1349 <<notanglefix2>>=
1350 \begin_inset Newline newline
1351 \end_inset
1352
1353 #! /usr/bin/awk -f
1354 \begin_inset Newline newline
1355 \end_inset
1356
1357
1358 \begin_inset Newline newline
1359 \end_inset
1360
1361 BEGIN {
1362 \begin_inset Newline newline
1363 \end_inset
1364
1365   RS="[ ]*
1366 \backslash
1367
1368 \backslash
1369
1370 \backslash
1371
1372 \backslash
1373 begin_inset Newline newline[ 
1374 \backslash
1375 n]*
1376 \backslash
1377
1378 \backslash
1379
1380 \backslash
1381
1382 \backslash
1383 end_inset
1384 \backslash
1385 n"
1386 \begin_inset Newline newline
1387 \end_inset
1388
1389   buffer = "";
1390 \begin_inset Newline newline
1391 \end_inset
1392
1393 }
1394 \begin_inset Newline newline
1395 \end_inset
1396
1397
1398 \begin_inset Newline newline
1399 \end_inset
1400
1401 {
1402 \begin_inset Newline newline
1403 \end_inset
1404
1405   gsub("
1406 \backslash
1407
1408 \backslash
1409
1410 \backslash
1411
1412 \backslash
1413 backslash", "
1414 \backslash
1415
1416 \backslash
1417 ");
1418 \begin_inset Newline newline
1419 \end_inset
1420
1421   gsub("
1422 \backslash
1423 n","");
1424 \begin_inset Newline newline
1425 \end_inset
1426
1427   if (NR>1) print;
1428 \begin_inset Newline newline
1429 \end_inset
1430
1431 }
1432 \begin_inset Newline newline
1433 \end_inset
1434
1435 @
1436 \end_layout
1437
1438 \begin_layout Standard
1439 Finally, to extract a C source file, we use this command, where $1 is the
1440  lyx filename and $2 is the root fragment to extract:
1441 \end_layout
1442
1443 \begin_layout Scrap
1444 <<fix-notangle-extract>>=
1445 \begin_inset Newline newline
1446 \end_inset
1447
1448 notangle -L'#line %L "%F"%N' ${2+-R"$2"} "$1" 
1449 \backslash
1450
1451 \begin_inset Newline newline
1452 \end_inset
1453
1454   | awk -f notangle-fix
1455 \begin_inset Newline newline
1456 \end_inset
1457
1458 @
1459 \end_layout
1460
1461 \begin_layout Part
1462 Using Noweb
1463 \end_layout
1464
1465 \begin_layout Section
1466 A word about Make with Noweb and Lyx
1467 \end_layout
1468
1469 \begin_layout Standard
1470 Whitespace formatting is very important in a Makefile.
1471  The first character of each command line must be a TAB.
1472 \end_layout
1473
1474 \begin_layout LyX-Code
1475 target: pre-requisite
1476 \begin_inset Newline newline
1477 \end_inset
1478
1479    →    action
1480 \begin_inset Newline newline
1481 \end_inset
1482
1483    →    action
1484 \end_layout
1485
1486 \begin_layout Standard
1487 But a TAB is pretty hard to enter in a Lyx scrap.
1488  An alternative is to use a semi-colon after the pre-requisite, and a backslash
1489  at the end of each line (except the last).
1490 \end_layout
1491
1492 \begin_layout LyX-Code
1493 target: pre-requisite ; 
1494 \backslash
1495
1496 \begin_inset Newline newline
1497 \end_inset
1498
1499 ␣␣action 
1500 \backslash
1501
1502 \begin_inset Newline newline
1503 \end_inset
1504
1505 ␣␣action
1506 \end_layout
1507
1508 \begin_layout Standard
1509 This is the style that we use and it works pretty well for GNU make at least.
1510 \end_layout
1511
1512 \begin_layout Standard
1513 We also adopt a convention that code chunks whose names beginning with ./
1514  should always be automatically extracted from the document.
1515  Code chunks whose names do not begin with ./ are for internal reference.
1516  (This doesn't prevent such chunks from being extracted directly).
1517 \end_layout
1518
1519 \begin_layout Section
1520 Boot-strapping the extraction
1521 \end_layout
1522
1523 \begin_layout Standard
1524 It seems convenient to have the makefile extract or update the C source
1525  files as part of it's operation.
1526  It also seems convenient to have the makefile itself extracted from this
1527  document.
1528 \end_layout
1529
1530 \begin_layout Standard
1531 It would also be convenient to have the code to extract the makefile from
1532  this document to also be part of this document, however we have to start
1533  somewhere and this unfortunately requires us to type at least a few words
1534  by hand to start things off.
1535 \end_layout
1536
1537 \begin_layout Standard
1538 Therefore we will have a minimal root fragment, which, when extracted, can
1539  cope with extracting the rest of the source.
1540  This, along fix notanglefix will need to be extracted manually somehow
1541  first, perhaps with this shell script, which could be called 
1542 \emph on
1543 autoboot
1544 \emph default
1545 .
1546 \end_layout
1547
1548 \begin_layout Scrap
1549 <<*>>=
1550 \begin_inset Newline newline
1551 \end_inset
1552
1553 #! /bin/sh
1554 \begin_inset Newline newline
1555 \end_inset
1556
1557
1558 \begin_inset Newline newline
1559 \end_inset
1560
1561 notangle -R./Makefile.inc "${1:-noweb-lyx.lyx}" 
1562 \backslash
1563
1564 \begin_inset Newline newline
1565 \end_inset
1566
1567   | awk -f notanglefix > ./Makefile.inc
1568 \begin_inset Newline newline
1569 \end_inset
1570
1571
1572 \begin_inset Newline newline
1573 \end_inset
1574
1575 make -f ./Makefile.inc tangle_source
1576 \begin_inset Newline newline
1577 \end_inset
1578
1579 @
1580 \end_layout
1581
1582 \begin_layout Standard
1583 The general Makefile can be invoked with 
1584 \emph on
1585 ./autoboot
1586 \emph default
1587  and can also be included into any automake file to automatically re-generate
1588  the source files.
1589 \end_layout
1590
1591 \begin_layout Standard
1592 The 
1593 \emph on
1594 autoboot
1595 \emph default
1596  can be extracted with this command:
1597 \end_layout
1598
1599 \begin_layout LyX-Code
1600 notangle noweb-lyx.lyx | awk -f notanglefix > ./autoboot
1601 \end_layout
1602
1603 \begin_layout Standard
1604 This looks simple enough, but as mentioned, notanglefix has to be had from
1605  somewhere before it can be extracted.
1606 \end_layout
1607
1608 \begin_layout Section
1609 \begin_inset CommandInset label
1610 LatexCommand label
1611 name "sub:Keeping-extracted-files"
1612
1613 \end_inset
1614
1615 Keeping extracted files up to date
1616 \end_layout
1617
1618 \begin_layout Standard
1619 Makefile.inc will cope with extracting all the other source files from this
1620  document and keeping them up to date.
1621  It make may also be included by Makefile.am.
1622 \end_layout
1623
1624 \begin_layout Standard
1625 We first define NOWEB_SOURCE to hold the name of this Lyx file.
1626 \end_layout
1627
1628 \begin_layout Scrap
1629 <<Makefile.inc>>=
1630 \begin_inset Newline newline
1631 \end_inset
1632
1633 NOWEB_SOURCE=noweb-lyx.lyx
1634 \begin_inset Newline newline
1635 \end_inset
1636
1637 @
1638 \end_layout
1639
1640 \begin_layout Standard
1641 The Lyx document can result in any number of source documents, but not all
1642  of these will be changed each time the Lyx document is updated.
1643  We certainly don't want to update the timestamps of these files and cause
1644  the whole source tree to be recompiled just because the Lyx document was
1645  edited.
1646  To solve this problem we use a stamp file which is always updated each
1647  time the sources are extracted from the Lyx document.
1648  If the stamp file is older than the Lyx document then we can make an attempt
1649  to re-extract the sources.
1650 \end_layout
1651
1652 \begin_layout Scrap
1653 <<Makefile.inc>>=
1654 \begin_inset Newline newline
1655 \end_inset
1656
1657 NOWEB_SOURCE_STAMP=$(NOWEB_SOURCE).stamp
1658 \begin_inset Newline newline
1659 \end_inset
1660
1661 @
1662 \end_layout
1663
1664 \begin_layout Standard
1665 We also must compute NOWEB_SOURCES to hold the names of all the source files
1666  defined in this document.
1667  We compute this only once, by means of := in assignent.
1668  The sed deletes the <
1669 \begin_inset space \hspace*{}
1670 \length 0in
1671 \end_inset
1672
1673 < and >
1674 \begin_inset space \hspace*{}
1675 \length 0in
1676 \end_inset
1677
1678 > which surround the output of the noroots command, and removes the root
1679  called * as that is not a valid filename.
1680  
1681 \end_layout
1682
1683 \begin_layout Standard
1684 As we use chunk names beginning with ./ to denote top level fragments that
1685  should be extracted, we also filter out all fragments that do not begin
1686  with ./
1687 \end_layout
1688
1689 \begin_layout Scrap
1690 <<Makefile.inc>>=
1691 \begin_inset Newline newline
1692 \end_inset
1693
1694 NOWEB_SOURCES:=$(shell noroots $(NOWEB_SOURCE) |
1695 \backslash
1696
1697 \begin_inset Newline newline
1698 \end_inset
1699
1700   sed -e 's/^@<<//;s/@>>$$//;/^
1701 \backslash
1702 *$$/d;/^
1703 \backslash
1704 .
1705 \backslash
1706 //!d')
1707 \begin_inset Newline newline
1708 \end_inset
1709
1710
1711 \begin_inset Newline newline
1712 \end_inset
1713
1714 echo_noweb_sources: ; @echo $(NOWEB_SOURCES)
1715 \begin_inset Newline newline
1716 \end_inset
1717
1718 @
1719 \end_layout
1720
1721 \begin_layout Standard
1722 We define a convenient target called noweb_sources to re-extract the source
1723  if the Lyx file has been updated.
1724 \end_layout
1725
1726 \begin_layout Scrap
1727 <<Makefile.inc>>=
1728 \begin_inset Newline newline
1729 \end_inset
1730
1731 noweb_sources: $(NOWEB_SOURCE_STAMP)
1732 \begin_inset Newline newline
1733 \end_inset
1734
1735 @
1736 \end_layout
1737
1738 \begin_layout Standard
1739 And also a convenient target to remove extracted sources.
1740 \end_layout
1741
1742 \begin_layout Scrap
1743 <<Makefile.inc>>=
1744 \begin_inset Newline newline
1745 \end_inset
1746
1747 clean_noweb_sources: ; rm $(NOWEB_SOURCESTAMP) $(NOWEB_SOURCES)
1748 \begin_inset Newline newline
1749 \end_inset
1750
1751 @
1752 \end_layout
1753
1754 \begin_layout Standard
1755 We now define the pattern for extracting a file.
1756  The files are written using noweb's 
1757 \emph on
1758 cpif
1759 \emph default
1760  so that the file timestamp will not be touched if the contents haven't
1761  changed.
1762  This avoids the need to rebuild the entire project because of a typographical
1763  change in the documentation, or if only a few C source files have changed.
1764 \end_layout
1765
1766 \begin_layout Scrap
1767 <<Makefile.inc>>=
1768 \begin_inset Newline newline
1769 \end_inset
1770
1771 noweb_extract = mkdir -p $(dir $(1)) && 
1772 \backslash
1773
1774 \begin_inset Newline newline
1775 \end_inset
1776
1777   notangle $(call notangle_args,$(1)) 
1778 \backslash
1779
1780 \begin_inset Newline newline
1781 \end_inset
1782
1783     -R"$(1)" "$(2)" 
1784 \backslash
1785
1786 \begin_inset Newline newline
1787 \end_inset
1788
1789   | awk -f notanglefix | cpif "$(1)"
1790 \begin_inset Newline newline
1791 \end_inset
1792
1793 @
1794 \end_layout
1795
1796 \begin_layout Standard
1797 For some source files like C files, we want to turn on source tracing by
1798  passing additional -L arguments to notangle so that C compile errors will
1799  refer to the line number in this document.
1800  We do this using the makefile macro tangle_line to generate these arguments
1801  for certain file extensions: C_EXTENSIONS.
1802 \end_layout
1803
1804 \begin_layout Scrap
1805 <<Makefile.inc>>=
1806 \begin_inset Newline newline
1807 \end_inset
1808
1809 C_EXTENSIONS=.c .h
1810 \begin_inset Newline newline
1811 \end_inset
1812
1813 C_SOURCE_TRACING=-L'
1814 \backslash
1815 #line %L "%F"%N'
1816 \begin_inset Newline newline
1817 \end_inset
1818
1819 notangle_args = $(if $(findstring $(suffix $(1)),
1820 \backslash
1821
1822 \begin_inset Newline newline
1823 \end_inset
1824
1825     $(C_EXTENSIONS)),$(C_SOURCE_TRACING))
1826 \begin_inset Newline newline
1827 \end_inset
1828
1829 @
1830 \end_layout
1831
1832 \begin_layout Standard
1833 Source tracing can be turned off with:
1834 \end_layout
1835
1836 \begin_layout LyX-Code
1837 make notangle_sources C_SOURCE_TRACING=
1838 \end_layout
1839
1840 \begin_layout Standard
1841 We define a target which will extract or update all sources.
1842  Sadly in this first attempt the targets are all extracted in one big command
1843  line.
1844  
1845 \end_layout
1846
1847 \begin_layout Scrap
1848 <<Makefile.inc-sources-big>>=
1849 \begin_inset Newline newline
1850 \end_inset
1851
1852 $(NOWEB_SOURCE_STAMP): $(NOWEB_SOURCE); 
1853 \backslash
1854
1855 \begin_inset Newline newline
1856 \end_inset
1857
1858   $(foreach source,$(NOWEB_SOURCES),
1859 \backslash
1860
1861 \begin_inset Newline newline
1862 \end_inset
1863
1864     $(call noweb_extract,$(source),$(NOWEB_SOURCE)) && 
1865 \backslash
1866
1867 \begin_inset Newline newline
1868 \end_inset
1869
1870   ) touch $(NOWEB_SOURCE_STAMP)
1871 \begin_inset Newline newline
1872 \end_inset
1873
1874 @
1875 \end_layout
1876
1877 \begin_layout Standard
1878 This better alternative defines a target for each extractable source file
1879  and has 
1880 \emph on
1881 make
1882 \emph default
1883  extract them individually.
1884  To do this we first defined a makefile template that can do this for any
1885  source file.
1886 \end_layout
1887
1888 \begin_layout Scrap
1889 <<Makefile.inc-sources>>=
1890 \begin_inset Newline newline
1891 \end_inset
1892
1893 define NOTANGLE_template
1894 \begin_inset Newline newline
1895 \end_inset
1896
1897   $(1): $(2); 
1898 \backslash
1899
1900 \begin_inset Newline newline
1901 \end_inset
1902
1903     $(call noweb_extract,$(1),$(2))
1904 \begin_inset Newline newline
1905 \end_inset
1906
1907   NOWEB_TARGETS+=$(1)
1908 \begin_inset Newline newline
1909 \end_inset
1910
1911 endef
1912 \begin_inset Newline newline
1913 \end_inset
1914
1915 @
1916 \end_layout
1917
1918 \begin_layout Standard
1919 We then enumerate the discovered NOTANGLE_SOURCES to generate a makefile
1920  rule for each one using the makefile template we defined above.
1921 \end_layout
1922
1923 \begin_layout Scrap
1924 <<Makefile.inc-sources>>=
1925 \begin_inset Newline newline
1926 \end_inset
1927
1928 $(foreach source,$(NOWEB_SOURCES),
1929 \backslash
1930
1931 \begin_inset Newline newline
1932 \end_inset
1933
1934   $(eval $(call NOTANGLE_template,$(source),$(NOWEB_SOURCE)))
1935 \backslash
1936
1937 \begin_inset Newline newline
1938 \end_inset
1939
1940 )
1941 \begin_inset Newline newline
1942 \end_inset
1943
1944 @
1945 \end_layout
1946
1947 \begin_layout Standard
1948 And finally declare the rule to build them all:
1949 \end_layout
1950
1951 \begin_layout Scrap
1952 <<Makefile.inc-sources>>=
1953 \begin_inset Newline newline
1954 \end_inset
1955
1956 $(NOWEB_SOURCE_STAMP): $(NOWEB_SOURCE) $(NOWEB_TARGETS); 
1957 \backslash
1958
1959 \begin_inset Newline newline
1960 \end_inset
1961
1962   touch $(NOWEB_SOURCE_STAMP)
1963 \backslash
1964
1965 \begin_inset Newline newline
1966 \end_inset
1967
1968 @
1969 \end_layout
1970
1971 \begin_layout Standard
1972 The Makefile.inc is then defined as
1973 \end_layout
1974
1975 \begin_layout Scrap
1976 <<./Makefile.inc>>=
1977 \begin_inset Newline newline
1978 \end_inset
1979
1980 <<Makefile.inc>>
1981 \begin_inset Newline newline
1982 \end_inset
1983
1984 <<Makefile.inc-sources>>
1985 \begin_inset Newline newline
1986 \end_inset
1987
1988 @
1989 \end_layout
1990
1991 \begin_layout Standard
1992 We may as well have notanglefix from section 
1993 \begin_inset CommandInset ref
1994 LatexCommand ref
1995 reference "sub:Generally-mangled-notangle"
1996
1997 \end_inset
1998
1999  extracted automatically too, but it will sadly begin with a blank line.
2000 \end_layout
2001
2002 \begin_layout Scrap
2003 <<./notanglefix.awk>>=
2004 \begin_inset Newline newline
2005 \end_inset
2006
2007 <<notanglefix>>
2008 \begin_inset Newline newline
2009 \end_inset
2010
2011 @
2012 \end_layout
2013
2014 \begin_layout Standard
2015 If Makefile.inc is included into Makefile, then extracted files can be updated
2016  with this command:
2017 \end_layout
2018
2019 \begin_layout LyX-Code
2020 make noweb_sources
2021 \end_layout
2022
2023 \begin_layout Standard
2024 otherwise, with:
2025 \end_layout
2026
2027 \begin_layout LyX-Code
2028 make -f Makefile.inc noweb_sources
2029 \end_layout
2030
2031 \begin_layout Bibliography
2032 \begin_inset CommandInset bibitem
2033 LatexCommand bibitem
2034 label "Extended Lyx Features"
2035 key "lyx-noweb"
2036
2037 \end_inset
2038
2039 http://nuclear.gla.ac.uk/computing/LyX_doc/Extended.html#tth_sEc6.5
2040 \end_layout
2041
2042 \end_body
2043 \end_document