![]() |
Help files, the help browser and expansion into books | ![]() |
At startup, TEXMACS_DOC_PATH is set to its value from the environment (if any), followed by $TEXMACS_HOME_PATH/doc, $TEXMACS_PATH/doc and the doc directories of all plug-ins (
src/src/System/Boot/init_texmacs.cpp
, see boot paths). Users can therefore add or override pages in their home directory, and plug-ins ship their own documentation.
The routines of
progs/doc/help-funcs.scm
work with names relative to this path:
Tests whether a file (given with its language suffix, for instance "devel/devel.en.tm") exists somewhere in the help path. The Help menu uses it to show only the entries whose documentation is installed. The answer is cached for the whole session.
(internal) Finds the file for a name without suffix: first name.xx.tmml, then name.xx.tm, where xx is the two letter code of the output language, and finally name.en.tm. A name which already ends in .tm or .tex and exists is used as is.
The title of a help file (the first title, doc-title, tmdoc-title or tmweb-title), cached and re-read when the file changes; used for the result lists of searches.
load-help-buffer, load-help-article and load-help-book resolve a name with url-resolve-help (showing an error message if there is none) and open it as a page of type normal, article and book respectively. The first two go through tmdoc-expand-help, which turns the file name into tmfs://help/type/file and loads that URL; books go through tmdoc-expand-help-manual, described below. Help menus normally use load-help-article for single chapters and load-help-buffer for the Browse entries, so that the latter show the page itself, with its list of branches. load-help-online is meant to open a page of the online documentation below https://www.texmacs.org/tmbrowse; since it passes that URL to load-help-buffer, which looks names up relative to the help path, it probably does not work (not tested). Finally, update-help-online downloads an archive of the documentation into $TEXMACS_HOME_PATH with wget from an ftp address.
The tmfs://help/ handler itself (types, conversions of HTML and TMML files, the page shown for a missing file, the title Help - title) is described in the TeXmacs file system handlers. Help buffers are read only.
For all types except normal, the handler calls tmdoc-expand (
progs/doc/tmdoc.scm
), which loads the file and rewrites its body:
becomes a sectional heading of the current level, followed by a label sec-name, where name is the base name of the file without language and suffix (for instance sec-server-buffers for server-buffers.en.tm). At the top of a book the level is title and the title becomes the title of the book.
(section, subsection, subsubsection, paragraph, subparagraph and their starred variants) are taken relative to the level of the page: a section becomes the level just below the heading of the page, a subsection the level below that, and so on (tmdoc-demote). In a page which becomes a chapter, sections thus stay sections; in a page which becomes a section, they become subsections. Pages without sectioning commands, like most pages of the user manual, are not affected.
(a heading such as Contents of this chapter which is followed by a traverse before any other heading) is removed, since the expanded branches become its siblings and it would remain empty; the text between the heading and the traverse is kept.
consists of the headings which come before its traverse, typically Introduction, Overview and Source files. A heading which directly follows the title is removed, so that its text opens the chapter (or section, …) of the page; the other ones become unnumbered headings without entry in the table of contents (tmdoc-mark-opening). The numbered divisions of the page are thus exactly its branches. In the help browser, where pages are shown one by one, the headings are unchanged.
is replaced by the expansion of its branches.
expands the target one level deeper, according to the table of tmdoc-down: title and part give chapter, chapter gives section, then subsection, subsubsection, paragraph and finally subparagraph for all deeper levels. The level of the root page of an article is tmdoc-title, so its branches become sections. A deeply nested book may start with parts instead of chapters: if the initial environment of its root file sets tmdoc-book-parts to true, the root level is title*, whose branches become parts. The developer guide (
devel/source/source.en.tm
) and the whole developer documentation (
devel/devel.en.tm
) use this.
expands the target at the same level and drops its title, so that a long page can be split into several files.
expands the target as an appendix.
are removed.
are rebased: their targets, which are relative to the file they appear in, are made relative to the root file (tmdoc-substitute).
Target names are resolved with tmdoc-relative, which follows the same rules as the tmdoc-file macro (the file itself, the translation for the current language, the English file). A table of the files already expanded makes sure that each file is included only once, even if several pages branch to it; a file which cannot be read is replaced by an empty paragraph and a message bad link or file on the console.
For the type article (and any other type except normal and book), the expanded body is put in a document with the tmdoc style and the language of the root file. Links stay external.
For the type book, three more steps follow:
tmdoc-internalize collects all labels of the expanded document and turns every hyperlink whose target is part of the book (through its label sec-name or an explicit #label) into an internal link. Hyperlinks to targets outside the book are replaced by their text.
tmdoc-add-aux inserts a table of contents after the title, a bibliography if the document contains citations, and an index at the end; a chapter called Preface becomes unnumbered.
The style is the one given by the preference manual style (default tmmanual) and the page medium is paper.
tmdoc-expand-help-manual then runs generate-all-aux and updates the buffer three times, so that the table of contents, the index and the references settle, and finally marks the buffer as saved. tmdoc-expand-this does the same for the current buffer; it is behind Help\(\rightarrow\)Full manuals\(\rightarrow\)Compile article and Compile book, which appear when the current document uses tmdoc. For Mathemagix documentation it switches the result to the mmxmanual style. The Full manuals menu also contains ready-made entries for the user manual, the source code documentation and the Scheme developer guide.
The command line option -build-manual file calls build-manual (
progs/utils/test/test-convert.scm
). The file name has the form dir/name.xx.pdf; name must be one of texmacs-user-manual, texmacs-reference-manual and texmacs-scheme-manual, which select main/man-manual, main/man-reference and devel/scheme/scheme. The manual is expanded as a book in the language xx (switching the output language if needed) and exported to PDF. Other names are silently ignored, and an existing PDF file is not rebuilt. Note also that in headless mode the automatic quit-TeXmacs runs before this command unless -X is given (see startup commands).