#lang scribble/doc @(require "common.ss") @title{Document Modules} Like all PLT Scheme programs, Scribble documents are organized into modules, each in its own file. A @hash-lang[] line starts a module, and most PLT Scheme modules start with @code-elem{#lang scheme} or @code-elem{#lang scheme/base}. A Scribble document normally starts with @code-elem{#lang scribble/doc} to use a prose-oriented notation with @lit["@"] syntax, but a Scribble document can be written in any notation and using any helper functions and syntax, as long as it exports a @schemeidfont{doc} binding whose value is an instance of the Scribble @scheme[part] structure type. For example, @; @code-block|{ #lang scheme (require scribble/decode) (define doc (decode '("Hello, world!"))) (provide doc) }| @; implements in Scheme notation a Scribble document that contains only the text ``Hello, world!'' Larger documents are typically split across modules/files along section boundaries. Subsections are incorporated into a larger section using the @scheme[include-section] form, which expands to a @scheme[require] to import the sub-section module and an expression that produces the @scheme[doc] part exported by the module. Since document inclusion corresponds to module importing, all of the usual PLT Scheme tools for building and executing modules apply to Scribble documents. When a large document source is split into multiple modules, most of the modules need the same basic typesetting functions as well as the same ``standard'' bindings for examples. In Scribble, both sets of bindings can be packaged together; since @scheme[for-label] declarations build on the module system's import mechanisms, they work with the module system's re-exporting mechanisms. For example, the documentation for a library that builds on the @schememodname[scheme/base] library might use this @filepath{common.ss} library: @; @code-block{ #lang scheme/base (require scribble/manual (for-label lang/htdp-beginner)) (provide (all-from-out scribble/manual) (for-label (all-from-out lang/htdp-beginner))) } @; Then, each part of the document can be implemented as @; @code-block|{ #lang scribble/doc @(require "common.ss") .... }| @; instead of separately requiring @schememodname[scribble/manual] and @schememodname[(for-label lang/htdp-beginner)] in every file.