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 false
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 numerical
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 a new language that is stored in
221 \begin_inset Flex Code
224 \begin_layout Plain Layout
235 \begin_layout Description
244 setting If a certain setting becomes obsolete and gets removed, a file format
248 \begin_layout Description
253 inset Of course a new inset requires a file format update.
256 \begin_layout Description
261 style in any layout file or module shipped with LyX, or new shipped layout
263 These requirements are currently under discussion and might change in the
267 \begin_layout Description
280 package Any new math package that is automatically loaded needs a file format
282 The reason for this is that there is no true ERT inset for math formulas:
283 Each command is parsed, and if a user happens to defne a local command
284 with the same name as a command that triggers an automatic load of a package,
285 he needs to be able to switch off the automatic loading of that package.
286 This switch is stored by the
287 \begin_inset Flex Code
290 \begin_layout Plain Layout
299 \begin_layout Standard
300 If you are still unsure, please ask on the development list.
303 \begin_layout Section
304 How to update the file format number of .lyx files
307 \begin_layout Standard
308 Once you came to the conclusion that a file format update is needed you
309 should use the following procedure to perform the update:
312 \begin_layout Enumerate
313 Implement and test the new feature, including the reading and writing of
315 Note that any file produced at this stage does not use a valid format,
316 so do not use this version of LyX for working on any important documents.
319 \begin_layout Enumerate
320 Describe the new format in
321 \begin_inset Flex Code
324 \begin_layout Plain Layout
333 \begin_layout Enumerate
334 Update the LyX file format number in
335 \begin_inset Flex Code
338 \begin_layout Plain Layout
347 \begin_layout Enumerate
348 Add an entry to both format lists (for conversion and reversion) in
349 \begin_inset Flex Code
352 \begin_layout Plain Layout
353 lib/lyx2lyx_lyx2lyx_2_1.py
359 Add a conversion routine if needed (e.g.
360 a new header setting always needs a conversion that adds the new setting,
361 a new document language does not need one).
362 Add a reversion routine if needed.
363 While the conversion routine is required to produce a document that is
364 equivalent to the old version, the requirements of the reversion are not
366 If possible, try to produce a proper reversion, using ERT if needed, but
367 for some features this might be too complicated.
368 In this case, the minimum requirement of the reversion routine is that
369 it produces a valid document which can be read by an older LyX.
370 If absolutely needed, even data loss is allowed for the reversion.
373 \begin_layout Enumerate
374 Since tex2lyx has several implicit file format dependencies caused by sharing
375 code with LyX, updating the file format of .lyx files produced by tex2lyx
376 at the same time as updating the main .lyx file format is strongly recommended.
377 Therefore, a compiler warning will be issued if the LyX and tex2lyx .lyx
378 file format numbers differ.
379 In many cases the tex2lyx update requires only the first and last item
384 \begin_layout Enumerate
385 Update the tex2lyx file format number in
386 \begin_inset Flex Code
389 \begin_layout Plain Layout
398 \begin_layout Enumerate
399 If the lyx2lyx conversion from the old to the new format is empty, or if
400 tex2lyx does not yet output the changed feature, you do not need any further
402 Otherwise, search for the changed feature in tex2lyx, and adjust the output
403 according to the lyx2lyx changes.
406 \begin_layout Enumerate
407 Update the tex2lyx test references as described in
408 \begin_inset CommandInset ref
409 LatexCommand formatted
410 reference "sec:Updating-test-references"
418 \begin_layout Enumerate
419 If you did not implement full tex2lyx support of the new feature, add a
421 \begin_inset Flex Code
424 \begin_layout Plain Layout
430 describing the missing bits.
431 Note that it is perfectly fine if you do not add full tex2lyx support for
432 a new feature: The updating recommendation above is only issued for the
433 syntax of the produced .lyx file.
434 It is no problem if some features supported by LyX are still output as
435 ERT by tex2lyx, since the problems in the past that resulted in the update
436 recommendation were related to mixed version syntax, not ERT.
439 \begin_layout Section
440 Backporting new styles to the stable version
443 \begin_layout Standard
444 Starting with the stable LyX 2.1 branch, there is a mechanism in place to
445 backport new styles to the stable version without the need to update the
447 The basic idea is that the new style definition is automatically copied
448 to the document preamble, so that it can even be used by older minor revisions
449 that did not yet include the style.
450 To backport a new style to the stable version, the following steps are
454 \begin_layout Enumerate
456 \begin_inset Flex Code
459 \begin_layout Plain Layout
465 to the style definition in the development version.
468 \begin_layout Enumerate
469 Copy the style definition to the stable version, but use
470 \begin_inset Flex Code
473 \begin_layout Plain Layout
480 If needed adjust the format to the one used by the stable version (see
481 the customization manual for details of the layout file format).
484 \begin_layout Enumerate
485 For each update of the style in a later stable version, increase the argument
487 \begin_inset Flex Code
490 \begin_layout Plain Layout
496 by one (in the stable version, the development version should not be touched).
499 \begin_layout Standard
500 For details about the
501 \begin_inset Flex Code
504 \begin_layout Plain Layout
510 flag see the customization manual.
512 \begin_inset Flex Code
515 \begin_layout Plain Layout
521 support is needed for backported styles: Since the style of the development
522 version has an infinite version number, it will always be used.
523 Furthermore, since its version number is less than one, the style will
524 not be written anymore to the document header for files saved by the new
528 \begin_layout Chapter
532 \begin_layout Standard
533 Automated tests are an important tool to detect bugs and regressions in
534 software development.
535 Some projects like gcc even require each bug fix to be accompanied by a
536 test case for the automatic test suite, that would detect this bug.
537 Testing interactive features automatically is of course very hard, but
538 core functionality like document import and export can be tested quite
539 easily, and some tests of this kind exist.
542 \begin_layout Section
546 \begin_layout Standard
547 Some tests are located in the
548 \begin_inset Flex Code
551 \begin_layout Plain Layout
552 development/autotests
557 subfolder of the LyX source code distribution.
560 \begin_layout Subsection
564 \begin_layout Standard
565 The LyX tests can be run by the commands
566 \begin_inset Flex Code
569 \begin_layout Plain Layout
576 \begin_inset Flex Code
579 \begin_layout Plain Layout
585 subfolder of the build directory.
586 \begin_inset Note Note
589 \begin_layout Plain Layout
590 FIXME: Is this possible with autotools?
598 \begin_layout Section
602 \begin_layout Standard
603 The tex2lyx tests are located in the
604 \begin_inset Flex Code
607 \begin_layout Plain Layout
613 subfolder of the LyX source code distribution.
614 The actual testing is performed by the simple python script
615 \begin_inset Flex Code
618 \begin_layout Plain Layout
619 src/tex2lyx/test/runtests.py
625 Each test consists of two files:
626 \begin_inset Flex Code
629 \begin_layout Plain Layout
635 contains the LaTeX code that should be tested.
637 \begin_inset Flex Code
640 \begin_layout Plain Layout
646 contains the expected output of tex2lyx.
647 When a test is run, the actual produced output is compared with the stored
649 The test passes if both are identical.
650 The test machinery is also able to generate a file
651 \begin_inset Flex Code
654 \begin_layout Plain Layout
660 by exporting the produced .lyx file with LyX again.
661 This may be useful for roundtrip comparisons.
664 \begin_layout Subsection
668 \begin_layout Standard
669 The tex2lyx tests can be run by the commands
670 \begin_inset Flex Code
673 \begin_layout Plain Layout
680 \begin_inset Flex Code
683 \begin_layout Plain Layout
690 \begin_inset Flex Code
693 \begin_layout Plain Layout
699 subfolder of the build directory.
700 If a test fails, the differences between the expected and actual results
701 are output in unified diff format.
704 \begin_layout Subsection
705 Updating test references
706 \begin_inset CommandInset label
708 name "sec:Updating-test-references"
715 \begin_layout Standard
716 In some cases a changed tex2lyx output is not a test failure, but wanted,
718 if a tex2lyx bug was fixed, or a new feature was added.
719 In these cases the stored references need to be updated.
721 \begin_inset Flex Code
724 \begin_layout Plain Layout
731 \begin_inset Note Note
734 \begin_layout Plain Layout
735 FIXME: Add cmake command
741 \begin_inset Flex Code
744 \begin_layout Plain Layout
750 subfolder of the build directory.
751 For convenience, this command does also produce re-exported roundtrip .lyx.tex
753 Please examine the changed output carefully before committing the changed
754 files to the repository: Since the test machinery does not do a roundtrip
756 \begin_inset Formula $\Rightarrow$
760 \begin_inset Formula $\Rightarrow$
763 .tex, and does not compare the produced dvi or pdf output, it assumes that
764 the stored .lyx reference produces correct output if processed by LyX.
765 There is only one chance to detect wrong output: before committing a new
767 Once it is committed, it is quite difficult to verify whether it is correct.
770 \begin_layout Subsection
774 \begin_layout Standard
775 In many cases tests for new features may be added to one of the existing
776 test files, but sometimes this is not possible or not wanted.
777 Then a new test file needs to be added:
780 \begin_layout Enumerate
782 \begin_inset Flex Code
785 \begin_layout Plain Layout
786 src/tex2lyx/test/<test name>.tex
791 and run tex2lyx in roundtrip mode to produce the file
792 \begin_inset Flex Code
795 \begin_layout Plain Layout
796 src/tex2lyx/test/<test name>.lyx.lyx
802 This file will be the new reference.
805 \begin_layout Enumerate
806 Once you confirmed that the tex2lyx output is correct, add the new files
807 to the corresponding lists in
808 \begin_inset Flex Code
811 \begin_layout Plain Layout
812 src/tex2lyx/test/runtests.py
818 \begin_inset Flex Code
821 \begin_layout Plain Layout
822 src/tex2lyx/Makefile.am
828 \begin_inset Flex Code
831 \begin_layout Plain Layout
832 src/tex2lyx/test/CMakeLists.txt
840 \begin_layout Enumerate
841 Commit the changes to the repository, or send a patch to the development
842 list and ask for committing if you do not have commit rights.