]> git.lyx.org Git - lyx.git/blob - lib/doc/Development.lyx
d02aa68a3b83920151f5c13c3deedc966b9f2f45
[lyx.git] / lib / doc / Development.lyx
1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
2 \lyxformat 499
3 \begin_document
4 \begin_header
5 \origin /systemlyxdir/doc/
6 \textclass scrbook
7 \options fleqn,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading
8 \use_default_options false
9 \begin_modules
10 logicalmkup
11 theorems-ams
12 theorems-ams-extended
13 multicol
14 shapepar
15 \end_modules
16 \maintain_unincluded_children false
17 \begin_local_layout
18 Format 7
19 InsetLayout CharStyle:MenuItem
20 LyxType               charstyle
21 LabelString           menu
22 LatexType             command
23 LatexName             menuitem
24 Font
25 Family              Sans
26 EndFont
27 Preamble
28 \newcommand*{\menuitem}[1]{{\sffamily #1}}
29 EndPreamble
30 End
31 \end_local_layout
32 \language english
33 \language_package default
34 \inputencoding auto
35 \fontencoding global
36 \font_roman default
37 \font_sans default
38 \font_typewriter default
39 \font_math auto
40 \font_default_family default
41 \use_non_tex_fonts false
42 \font_sc false
43 \font_osf false
44 \font_sf_scale 100
45 \font_tt_scale 100
46 \graphics default
47 \default_output_format default
48 \output_sync 0
49 \bibtex_command default
50 \index_command default
51 \paperfontsize 12
52 \spacing single
53 \use_hyperref true
54 \pdf_title "LyX's Development manual"
55 \pdf_author "LyX Team"
56 \pdf_subject "LyX's development documentation"
57 \pdf_keywords "LyX, Documentation, Development"
58 \pdf_bookmarks true
59 \pdf_bookmarksnumbered true
60 \pdf_bookmarksopen true
61 \pdf_bookmarksopenlevel 1
62 \pdf_breaklinks false
63 \pdf_pdfborder false
64 \pdf_colorlinks true
65 \pdf_backref false
66 \pdf_pdfusetitle false
67 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
68 \papersize a4paper
69 \use_geometry false
70 \use_package amsmath 1
71 \use_package amssymb 1
72 \use_package cancel 0
73 \use_package esint 0
74 \use_package mathdots 1
75 \use_package mathtools 0
76 \use_package mhchem 1
77 \use_package stackrel 0
78 \use_package stmaryrd 0
79 \use_package undertilde 0
80 \cite_engine basic
81 \cite_engine_type default
82 \biblio_style plain
83 \use_bibtopic false
84 \use_indices false
85 \paperorientation portrait
86 \suppress_date false
87 \justification true
88 \use_refstyle 0
89 \notefontcolor #0000ff
90 \index Index
91 \shortcut idx
92 \color #008000
93 \end_index
94 \secnumdepth 3
95 \tocdepth 3
96 \paragraph_separation indent
97 \paragraph_indentation default
98 \quotes_language english
99 \papercolumns 1
100 \papersides 2
101 \paperpagestyle headings
102 \tracking_changes false
103 \output_changes false
104 \html_math_output 0
105 \html_css_as_file 0
106 \html_be_strict true
107 \end_header
108
109 \begin_body
110
111 \begin_layout Title
112 Developing \SpecialChar LyX
113
114 \end_layout
115
116 \begin_layout Subtitle
117 Version 2.2.x
118 \end_layout
119
120 \begin_layout Author
121 by the \SpecialChar LyX
122  Team
123 \begin_inset Foot
124 status collapsed
125
126 \begin_layout Plain Layout
127 \noindent
128 If you have comments or error corrections, please send them to the \SpecialChar LyX
129  Documentatio
130 n mailing list, 
131 \begin_inset Flex Code
132 status collapsed
133
134 \begin_layout Plain Layout
135 \noindent
136 <lyx-docs@lists.lyx.org>
137 \end_layout
138
139 \end_inset
140
141 .
142 \end_layout
143
144 \end_inset
145
146
147 \end_layout
148
149 \begin_layout Standard
150 \begin_inset CommandInset toc
151 LatexCommand tableofcontents
152
153 \end_inset
154
155
156 \end_layout
157
158 \begin_layout Chapter
159 Introduction
160 \end_layout
161
162 \begin_layout Standard
163 This manual documents some aspects of \SpecialChar LyX
164  development.
165  It is currently rather incomplete, but will hopefully be extended in the
166  future.
167  Meanwhile, additional information can be found in the 
168 \begin_inset Flex Code
169 status collapsed
170
171 \begin_layout Plain Layout
172 development
173 \end_layout
174
175 \end_inset
176
177  subfolder of the \SpecialChar LyX
178  source code distribution.
179  This document is not translated, since the development language of \SpecialChar LyX
180  is
181  english.
182  If you want to use \SpecialChar LyX
183  you don't need to read this manual.
184  However, if you want to learn more about how \SpecialChar LyX
185  is developed, or even want
186  to participate in \SpecialChar LyX
187  development, you may find some interesting information.
188 \end_layout
189
190 \begin_layout Chapter
191 File formats
192 \end_layout
193
194 \begin_layout Standard
195 \SpecialChar LyX
196  uses several custom file formats for configuration files and documents.
197  This chapter contains some background concerning these file formats.
198  Several file formats are also described in detail in the regular user documenta
199 tion.
200 \end_layout
201
202 \begin_layout Section
203 File Format Numbers
204 \end_layout
205
206 \begin_layout Section
207 When is an update of the .lyx file format number needed?
208 \begin_inset CommandInset label
209 LatexCommand label
210 name "sec:When-is-an"
211
212 \end_inset
213
214
215 \end_layout
216
217 \begin_layout Standard
218 When you are working on a new feature you may ask yourself whether it needs
219  an update of the .lyx file format number.
220  Whether an update is needed or not is not always obvious.
221  Below you can find a list of reasons for file format updates with explanations:
222 \end_layout
223
224 \begin_layout Description
225 New
226 \begin_inset space ~
227 \end_inset
228
229 document
230 \begin_inset space ~
231 \end_inset
232
233 setting Whenever you introduce a new setting that is stored in the document
234  header, a file format update is needed.
235  This is also true if you add a new valid value to an existing setting,
236  e.
237 \begin_inset space \thinspace{}
238 \end_inset
239
240 g.
241 \begin_inset space \space{}
242 \end_inset
243
244 a new language that is stored in 
245 \begin_inset Flex Code
246 status collapsed
247
248 \begin_layout Plain Layout
249
250 \backslash
251 language
252 \end_layout
253
254 \end_inset
255
256 .
257 \end_layout
258
259 \begin_layout Description
260 Removed
261 \begin_inset space ~
262 \end_inset
263
264 document
265 \begin_inset space ~
266 \end_inset
267
268 setting If a certain setting becomes obsolete and gets removed, a file format
269  update is needed.
270 \end_layout
271
272 \begin_layout Description
273 New
274 \begin_inset space ~
275 \end_inset
276
277 inset Of course a new inset requires a file format update.
278 \end_layout
279
280 \begin_layout Description
281 New
282 \begin_inset space ~
283 \end_inset
284
285 style in any layout file or module shipped with \SpecialChar LyX
286 , or new shipped layout
287  file or module.
288  These requirements are currently under discussion and might change in the
289  future.
290 \end_layout
291
292 \begin_layout Description
293 Automatically
294 \begin_inset space ~
295 \end_inset
296
297 loaded
298 \begin_inset space ~
299 \end_inset
300
301 math
302 \begin_inset space ~
303 \end_inset
304
305 package Any new math package that is automatically loaded needs a file format
306  update.
307  The reason for this is that there is no true ERT inset for math formulas:
308  Each command is parsed, and if a user happens to defne a local command
309  with the same name as a command that triggers an automatic load of a package,
310  he needs to be able to switch off the automatic loading of that package.
311  This switch is stored by the 
312 \begin_inset Flex Code
313 status collapsed
314
315 \begin_layout Plain Layout
316 use_package
317 \end_layout
318
319 \end_inset
320
321  header setting.
322 \end_layout
323
324 \begin_layout Standard
325 If you are still unsure, please ask on the development list.
326 \end_layout
327
328 \begin_layout Section
329 How to update the file format number of .lyx files
330 \end_layout
331
332 \begin_layout Standard
333 Once you came to the conclusion that a file format update is needed you
334  should use the following procedure to perform the update:
335 \end_layout
336
337 \begin_layout Enumerate
338 Implement and test the new feature, including the reading and writing of
339  .lyx files.
340  Note that any file produced at this stage does not use a valid format,
341  so do not use this version of \SpecialChar LyX
342  for working on any important documents.
343 \end_layout
344
345 \begin_layout Enumerate
346 Describe the new format in 
347 \begin_inset Flex Code
348 status collapsed
349
350 \begin_layout Plain Layout
351 development/FORMAT
352 \end_layout
353
354 \end_inset
355
356 .
357 \end_layout
358
359 \begin_layout Enumerate
360 Update the \SpecialChar LyX
361  file format number in 
362 \begin_inset Flex Code
363 status collapsed
364
365 \begin_layout Plain Layout
366 src/version.h
367 \end_layout
368
369 \end_inset
370
371 .
372 \end_layout
373
374 \begin_layout Enumerate
375 Add an entry to both format lists (for conversion and reversion) in
376 \begin_inset Newline newline
377 \end_inset
378
379
380 \begin_inset Flex Code
381 status collapsed
382
383 \begin_layout Plain Layout
384 lib/lyx2lyx/lyx_2_2.py
385 \end_layout
386
387 \end_inset
388
389 .
390  Add a conversion routine if needed (e.
391 \begin_inset space \thinspace{}
392 \end_inset
393
394 g.
395 \begin_inset space \space{}
396 \end_inset
397
398 a new header setting always needs a conversion that adds the new setting,
399  a new document language does not need one).
400  Add a reversion routine if needed.
401  While the conversion routine is required to produce a document that is
402  equivalent to the old version, the requirements of the reversion are not
403  that strict.
404  If possible, try to produce a proper reversion, using ERT if needed, but
405  for some features this might be too complicated.
406  In this case, the minimum requirement of the reversion routine is that
407  it produces a valid document which can be read by an older \SpecialChar LyX
408 .
409  If absolutely needed, even data loss is allowed for the reversion.
410 \end_layout
411
412 \begin_layout Enumerate
413 Since tex2lyx has several implicit file format dependencies caused by sharing
414  code with \SpecialChar LyX
415 , updating the file format of .lyx files produced by tex2lyx at
416  the same time as updating the main .lyx file format is strongly recommended.
417  Therefore, a compiler warning will be issued if the \SpecialChar LyX
418  and tex2lyx .lyx file
419  format numbers differ.
420  In many cases the tex2lyx update requires only the first and last item
421  of the list below:
422 \begin_inset Separator parbreak
423 \end_inset
424
425
426 \end_layout
427
428 \begin_deeper
429 \begin_layout Enumerate
430 Update the tex2lyx file format number in 
431 \begin_inset Flex Code
432 status collapsed
433
434 \begin_layout Plain Layout
435 src/version.h
436 \end_layout
437
438 \end_inset
439
440 .
441 \end_layout
442
443 \begin_layout Enumerate
444 If the lyx2lyx conversion from the old to the new format is empty, or if
445  tex2lyx does not yet output the changed feature, you do not need any further
446  tex2lyx changes.
447  Otherwise, search for the changed feature in tex2lyx, and adjust the output
448  according to the lyx2lyx changes.
449 \end_layout
450
451 \begin_layout Enumerate
452 Update the tex2lyx test references as described in 
453 \begin_inset CommandInset ref
454 LatexCommand formatted
455 reference "sec:Updating-test-references"
456
457 \end_inset
458
459 .
460 \end_layout
461
462 \end_deeper
463 \begin_layout Enumerate
464 If you did not implement full tex2lyx support of the new feature, add a
465  line to 
466 \begin_inset Flex Code
467 status collapsed
468
469 \begin_layout Plain Layout
470 src/tex2lyx/TODO.txt
471 \end_layout
472
473 \end_inset
474
475  describing the missing bits.
476  Note that it is perfectly fine if you do not add full tex2lyx support for
477  a new feature: The updating recommendation above is only issued for the
478  syntax of the produced .lyx file.
479  It is no problem if some features supported by \SpecialChar LyX
480  are still output as ERT
481  by tex2lyx, since the problems in the past that resulted in the update
482  recommendation were related to mixed version syntax, not ERT.
483 \end_layout
484
485 \begin_layout Enumerate
486 It would be nice if you could create a .lyx test file which contains instances
487  of all changed or added features.
488  This could then be used to test lyxl2yx and tex2lyx.
489  Unfortunately it has not yet been decided how to collect such examples,
490  so please ask on the development list if you want to create one.
491 \end_layout
492
493 \begin_layout Section
494 Backporting new styles to the stable version
495 \end_layout
496
497 \begin_layout Standard
498 Starting with the stable \SpecialChar LyX
499  2.1 branch, there is a mechanism in place to backport
500  new styles to the stable version without the need to update the file format.
501  The basic idea is that the new style definition is automatically copied
502  to the document preamble, so that it can even be used by older minor revisions
503  that did not yet include the style.
504  To backport a new style to the stable version, the following steps are
505  needed:
506 \end_layout
507
508 \begin_layout Enumerate
509 Add the line 
510 \begin_inset Flex Code
511 status collapsed
512
513 \begin_layout Plain Layout
514 ForceLocal -1
515 \end_layout
516
517 \end_inset
518
519  to the style definition in the development version.
520 \end_layout
521
522 \begin_layout Enumerate
523 Copy the style definition to the stable version, but use 
524 \begin_inset Flex Code
525 status collapsed
526
527 \begin_layout Plain Layout
528 ForceLocal 1
529 \end_layout
530
531 \end_inset
532
533  instead.
534  If needed adjust the format to the one used by the stable version (see
535  the customization manual for details of the layout file format).
536 \end_layout
537
538 \begin_layout Enumerate
539 For each update of the style in a later stable version, increase the argument
540  of 
541 \begin_inset Flex Code
542 status collapsed
543
544 \begin_layout Plain Layout
545 ForceLocal
546 \end_layout
547
548 \end_inset
549
550  by one (in the stable version, the development version should not be touched).
551 \end_layout
552
553 \begin_layout Standard
554 For details about the 
555 \begin_inset Flex Code
556 status collapsed
557
558 \begin_layout Plain Layout
559 ForceLocal
560 \end_layout
561
562 \end_inset
563
564  flag see the customization manual.
565  No 
566 \begin_inset Flex Code
567 status collapsed
568
569 \begin_layout Plain Layout
570 lyx2lyx
571 \end_layout
572
573 \end_inset
574
575  support is needed for backported styles: Since the style of the development
576  version has an infinite version number, it will always be used.
577  Furthermore, since its version number is less than one, the style will
578  not be written anymore to the document header for files saved by the new
579  version.
580 \end_layout
581
582 \begin_layout Chapter
583 Tests
584 \end_layout
585
586 \begin_layout Standard
587 Automated tests are an important tool to detect bugs and regressions in
588  software development.
589  Some projects like gcc even require each bug fix to be accompanied by a
590  test case for the automatic test suite, that would detect this bug.
591  Testing interactive features automatically is of course very hard, but
592  core functionality like document import and export can be tested quite
593  easily, and some tests of this kind exist.
594 \end_layout
595
596 \begin_layout Section
597 \SpecialChar LyX
598  tests
599 \end_layout
600
601 \begin_layout Standard
602 Some tests are located in the 
603 \begin_inset Flex Code
604 status collapsed
605
606 \begin_layout Plain Layout
607 development/autotests
608 \end_layout
609
610 \end_inset
611
612  subfolder of the \SpecialChar LyX
613  source code distribution.
614 \end_layout
615
616 \begin_layout Subsection
617 Running the tests
618 \end_layout
619
620 \begin_layout Standard
621 cmake is required to run the \SpecialChar LyX
622  tests, running them is not implemented for
623  autotools.
624  The \SpecialChar LyX
625  tests can be run by the commands 
626 \begin_inset Flex Code
627 status collapsed
628
629 \begin_layout Plain Layout
630 ctest
631 \end_layout
632
633 \end_inset
634
635  (all platforms) or 
636 \begin_inset Flex Code
637 status collapsed
638
639 \begin_layout Plain Layout
640 make test
641 \end_layout
642
643 \end_inset
644
645  (when using a make based build system and not MSVC) in the 
646 \begin_inset Flex Code
647 status collapsed
648
649 \begin_layout Plain Layout
650 autotests
651 \end_layout
652
653 \end_inset
654
655  subfolder of the build directory.
656 \end_layout
657
658 \begin_layout Section
659 tex2lyx tests
660 \end_layout
661
662 \begin_layout Standard
663 The tex2lyx tests are located in the 
664 \begin_inset Flex Code
665 status collapsed
666
667 \begin_layout Plain Layout
668 src/tex2lyx/test
669 \end_layout
670
671 \end_inset
672
673  subfolder of the \SpecialChar LyX
674  source code distribution.
675  The actual testing is performed by the simple python script 
676 \begin_inset Flex Code
677 status collapsed
678
679 \begin_layout Plain Layout
680 src/tex2lyx/test/runtests.py
681 \end_layout
682
683 \end_inset
684
685 .
686  Each test consists of two files: 
687 \begin_inset Flex Code
688 status collapsed
689
690 \begin_layout Plain Layout
691 <test name>.tex
692 \end_layout
693
694 \end_inset
695
696  contains the \SpecialChar LaTeX
697  code that should be tested.
698  
699 \begin_inset Flex Code
700 status collapsed
701
702 \begin_layout Plain Layout
703 <test name>.lyx.lyx
704 \end_layout
705
706 \end_inset
707
708  contains the expected output of tex2lyx.
709  When a test is run, the actual produced output is compared with the stored
710  reference output.
711  The test passes if both are identical.
712  The test machinery is also able to generate a file 
713 \begin_inset Flex Code
714 status collapsed
715
716 \begin_layout Plain Layout
717 <test name>.lyx.tex
718 \end_layout
719
720 \end_inset
721
722  by exporting the produced .lyx file with \SpecialChar LyX
723  again.
724  This may be useful for roundtrip comparisons.
725 \end_layout
726
727 \begin_layout Subsection
728 Running the tests
729 \end_layout
730
731 \begin_layout Standard
732 The tex2lyx tests can be run by the commands 
733 \begin_inset Flex Code
734 status collapsed
735
736 \begin_layout Plain Layout
737 ctest -R tex2lyx
738 \end_layout
739
740 \end_inset
741
742  (cmake, all platforms), 
743 \begin_inset Flex Code
744 status collapsed
745
746 \begin_layout Plain Layout
747 make test
748 \end_layout
749
750 \end_inset
751
752  (cmake, when using a make based build system and not MSVC) or 
753 \begin_inset Flex Code
754 status collapsed
755
756 \begin_layout Plain Layout
757 make alltests
758 \end_layout
759
760 \end_inset
761
762  (autotools) in the 
763 \begin_inset Flex Code
764 status collapsed
765
766 \begin_layout Plain Layout
767 src/tex2lyx
768 \end_layout
769
770 \end_inset
771
772  subfolder of the build directory.
773  If a test fails, the differences between the expected and actual results
774  are output in unified diff format.
775 \end_layout
776
777 \begin_layout Subsection
778 Updating test references
779 \begin_inset CommandInset label
780 LatexCommand label
781 name "sec:Updating-test-references"
782
783 \end_inset
784
785
786 \end_layout
787
788 \begin_layout Standard
789 In some cases a changed tex2lyx output is not a test failure, but wanted,
790  e.
791 \begin_inset space \thinspace{}
792 \end_inset
793
794 g.
795 \begin_inset space \space{}
796 \end_inset
797
798 if a tex2lyx bug was fixed, or a new feature was added.
799  In these cases the stored references need to be updated.
800  To do so if using autotools, call 
801 \begin_inset Flex Code
802 status collapsed
803
804 \begin_layout Plain Layout
805 make updatetests
806 \end_layout
807
808 \end_inset
809
810  in the 
811 \begin_inset Flex Code
812 status collapsed
813
814 \begin_layout Plain Layout
815 src/tex2lyx
816 \end_layout
817
818 \end_inset
819
820  subdirectory of the build directory.
821  If instead using CMake, call 
822 \begin_inset Flex Code
823 status collapsed
824
825 \begin_layout Plain Layout
826 make updatetex2lyxtests
827 \end_layout
828
829 \end_inset
830
831  in the build directory or in the 
832 \begin_inset Flex Code
833 status collapsed
834
835 \begin_layout Plain Layout
836 src/tex2lyx/test
837 \end_layout
838
839 \end_inset
840
841  subdirectory of the build directory
842 \begin_inset Foot
843 status collapsed
844
845 \begin_layout Plain Layout
846 Note that this is a case where a make target in the build directory can
847  affect the source directory, which might not be advisable.
848 \end_layout
849
850 \end_inset
851
852 .
853  For convenience, these commands also produce re-exported roundtrip .lyx.tex
854  files.
855  Please examine the changed output carefully before committing the changed
856  files to the repository: Since the test machinery does not do a roundtrip
857  test .tex 
858 \begin_inset Formula $\Rightarrow$
859 \end_inset
860
861  .lyx 
862 \begin_inset Formula $\Rightarrow$
863 \end_inset
864
865  .tex, and does not compare the produced dvi or pdf output, it assumes that
866  the stored .lyx reference produces correct output if processed by \SpecialChar LyX
867 .
868  There is only one chance to detect wrong output: before committing a new
869  reference.
870  Once it is committed, it is quite difficult to verify whether it is correct.
871 \end_layout
872
873 \begin_layout Standard
874 Please 
875 \emph on
876 do not
877 \emph default
878  update the test references by opening them with \SpecialChar LyX
879  or directly running lyx2lyx
880  on them.
881  This would not work, since lyx2lyx and \SpecialChar LyX
882  produce slightly different files
883  regarding insignificant whitespace and line breaks.
884 \end_layout
885
886 \begin_layout Subsection
887 Adding a new test
888 \end_layout
889
890 \begin_layout Standard
891 In many cases tests for new features may be added to one of the existing
892  test files, but sometimes this is not possible or not wanted.
893  Then a new test file needs to be added:
894 \end_layout
895
896 \begin_layout Enumerate
897 Create the new file 
898 \begin_inset Flex Code
899 status collapsed
900
901 \begin_layout Plain Layout
902 src/tex2lyx/test/<test name>.tex
903 \end_layout
904
905 \end_inset
906
907  and run tex2lyx in roundtrip mode to produce the file 
908 \begin_inset Flex Code
909 status collapsed
910
911 \begin_layout Plain Layout
912 src/tex2lyx/test/<test name>.lyx.lyx
913 \end_layout
914
915 \end_inset
916
917 .
918  This file will be the new reference.
919 \end_layout
920
921 \begin_layout Enumerate
922 Once you confirmed that the tex2lyx output is correct, add the new files
923  to the corresponding lists in 
924 \begin_inset Flex Code
925 status collapsed
926
927 \begin_layout Plain Layout
928 src/tex2lyx/test/runtests.py
929 \end_layout
930
931 \end_inset
932
933
934 \begin_inset Flex Code
935 status collapsed
936
937 \begin_layout Plain Layout
938 src/tex2lyx/Makefile.am
939 \end_layout
940
941 \end_inset
942
943  and 
944 \begin_inset Flex Code
945 status collapsed
946
947 \begin_layout Plain Layout
948 src/tex2lyx/test/CMakeLists.txt
949 \end_layout
950
951 \end_inset
952
953 .
954 \end_layout
955
956 \begin_layout Enumerate
957 Commit the changes to the repository, or send a patch to the development
958  list and ask for committing if you do not have commit rights.
959 \end_layout
960
961 \begin_layout Section
962 Export tests
963 \end_layout
964
965 \begin_layout Standard
966 The export tests are integration tests.
967  They take longer to run and are more likely to break than the tex2lyx tests.
968  Nevertheless, they have caught many regressions and without a better alternativ
969 e it is important to keep them up-to-date and understand how they work.
970 \end_layout
971
972 \begin_layout Subsection
973 Expectations of LyX developers
974 \end_layout
975
976 \begin_layout Standard
977 Because the export tests are integration tests and take a long time to run,
978  LyX developers are rarely expected to run all of the tests.
979  Here are some good practices to follow by developers:
980 \end_layout
981
982 \begin_layout Itemize
983 When making a non-trivial change to a .layout file, run the export and layout
984  tests corresponding with that .layout file.
985 \end_layout
986
987 \begin_layout Itemize
988 When making non-trivial changes to a .lyx file, run the export tests correspondin
989 g to that .lyx file.
990 \end_layout
991
992 \begin_layout Itemize
993 When making non-trivial changes to LyX's LaTeX export code (e.g.
994  touching the encoding code or package handling code that you expect will
995  change the exported LaTeX in some way), consider running all of the export
996  tests before and after your change.
997  If there are differences, please reconcile these (i.e.
998  fix the bug or fix the tests) 
999 \emph on
1000 before
1001 \emph default
1002  committing.
1003  Ask for help if you're not sure what to do or if you do not want to run
1004  the tests, post the patch on the list and others will run the tests.
1005 \end_layout
1006
1007 \begin_layout Itemize
1008 Understand how to interpret test failures.
1009  If your commit is found to have broken a test, you should be able to interpret
1010  the test results when made aware of them.
1011  See Section 
1012 \begin_inset CommandInset ref
1013 LatexCommand ref
1014 reference "subsec:Interpreting-export-tests"
1015
1016 \end_inset
1017
1018 .
1019 \end_layout
1020
1021 \begin_layout Subsection
1022 Configuring the tests
1023 \end_layout
1024
1025 \begin_layout Standard
1026 To enable these tests when using CMake, add the 
1027 \begin_inset Flex Code
1028 status collapsed
1029
1030 \begin_layout Plain Layout
1031 -DLYX_ENABLE_EXPORT_TESTS=ON
1032 \end_layout
1033
1034 \end_inset
1035
1036  flag.
1037  For example:
1038 \end_layout
1039
1040 \begin_layout Standard
1041 \begin_inset Flex Code
1042 status collapsed
1043
1044 \begin_layout Plain Layout
1045 cmake -DLYX_ENABLE_EXPORT_TESTS=ON /path/to/source
1046 \end_layout
1047
1048 \end_inset
1049
1050
1051 \end_layout
1052
1053 \begin_layout Standard
1054 \noindent
1055 This flag will increase the time for the cmake command by several seconds,
1056  mainly because of the process of inverting tests (see Section 
1057 \begin_inset CommandInset ref
1058 LatexCommand ref
1059 reference "subsec:Interpreting-export-tests"
1060
1061 \end_inset
1062
1063 ).
1064 \end_layout
1065
1066 \begin_layout Subsection
1067 Running the tests
1068 \end_layout
1069
1070 \begin_layout Standard
1071 To run all tests, in the build directory simply run the command 
1072 \begin_inset Flex Code
1073 status collapsed
1074
1075 \begin_layout Plain Layout
1076 ctest
1077 \end_layout
1078
1079 \end_inset
1080
1081 .
1082  To run only some of the tests, use the command 
1083 \begin_inset Flex Code
1084 status collapsed
1085
1086 \begin_layout Plain Layout
1087 ctest -R <pattern>
1088 \end_layout
1089
1090 \end_inset
1091
1092 , where 
1093 \begin_inset Flex Code
1094 status collapsed
1095
1096 \begin_layout Plain Layout
1097 <pattern>
1098 \end_layout
1099
1100 \end_inset
1101
1102  is a regular expression that matches test names.
1103  To run only the export tests, you can use 
1104 \begin_inset Flex Code
1105 status collapsed
1106
1107 \begin_layout Plain Layout
1108 ctest -L export
1109 \end_layout
1110
1111 \end_inset
1112
1113 .
1114  For the list of test categories available in addition to 
1115 \begin_inset Quotes eld
1116 \end_inset
1117
1118 export
1119 \begin_inset Quotes erd
1120 \end_inset
1121
1122 , run 
1123 \begin_inset Flex Code
1124 status collapsed
1125
1126 \begin_layout Plain Layout
1127 ctest --print-labels
1128 \end_layout
1129
1130 \end_inset
1131
1132 .
1133  It is often useful to list the tests without running them (e.g.
1134  if you want to know how many tests there are or whether your 
1135 \begin_inset Flex Code
1136 status collapsed
1137
1138 \begin_layout Plain Layout
1139 <pattern>
1140 \end_layout
1141
1142 \end_inset
1143
1144  regular expression did what you expected).
1145  This can be done with the 
1146 \begin_inset Flex Code
1147 status collapsed
1148
1149 \begin_layout Plain Layout
1150 -N
1151 \end_layout
1152
1153 \end_inset
1154
1155  or 
1156 \begin_inset Flex Code
1157 status collapsed
1158
1159 \begin_layout Plain Layout
1160 --show-only
1161 \end_layout
1162
1163 \end_inset
1164
1165  argument.
1166  We are still working on getting the tests to run in parallel which is supported
1167  by the 
1168 \begin_inset Flex Code
1169 status collapsed
1170
1171 \begin_layout Plain Layout
1172 ctest
1173 \end_layout
1174
1175 \end_inset
1176
1177  command with the 
1178 \begin_inset Flex Code
1179 status collapsed
1180
1181 \begin_layout Plain Layout
1182 -j <jobs>
1183 \end_layout
1184
1185 \end_inset
1186
1187  or 
1188 \begin_inset Flex Code
1189 status collapsed
1190
1191 \begin_layout Plain Layout
1192 --parallel <jobs>
1193 \end_layout
1194
1195 \end_inset
1196
1197  argument.
1198  However, when running the tests in parallel, sometimes tests fail that
1199  pass when run sequentially.
1200  A reasonable approach is to first run the tests in parallel and then run
1201  the failed tests sequentially.
1202  For example, to run 8 jobs at a time:
1203 \end_layout
1204
1205 \begin_layout Standard
1206 \begin_inset Flex Code
1207 status collapsed
1208
1209 \begin_layout Plain Layout
1210 ctest -j8
1211 \end_layout
1212
1213 \end_inset
1214
1215
1216 \end_layout
1217
1218 \begin_layout Standard
1219 \begin_inset Flex Code
1220 status collapsed
1221
1222 \begin_layout Plain Layout
1223 ctest \SpecialChar nobreakdash
1224 \SpecialChar nobreakdash
1225 rerun-failed
1226 \end_layout
1227
1228 \end_inset
1229
1230
1231 \end_layout
1232
1233 \begin_layout Standard
1234 \noindent
1235 Note that some tests cannot be run in parallel.
1236  These tests are marked in the code with the 
1237 \begin_inset Flex Code
1238 status collapsed
1239
1240 \begin_layout Plain Layout
1241 \noindent
1242 RUN_SERIAL ON
1243 \end_layout
1244
1245 \end_inset
1246
1247  CMake property.
1248 \end_layout
1249
1250 \begin_layout Standard
1251 In some situations the option 
1252 \begin_inset Flex Code
1253 status collapsed
1254
1255 \begin_layout Plain Layout
1256 --timeout <seconds>
1257 \end_layout
1258
1259 \end_inset
1260
1261  is useful.
1262  There have been bugs in LyX and in LaTeX which cause compilation to hang,
1263  and without a timeout a test might never stop (in one case there was even
1264  a memory leak).
1265  If a test times out, the 
1266 \begin_inset Flex Code
1267 status collapsed
1268
1269 \begin_layout Plain Layout
1270 ctest
1271 \end_layout
1272
1273 \end_inset
1274
1275  command exits with error, but you can distinguish between a timed out test
1276  and a failed test in the output reported at the end of the 
1277 \begin_inset Flex Code
1278 status collapsed
1279
1280 \begin_layout Plain Layout
1281 ctest
1282 \end_layout
1283
1284 \end_inset
1285
1286  command.
1287 \end_layout
1288
1289 \begin_layout Subsection
1290 \begin_inset CommandInset label
1291 LatexCommand label
1292 name "subsec:Interpreting-export-tests"
1293
1294 \end_inset
1295
1296 Interpreting the export test results
1297 \end_layout
1298
1299 \begin_layout Standard
1300 A test can fail for several reasons, not all of them bad.
1301 \end_layout
1302
1303 \begin_layout Itemize
1304 The .lyx file could have been added recently and some formats are not expected
1305  to work well.
1306 \end_layout
1307
1308 \begin_layout Itemize
1309 A dependency is not met (e.g.
1310  the LaTeX class file).
1311  One hint that this is the case is that the corresponding 
1312 \begin_inset Flex Code
1313 status open
1314
1315 \begin_layout Plain Layout
1316 check_load
1317 \end_layout
1318
1319 \end_inset
1320
1321  test will likely also fail.
1322 \end_layout
1323
1324 \begin_layout Itemize
1325 An export that previously failed to compile now compiles.
1326 \end_layout
1327
1328 \begin_layout Itemize
1329 An external dependency was updated (e.g.
1330  TeX Live).
1331 \end_layout
1332
1333 \begin_layout Itemize
1334 A recent code change introduced a bug.
1335 \end_layout
1336
1337 \begin_layout Standard
1338 Because the .lyx files are exported in several formats, it is not surprising
1339  that many of the exports fail.
1340  This expectation of failure is addressed by 
1341 \begin_inset Quotes eld
1342 \end_inset
1343
1344 inverting
1345 \begin_inset Quotes erd
1346 \end_inset
1347
1348  the tests, that is, by marking the test as 
1349 \begin_inset Quotes eld
1350 \end_inset
1351
1352 passing
1353 \begin_inset Quotes erd
1354 \end_inset
1355
1356  if the export exits with error and as 
1357 \begin_inset Quotes eld
1358 \end_inset
1359
1360 failing
1361 \begin_inset Quotes erd
1362 \end_inset
1363
1364  if the export succeeds
1365 \emph on
1366 .
1367
1368 \emph default
1369  It follows that these expected failures will not show up as failed tests
1370  in the test results and thus will not pollute the 
1371 \begin_inset Quotes eld
1372 \end_inset
1373
1374 good
1375 \begin_inset Quotes erd
1376 \end_inset
1377
1378  tests.
1379  If the export actually succeeds, then the test will fail.
1380  The purpose of this failure is to get your attentions—something has changed,
1381  possibly for the better.
1382 \end_layout
1383
1384 \begin_layout Standard
1385 We try to document why a test is inverted or ignored.
1386  See the comment (prefixed with 
1387 \begin_inset Flex Code
1388 status collapsed
1389
1390 \begin_layout Plain Layout
1391 #
1392 \end_layout
1393
1394 \end_inset
1395
1396 ) above the block in which the test is listed as inverted or ignored in
1397  the files 
1398 \begin_inset Flex Code
1399 status collapsed
1400
1401 \begin_layout Plain Layout
1402 development/autotests/revertedTests
1403 \end_layout
1404
1405 \end_inset
1406
1407  and 
1408 \begin_inset Flex Code
1409 status collapsed
1410
1411 \begin_layout Plain Layout
1412 development/autotests/ignoredTests
1413 \end_layout
1414
1415 \end_inset
1416
1417 .
1418 \end_layout
1419
1420 \begin_layout Standard
1421 What action should you take if a test fails? First, check manually that
1422  when the compilation succeeded before the resulting PDF was good.
1423  In fact, sometimes it is an improvement when a test fails.
1424  If you check manually, it might be the case that the export was succeeding
1425  before but showing garbled text in a PDF output.
1426  Now it might fail with a clear message of "language xyz not supported".
1427  It is always good to check manually why something fails and if it passes
1428  if the PDF output is good.
1429 \end_layout
1430
1431 \begin_layout Standard
1432 Sometimes a test is fixed by accident.
1433  We should uninvert a test (remove it from the 
1434 \begin_inset Flex Code
1435 status collapsed
1436
1437 \begin_layout Plain Layout
1438 revertedTests
1439 \end_layout
1440
1441 \end_inset
1442
1443  file) in order to preserve the fix.
1444 \end_layout
1445
1446 \begin_layout Standard
1447 When a test or several tests fail, consider checking the files in the 
1448 \begin_inset Flex Code
1449 status collapsed
1450
1451 \begin_layout Plain Layout
1452 Testing/Temporary/
1453 \end_layout
1454
1455 \end_inset
1456
1457  subdirectory of your build directory.
1458  In this subdirectory are three files: the file 
1459 \begin_inset Flex Code
1460 status collapsed
1461
1462 \begin_layout Plain Layout
1463 LastTestsFailed.log
1464 \end_layout
1465
1466 \end_inset
1467
1468  simply lists the tests that failed on your last 
1469 \begin_inset Flex Code
1470 status collapsed
1471
1472 \begin_layout Plain Layout
1473 ctest
1474 \end_layout
1475
1476 \end_inset
1477
1478  command; the 
1479 \begin_inset Flex Code
1480 status collapsed
1481
1482 \begin_layout Plain Layout
1483 LastTest.log
1484 \end_layout
1485
1486 \end_inset
1487
1488  file contains the output from the tests (and often has details explaining
1489  why a test failed); and the 
1490 \begin_inset Flex Code
1491 status collapsed
1492
1493 \begin_layout Plain Layout
1494 CTestCostData.txt
1495 \end_layout
1496
1497 \end_inset
1498
1499  file lists the times that it took to run the tests.
1500 \end_layout
1501
1502 \begin_layout Section
1503 check_load tests
1504 \end_layout
1505
1506 \begin_layout Standard
1507 These tests check whether a .lyx file loads without any terminal messages.
1508  They correspond to the manual operations of simply opening a .lyx file on
1509  the terminal, exiting LyX once the file is loaded, and then checking whether
1510  there is any output from the terminal.
1511  These tests are useful for catching malformed .lyx files and parsing bugs.
1512  They can also be used to find a .lyx file in which an instance of something
1513  happens.
1514  To do this, compile LyX with a local patch that outputs something to the
1515  terminal when an instance is found, and then run the check_load tests to
1516  see if any fail, which would mean that the situation occurs in the LyX
1517  documentation files corresponding to the failed tests.
1518  These tests are expectedly fragile: any LyX diagnostic message, which is
1519  not necessarily an error, would cause the tests to fail.
1520  Similarly, any message output by a library (e.g.
1521  Qt) would also cause failure.
1522  There are some messages that the check_load tests are instructed to ignore,
1523  which are stored in the file 
1524 \begin_inset Flex Code
1525 status collapsed
1526
1527 \begin_layout Plain Layout
1528 development/autotests/filterCheckWarnings
1529 \end_layout
1530
1531 \end_inset
1532
1533 .
1534 \end_layout
1535
1536 \begin_layout Section
1537 URL tests
1538 \end_layout
1539
1540 \begin_layout Standard
1541 The URL tests are enabled with the 
1542 \begin_inset Flex Code
1543 status collapsed
1544
1545 \begin_layout Plain Layout
1546 -DLYX_ENABLE_URLTESTS=ON
1547 \end_layout
1548
1549 \end_inset
1550
1551  CMake flag and are useful for finding broken links in our documentation
1552  files.
1553  If a URL test fails, to see which link in particular was reported as broken,
1554  see the output in 
1555 \begin_inset Flex Code
1556 status collapsed
1557
1558 \begin_layout Plain Layout
1559 LastTest.log
1560 \end_layout
1561
1562 \end_inset
1563
1564 .
1565  These tests are extremely fragile (e.g.
1566  a test can depend on your Internet connection) and a failed URL test should
1567  not be taken too seriously.
1568 \end_layout
1569
1570 \begin_layout Chapter
1571 Development policies
1572 \end_layout
1573
1574 \begin_layout Standard
1575 This chapter lists some guidelines that should be followed.
1576  This list is not complete, and many guidelines are in separate chapters,
1577  such as 
1578 \begin_inset Quotes eld
1579 \end_inset
1580
1581 When is an update of the .lyx file format number needed?
1582 \begin_inset Quotes erd
1583 \end_inset
1584
1585  in Section 
1586 \begin_inset CommandInset ref
1587 LatexCommand ref
1588 reference "sec:When-is-an"
1589
1590 \end_inset
1591
1592 .
1593 \end_layout
1594
1595 \begin_layout Section
1596 When to set a fixed milestone?
1597 \end_layout
1598
1599 \begin_layout Standard
1600 Only set a fixed milestone (like 2.1.4 or 2.2.0) if at least one of the following
1601  holds:
1602 \end_layout
1603
1604 \begin_layout Enumerate
1605 Somebody is actively working on a fix.
1606 \end_layout
1607
1608 \begin_layout Enumerate
1609 The bug is so severe that it would block the release if it is not fixed.
1610 \end_layout
1611
1612 \begin_layout Standard
1613 If a bug is important, but nobody is working on it, and it is no showstopper,
1614  use a milestone like 2.1.x or 2.2.x.
1615  For all other bugs, do not set a milestone at all.
1616 \end_layout
1617
1618 \begin_layout Section
1619 Can we add rc entries in stable branch?
1620 \end_layout
1621
1622 \begin_layout Standard
1623 No.
1624  We are supposed to increase the prefs2prefs version number with such things.
1625 \end_layout
1626
1627 \begin_layout Chapter
1628 Documentation policies
1629 \end_layout
1630
1631 \begin_layout Standard
1632 The main documentation consists of these files:
1633 \end_layout
1634
1635 \begin_layout Description
1636 splash.lyx it is the first file you see after an installation.
1637  We assume that a new user sees this.
1638  It is therefore designed to be as simple as possible.
1639  Therefore please don't add any new formatting, only fix typos etc.
1640  Splash.lyx is up to date for \SpecialChar LyX
1641  2.1.x, currently maintained by Uwe Stöhr.
1642 \end_layout
1643
1644 \begin_layout Description
1645 Intro.lyx This is the manual new users will read to learn \SpecialChar LyX
1646 .
1647  It therefore uses a limited set of formatting.
1648  For example a standard document class.
1649  Since new users will first learn about the formatting possibilities of
1650  \SpecialChar LyX
1651  please keep this file that simple.
1652  Intro.lyx is up to date for \SpecialChar LyX
1653  2.1.x, currently maintained by Uwe Stöhr.
1654 \end_layout
1655
1656 \begin_layout Description
1657 Tutorial.lyx our tutorial.
1658  It must be always up to date.
1659  Normally there is nothing to add since we don't want to overwhelm new users
1660  with too much details.
1661  The will learn these details while using \SpecialChar LyX
1662  and we have special manuals.
1663  Tutorial.lyx is up to date for \SpecialChar LyX
1664  2.1.x, currently maintained by Uwe Stöhr.
1665 \end_layout
1666
1667 \begin_layout Description
1668 UserGuide.lyx our main user guide.
1669  It covers a mixture of basic and detailed information.
1670  Some information is also in the Math and EmbeddedObjects manual so that
1671  the UserGuide refers to these files.
1672  UserGuide.lyx is up to date for \SpecialChar LyX
1673  2.1.x, currently maintained by Uwe Stöhr.
1674 \end_layout
1675
1676 \begin_layout Description
1677 EmbeddedObjects.lyx a special manual to explain things like tables floats
1678  boxes etc.
1679  in all detail.
1680  EmbeddedObjects.lyx is up to date for \SpecialChar LyX
1681  2.1.x, currently maintained by Uwe
1682  Stöhr.
1683 \end_layout
1684
1685 \begin_layout Description
1686 Math.lyx a special manual to explain everything regarding math in all detail.
1687  Math.lyx is up to date for \SpecialChar LyX
1688  2.1.x, currently maintained by Uwe Stöhr.
1689 \end_layout
1690
1691 \begin_layout Description
1692 Additional.lyx this manual covers information that would be too much detail
1693  for the UserGuide or would make the UserGuide uncompilable or only compilable
1694  when installing a lot of special \SpecialChar LaTeX
1695 -packages.
1696  What should be in the UserGuide or better in Additional is a matter of
1697  taste.
1698  it is up to you to decide that.
1699  Additional.lyx is not completely up to date for \SpecialChar LyX
1700  2.1.x.
1701  Only chapter
1702 \begin_inset space ~
1703 \end_inset
1704
1705 8 is up to date and currently maintained by Uwe Stöhr.
1706  It certainly needs a rewrite and update.
1707  For example many info in chapter
1708 \begin_inset space ~
1709 \end_inset
1710
1711 2 and 3 are already covered by the UserGuide and/or the EmbeddedObjects
1712  manual.
1713 \end_layout
1714
1715 \begin_layout Description
1716 Customization.lyx this manual covers information how to customize \SpecialChar LyX
1717  for certain
1718  output formats, operating systems, languages etc.
1719  It is currently completely out of date and needs a major rewrite and update.
1720  If you do this please assure that your information are given for all OSes
1721  and \SpecialChar LaTeX
1722  distributions (meaning be as objective as possible).
1723 \end_layout
1724
1725 \begin_layout Standard
1726 There are only 4
1727 \begin_inset space ~
1728 \end_inset
1729
1730 rules in editing the docs:
1731 \end_layout
1732
1733 \begin_layout Enumerate
1734 If you are not the maintainer of a doc file or a chapter/section, you MUST
1735  use change tracking so that the maintainer could review your changes
1736 \end_layout
1737
1738 \begin_layout Enumerate
1739 Respect the formatting of the document.
1740  The different files use different formatting styles.
1741  That is OK and has historic reasons nobody fully know ;-).
1742  But it is important to be consistent within one file.
1743 \end_layout
1744
1745 \begin_layout Enumerate
1746 All changes you make to a file in one language MUST also go the file in
1747  the other actively maintained languages.
1748  Normally the maintainer does this for you, if you are the maintainer, you
1749  must do this by copying or changing the changed or added text to the other
1750  files so that the translators sees the blue underlined text and know what
1751  they have to translate and what was changed.
1752 \end_layout
1753
1754 \begin_layout Enumerate
1755 You MUST assure that the document is compilable as 
1756 \begin_inset Quotes eld
1757 \end_inset
1758
1759 PDF (pdflatex)
1760 \begin_inset Quotes erd
1761 \end_inset
1762
1763  after your changes.
1764 \end_layout
1765
1766 \end_body
1767 \end_document