1 #LyX 2.1 created this file. For more info see http://www.lyx.org/
6 \options fleqn,bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading
7 \use_default_options false
15 \maintain_unincluded_children false
18 InsetLayout CharStyle:MenuItem
27 \newcommand*{\menuitem}[1]{{\sffamily #1}}
32 \language_package default
37 \font_typewriter default
39 \font_default_family default
40 \use_non_tex_fonts false
46 \default_output_format default
48 \bibtex_command default
49 \index_command default
53 \pdf_title "LyX's Development manual"
54 \pdf_author "LyX Team"
55 \pdf_subject "LyX's development documentation"
56 \pdf_keywords "LyX, Documentation, Development"
58 \pdf_bookmarksnumbered true
59 \pdf_bookmarksopen true
60 \pdf_bookmarksopenlevel 1
65 \pdf_pdfusetitle false
66 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
69 \use_package amsmath 1
70 \use_package amssymb 1
73 \use_package mathdots 1
74 \use_package mathtools 0
76 \use_package stackrel 0
77 \use_package stmaryrd 0
78 \use_package undertilde 0
80 \cite_engine_type default
84 \paperorientation portrait
88 \notefontcolor #0000ff
95 \paragraph_separation indent
96 \paragraph_indentation default
97 \quotes_language english
100 \paperpagestyle headings
101 \tracking_changes false
102 \output_changes false
114 \begin_layout Subtitle
123 \begin_layout Plain Layout
125 If you have comments or error corrections, please send them to the LyX Documenta
127 \begin_inset Flex Code
130 \begin_layout Plain Layout
132 <lyx-docs@lists.lyx.org>
145 \begin_layout Standard
146 \begin_inset CommandInset toc
147 LatexCommand tableofcontents
154 \begin_layout Chapter
158 \begin_layout Standard
159 This manual documents some aspects of LyX development.
160 It is currently rather incomplete, but will hopefully be extended in the
162 Meanwhile, additional information can be found in the
163 \begin_inset Flex Code
166 \begin_layout Plain Layout
172 subfolder of the LyX source code distribution.
173 This document is not translated, since the development language of LyX
175 If you want to use LyX you don't need to read this manual.
176 However, if you want to learn more about how LyX is developed, or even
177 want to participate in LyX development, you may find some interesting informati
181 \begin_layout Chapter
185 \begin_layout Standard
186 LyX uses several custom file formats for configuration files and documents.
187 This chapter contains some background concerning these file formats.
188 Several file formats are also described in detail in the regular user documenta
192 \begin_layout Section
196 \begin_layout Section
197 When is an update of the .lyx file format number needed?
200 \begin_layout Standard
201 When you ware working on a new feature you may ask yourself whether it needs
202 an update of the .lyx file format number.
203 Whether an update is needed or not is not always obvious.
204 Below you can find a list of reasons for file format updates with explanations:
207 \begin_layout Description
216 setting Whenever you introduce a new setting that is stored in the document
217 header, a file format update is needed.
218 This is also true if you add a new valid value to an existing setting,
220 \begin_inset space \thinspace{}
224 \begin_inset space \space{}
227 a new language that is stored in
228 \begin_inset Flex Code
231 \begin_layout Plain Layout
242 \begin_layout Description
251 setting If a certain setting becomes obsolete and gets removed, a file format
255 \begin_layout Description
260 inset Of course a new inset requires a file format update.
263 \begin_layout Description
268 style in any layout file or module shipped with LyX, or new shipped layout
270 These requirements are currently under discussion and might change in the
274 \begin_layout Description
287 package Any new math package that is automatically loaded needs a file format
289 The reason for this is that there is no true ERT inset for math formulas:
290 Each command is parsed, and if a user happens to defne a local command
291 with the same name as a command that triggers an automatic load of a package,
292 he needs to be able to switch off the automatic loading of that package.
293 This switch is stored by the
294 \begin_inset Flex Code
297 \begin_layout Plain Layout
306 \begin_layout Standard
307 If you are still unsure, please ask on the development list.
310 \begin_layout Section
311 How to update the file format number of .lyx files
314 \begin_layout Standard
315 Once you came to the conclusion that a file format update is needed you
316 should use the following procedure to perform the update:
319 \begin_layout Enumerate
320 Implement and test the new feature, including the reading and writing of
322 Note that any file produced at this stage does not use a valid format,
323 so do not use this version of LyX for working on any important documents.
326 \begin_layout Enumerate
327 Describe the new format in
328 \begin_inset Flex Code
331 \begin_layout Plain Layout
340 \begin_layout Enumerate
341 Update the LyX file format number in
342 \begin_inset Flex Code
345 \begin_layout Plain Layout
354 \begin_layout Enumerate
355 Add an entry to both format lists (for conversion and reversion) in
356 \begin_inset Newline newline
360 \begin_inset Flex Code
363 \begin_layout Plain Layout
364 lib/lyx2lyx/lyx_2_1.py
370 Add a conversion routine if needed (e.
371 \begin_inset space \thinspace{}
375 \begin_inset space \space{}
378 a new header setting always needs a conversion that adds the new setting,
379 a new document language does not need one).
380 Add a reversion routine if needed.
381 While the conversion routine is required to produce a document that is
382 equivalent to the old version, the requirements of the reversion are not
384 If possible, try to produce a proper reversion, using ERT if needed, but
385 for some features this might be too complicated.
386 In this case, the minimum requirement of the reversion routine is that
387 it produces a valid document which can be read by an older LyX.
388 If absolutely needed, even data loss is allowed for the reversion.
391 \begin_layout Enumerate
392 Since tex2lyx has several implicit file format dependencies caused by sharing
393 code with LyX, updating the file format of .lyx files produced by tex2lyx
394 at the same time as updating the main .lyx file format is strongly recommended.
395 Therefore, a compiler warning will be issued if the LyX and tex2lyx .lyx
396 file format numbers differ.
397 In many cases the tex2lyx update requires only the first and last item
402 \begin_layout Enumerate
403 Update the tex2lyx file format number in
404 \begin_inset Flex Code
407 \begin_layout Plain Layout
416 \begin_layout Enumerate
417 If the lyx2lyx conversion from the old to the new format is empty, or if
418 tex2lyx does not yet output the changed feature, you do not need any further
420 Otherwise, search for the changed feature in tex2lyx, and adjust the output
421 according to the lyx2lyx changes.
424 \begin_layout Enumerate
425 Update the tex2lyx test references as described in
426 \begin_inset CommandInset ref
427 LatexCommand formatted
428 reference "sec:Updating-test-references"
436 \begin_layout Enumerate
437 If you did not implement full tex2lyx support of the new feature, add a
439 \begin_inset Flex Code
442 \begin_layout Plain Layout
448 describing the missing bits.
449 Note that it is perfectly fine if you do not add full tex2lyx support for
450 a new feature: The updating recommendation above is only issued for the
451 syntax of the produced .lyx file.
452 It is no problem if some features supported by LyX are still output as
453 ERT by tex2lyx, since the problems in the past that resulted in the update
454 recommendation were related to mixed version syntax, not ERT.
457 \begin_layout Section
458 Backporting new styles to the stable version
461 \begin_layout Standard
462 Starting with the stable LyX 2.1 branch, there is a mechanism in place to
463 backport new styles to the stable version without the need to update the
465 The basic idea is that the new style definition is automatically copied
466 to the document preamble, so that it can even be used by older minor revisions
467 that did not yet include the style.
468 To backport a new style to the stable version, the following steps are
472 \begin_layout Enumerate
474 \begin_inset Flex Code
477 \begin_layout Plain Layout
483 to the style definition in the development version.
486 \begin_layout Enumerate
487 Copy the style definition to the stable version, but use
488 \begin_inset Flex Code
491 \begin_layout Plain Layout
498 If needed adjust the format to the one used by the stable version (see
499 the customization manual for details of the layout file format).
502 \begin_layout Enumerate
503 For each update of the style in a later stable version, increase the argument
505 \begin_inset Flex Code
508 \begin_layout Plain Layout
514 by one (in the stable version, the development version should not be touched).
517 \begin_layout Standard
518 For details about the
519 \begin_inset Flex Code
522 \begin_layout Plain Layout
528 flag see the customization manual.
530 \begin_inset Flex Code
533 \begin_layout Plain Layout
539 support is needed for backported styles: Since the style of the development
540 version has an infinite version number, it will always be used.
541 Furthermore, since its version number is less than one, the style will
542 not be written anymore to the document header for files saved by the new
546 \begin_layout Chapter
550 \begin_layout Standard
551 Automated tests are an important tool to detect bugs and regressions in
552 software development.
553 Some projects like gcc even require each bug fix to be accompanied by a
554 test case for the automatic test suite, that would detect this bug.
555 Testing interactive features automatically is of course very hard, but
556 core functionality like document import and export can be tested quite
557 easily, and some tests of this kind exist.
560 \begin_layout Section
564 \begin_layout Standard
565 Some tests are located in the
566 \begin_inset Flex Code
569 \begin_layout Plain Layout
570 development/autotests
575 subfolder of the LyX source code distribution.
578 \begin_layout Subsection
582 \begin_layout Standard
583 The LyX tests can be run by the commands
584 \begin_inset Flex Code
587 \begin_layout Plain Layout
594 \begin_inset Flex Code
597 \begin_layout Plain Layout
603 subfolder of the build directory.
604 \begin_inset Note Note
607 \begin_layout Plain Layout
608 FIXME: Is this possible with autotools?
616 \begin_layout Section
620 \begin_layout Standard
621 The tex2lyx tests are located in the
622 \begin_inset Flex Code
625 \begin_layout Plain Layout
631 subfolder of the LyX source code distribution.
632 The actual testing is performed by the simple python script
633 \begin_inset Flex Code
636 \begin_layout Plain Layout
637 src/tex2lyx/test/runtests.py
643 Each test consists of two files:
644 \begin_inset Flex Code
647 \begin_layout Plain Layout
653 contains the LaTeX code that should be tested.
655 \begin_inset Flex Code
658 \begin_layout Plain Layout
664 contains the expected output of tex2lyx.
665 When a test is run, the actual produced output is compared with the stored
667 The test passes if both are identical.
668 The test machinery is also able to generate a file
669 \begin_inset Flex Code
672 \begin_layout Plain Layout
678 by exporting the produced .lyx file with LyX again.
679 This may be useful for roundtrip comparisons.
682 \begin_layout Subsection
686 \begin_layout Standard
687 The tex2lyx tests can be run by the commands
688 \begin_inset Flex Code
691 \begin_layout Plain Layout
698 \begin_inset Flex Code
701 \begin_layout Plain Layout
708 \begin_inset Flex Code
711 \begin_layout Plain Layout
717 subfolder of the build directory.
718 If a test fails, the differences between the expected and actual results
719 are output in unified diff format.
722 \begin_layout Subsection
723 Updating test references
724 \begin_inset CommandInset label
726 name "sec:Updating-test-references"
733 \begin_layout Standard
734 In some cases a changed tex2lyx output is not a test failure, but wanted,
736 \begin_inset space \thinspace{}
740 \begin_inset space \space{}
743 if a tex2lyx bug was fixed, or a new feature was added.
744 In these cases the stored references need to be updated.
746 \begin_inset Flex Code
749 \begin_layout Plain Layout
756 \begin_inset Note Note
759 \begin_layout Plain Layout
760 FIXME: Add cmake command
766 \begin_inset Flex Code
769 \begin_layout Plain Layout
775 subfolder of the build directory.
776 For convenience, this command does also produce re-exported roundtrip .lyx.tex
778 Please examine the changed output carefully before committing the changed
779 files to the repository: Since the test machinery does not do a roundtrip
781 \begin_inset Formula $\Rightarrow$
785 \begin_inset Formula $\Rightarrow$
788 .tex, and does not compare the produced dvi or pdf output, it assumes that
789 the stored .lyx reference produces correct output if processed by LyX.
790 There is only one chance to detect wrong output: before committing a new
792 Once it is committed, it is quite difficult to verify whether it is correct.
795 \begin_layout Subsection
799 \begin_layout Standard
800 In many cases tests for new features may be added to one of the existing
801 test files, but sometimes this is not possible or not wanted.
802 Then a new test file needs to be added:
805 \begin_layout Enumerate
807 \begin_inset Flex Code
810 \begin_layout Plain Layout
811 src/tex2lyx/test/<test name>.tex
816 and run tex2lyx in roundtrip mode to produce the file
817 \begin_inset Flex Code
820 \begin_layout Plain Layout
821 src/tex2lyx/test/<test name>.lyx.lyx
827 This file will be the new reference.
830 \begin_layout Enumerate
831 Once you confirmed that the tex2lyx output is correct, add the new files
832 to the corresponding lists in
833 \begin_inset Flex Code
836 \begin_layout Plain Layout
837 src/tex2lyx/test/runtests.py
843 \begin_inset Flex Code
846 \begin_layout Plain Layout
847 src/tex2lyx/Makefile.am
853 \begin_inset Flex Code
856 \begin_layout Plain Layout
857 src/tex2lyx/test/CMakeLists.txt
865 \begin_layout Enumerate
866 Commit the changes to the repository, or send a patch to the development
867 list and ask for committing if you do not have commit rights.