GNU TeXmacsUser manualReferenceAboutEnglish
Writing and validating developer documentation

1.Conventions

The general conventions for the documentation (directories, file names, meta information, licenses) are given in contributing to the TeXmacs documentation. For the developer documentation in

doc/devel/source/

, the following conventions have proved useful:

2.Links to the source files

The pages of the developer documentation only make sense together with the code, so every reference to a source file is a link:

<source-link|Typeset/Env/env_exec.cpp|src/Typeset/Env/env_exec.cpp>
<source-link|ai.cpp:815|src/Data/Convert/AI/ai.cpp:815>

The first argument is the text which is shown, in the verbatim font; the second one is the path of the file relative to the src directory of the repository (the directory which contains src, TeXmacs and plugins), optionally followed by :line. The path may also name a directory, which is opened with the file manager of the system. A click calls open-source-link of

doc/source-links.scm

, which looks for the file in

  1. the directory of the preference developer:source directory, if it is set;

  2. otherwise $TEXMACS_SOURCE_PATH, the source tree TeXmacs was configured from (empty for the Windows builds);

  3. for paths in

    TeXmacs/

    , finally the installed $TEXMACS_PATH, so that the Scheme files, styles and packages can be opened from any installation.

The file is then opened with the tool chosen in Developer\(\rightarrow\)Open source links with (preference developer:source editor): TeXmacs itself, at the given line; the default application of the system; a predefined editor (Visual Studio Code, Emacs, Xcode, Sublime Text, Zed); or any command line, in which %f is replaced by the quoted file name and %l by the line (1 when no line is given). The same menu sets the source directory, which is needed for binary installations. The Developer menu appears once Tools\(\rightarrow\)Developer tool is checked.

The links are checked by

tests/docs/source-links.py

, which reports every source-link whose file is no longer in the repository, and every verbatim which names exactly one file (or one directory) of the repository and could be a link; with --convert it turns the latter into links. A name is matched by the end of the paths, so Plugins/Qt/qt_gui.cpp and qt_gui.cpp both work; a name starting with src/ is read from the root of the repository. Names without a / are only considered for source files (.cpp, .scm, .m4, …). Names which match several files or directories are left alone (write more of the path), as are generated files, files of other branches and files of the user's home directory, which stay in verbatim.

3.Encoding

.tm files are not UTF-8 files: strings are stored in the Cork encoding of TeXmacs, with escapes for everything else. When documentation is written or edited outside TeXmacs, the file should contain only ASCII characters:

A raw UTF-8 character in a .tm file is read as several Cork characters and shows up as garbage. A quick check is to search the file for bytes above 127, for instance with LC_ALL=C grep -nP '[\x80-\xff]' file.

4.Validation

Before committing new pages, it is useful to check that

  1. every tag used is defined. A tag which is not defined by the style is shown in red in the editor and silently passes through conversions. A simple check is to compare the tags used in the new files with those used in the existing documentation;

  2. every relative link points to an existing file, and

    tests/docs/source-links.py

    reports no broken source links;

  3. every page can be typeset. This can be done without opening windows, by converting each page to PDF in headless mode:

    TEXMACS_PATH=worktree/src/TeXmacs \
    TEXMACS_HOME_PATH=private-home QT_QPA_PLATFORM=offscreen \
    texmacs.bin -headless -c page.en.tm page.pdf -q

    A private TEXMACS_HOME_PATH keeps the test from changing the user's preferences and caches, and allows several conversions to run in parallel;

  4. the whole hierarchy expands: loading tmfs://help/book/… for the root page (as Help\(\rightarrow\)Full manuals does) should give a document which contains the label sec-name of every new page, and the console should show no bad link or file message.

5.Pitfalls and known problems

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".