On this page:
8.1 Extra and Format-Specific Files
8.2 Handling Cross-References

8 Running scribble

The scribble command-line tool (also available as raco scribble) runs a Scribble document and renders it to a specific format. Select a format with one of the following flags, where the output name fn is by default the document source name without its file suffix:

Use --dest-name to specify a fn other than the default name, but only when a single source file is provided. Use the --dest flag to specify a destination directory (for any number of source files). Use --dest-base to add a prefix to the name of each support file that is generated or copied to the destination.

After all flags, provide one or more document sources, where each source declares a module. The module should either have a doc submodule that exports doc as a part, or it should directly export doc as a part. (The submodule is tried first, and the main module is not directly loaded or evaluated if the submodule can be loaded on its own.)

When multiple documents are rendered at the same time, cross-reference information in one document is visible to the other documents. See Handling Cross-References for information on references that cross documents that are built separately.

8.1 Extra and Format-Specific Files

Use the --style flag to specify a format-specific file to adjust the output style file for certain formats. For HTML (single-page or multi-page) output, the style file should be a CSS file that is applied after all other CSS files, and that may therefore override some style properties. For Latex (or PDF) output, the style file should be a ".tex" file that can redefine Latex commands. When a particular Scribble function needs particular CSS or Latex support, however, a better option is to use a css-addition or tex-addition style property so that the support is included automatically; see Extending and Configuring Scribble Output for more information.

In rare cases, use the --style flag to specify a format-specific base style file. For HTML (single-page or multi-page) output, the style file should be a CSS file to substitute for "scribble.css" in the "scribble" collection. For Latex (or PDF) output, the style file should be a ".tex" file to substitute for "scribble.tex" in the "scribble" collection. The --style flag is rarely useful, because the content of "scribble.css" or "scribble.tex" is weakly specified; replacements must define all of the same styles, and the set of styles can change across versions of Racket.

Use --prefix to specify an alternate format-specific start of the output file. For HTML output, the starting file specifies the DOCTYPE declaration of each output HTML file as a substitute for "scribble-prefix.html" in the "scribble" collection. For Latex (or PDF) output (but not Latex-section output), the starting file specifies the \documentclass declaration and initial \usepackage declarations as a substitute for "scribble-prefix.tex" in the "scribble" collection. See also html-defaults, latex-defaults, and Extending and Configuring Scribble Output.

For any output form, use the ++extra flag to add a needed file to the build destination, such as an image file that is referenced in the generated output but not included via image (which copies the file automatically).

8.2 Handling Cross-References

Cross references within a document or documents rendered together are always resolved. When cross references span documents that are rendered separately, cross-reference information needs to be saved and loaded explicitly. Cross-reference information is format-specific, but HTML-format information is usable for Latex (or PDF) or text rendering.

A Racket installation includes HTML-format cross-reference information for all installed documentation. Each document’s information is in a separate file, so that loading all relevant files would be tedious. The +m or ++main-xref-in flag loads cross-reference information for all installed documentation, so

  scribble +m mine.scrbl

renders "mine.scrbl" to "mine.html" with cross-reference links to the Racket installation’s documentation. (The "racket-index" package must be installed to use +m/++main-xref-in.)

The ++xref-in flag loads cross-reference information by calling a specified module’s function. The setup/xref module provides load-collections-xref to load cross-reference information for all installed documentation, and +m or ++main-xref-in is just a shorthand for ++xref-in setup/xref load-collections-xref.

The --redirect-main flag for HTML output redirects links to the local installation’s documentation to a given URL, such as http://docs.racket-lang.org/. Beware that documentation links sometimes change (although Scribble generates HTML paths and anchors in a relatively stable way), so http://download.racket-lang.org/docs/version/html/ may be more reliable when building with an installation for version. The --redirect-main flag is ignored for non-HTML output.

The --redirect flag is like --redirect-main, except that it builds on the given URL to indicate a cross-reference tag that is more stable than an HTML path and anchor (in case the documentation for a function changes sections, for example). No server currently exists to serve such tag requests, however.

For cross-references among documentation that is not part of the Racket installation, use --info-out to save information from a document build and use ++info-in to load previously saved information. For example, if "c.scrbl" refers to information in "a.scrbl" and "b.scrbl", then

  scribble --info-out a.sxref a.scrbl
  scribble --info-out b.sxref b.scrbl
  scribble ++info-in a.sxref ++info-in b.sxref c.scrbl

builds "c.html" with cross-reference links into "a.html" and "b.html".