Scribble Cheatsheet
1 Section Header
1.1 Subsection Header
1.1.1 Subsubsection header
2 Documenting code
2.1 Modules
2.2 #langs
2.3 Procedures and Forms
2.3.1 Procedures
2.4 Syntax
2.5 Others
3 Formatting
4 Links
8.12

Scribble Cheatsheet🔗ℹ

a11ce


Dr. Racket-Emailhaver <dontemailme@racket-lang.org>

@title[#:tag "scribble-cheatsheet"]{Scribble Cheatsheet}

@author{a11ce}

@author[(author+email "Dr. Racket-Emailhaver" "dontemailme@racket-lang.org")]

    1 Section Header

      1.1 Subsection Header

        1.1.1 Subsubsection header

    2 Documenting code

      2.1 Modules

      2.2 #langs

      2.3 Procedures and Forms

        2.3.1 Procedures

      2.4 Syntax

      2.5 Others

    3 Formatting

    4 Links

1 Section Header🔗ℹ

@section{Section Header}

1.1 Subsection Header🔗ℹ

@subsection{Subsection Header}
1.1.1 Subsubsection header🔗ℹ
@subsubsection{Subsubsection header}

Non-numbered header (doesn’t show up in table of contents)
@subsubsub*section{Non-numbered header (doesn't show up in table of contents)}

2 Documenting code🔗ℹ

Remember that {} converts to a string and [] doesn’t.

2.1 Modules🔗ℹ

@defmodule[racket/positronics]

racketblocks require S-expressions and normalize terms (including formatting).

(map (λ (x) (+ 1 x)) '(1 1/2 3 4 5))

@racketblock[
(map
(λ (x)
(+ 1 x)) '(1 2/4
3 4 5))
]

2.2 #langs🔗ℹ

@defmodulelang[mechanized-loom]

codeblocks typeset verbatim, allow non-S-expression syntax, and don’t normalize terms.

#lang scribble/manual
@italic{me
ow}
@codeblock|{
#lang scribble/manual
@italic{me
ow}
}|

2.3 Procedures and Forms🔗ℹ

Names defined with defproc, defform, or defthing will be linked to from within rackets.

2.3.1 Procedures🔗ℹ

default is procedure

(proc-name arg ... [#:kwarg kwarg-val])  result-type

  arg : arg/c
  kwarg-val : kwarg/c = default
Within this block, things like arg will be typeset to match the definition (but will error within code).
@defproc[#:kind "default is procedure"
         (proc-name [arg arg/c] ...
                    [#:kwarg kwarg-val kwarg/c default])
                    result-type]{
Within this block, things like @racket[arg] will be typeset to match
the definition (but will error within @code{code}).
}

Use defproc* to describe related procedures or procedures with multiple calling cases.

procedure

(multi-proc)  result-type-one

(multi-proc arg)  result-type-two
  arg : arg/c
@defproc*[([(multi-proc) result-type-one]
           [(multi-proc (arg arg/c)) result-type-two])]

2.4 Syntax🔗ℹ

defform can specify which identifier it’s defining, typeset literals, or include a grammar.

default is syntax

(something-special form-name math)

 
math = (op num num)
     
op = plus
  | minus
@defform[#:kind "default is syntax"
         #:id form-name
         #:literals (define)
         (something-special form-name math)
         #:grammar
         [(math (op num num))
          (op plus
              minus)]]

Use defform* for multiple forms using the same identifier.

syntax

(define (proc-name arg ...) body ...+)

(define var-name body)
@defform*[((define (proc-name arg ...) body ...+)
           (define var-name body))]

2.5 Others🔗ℹ

Use defthing to describe non-procedure identifiers.

value

horse : animal?

Everyone knows what a horse is.
@defthing[horse animal?]{
Everyone knows what a horse is.
}

Use deftech to define vocabulary and tech to link to it.

A technical term is a term that is technical. An example of a technical term is number.
A @deftech{technical term} is a term that is technical.
An example of a @tech{technical term} is
@tech[#:doc '(lib "scribblings/guide/guide.scrbl")]{number}.

3 Formatting🔗ℹ

Margin note (not actually in the margin)

@margin-note{Margin note (not actually in the margin)}

Margin note* (actually in the margin)
@margin-note*{Margin note* (actually in the margin)}

Italic
@italic{Italic}
Bold
@bold{Bold}
woah nesting
@italic{@bold{woah nesting}}

More: subscript, subscript, larger, smaller.

AAAAAAAAAAAA
@larger{AAA@larger{AAA@larger{AAA@larger{AAA}}}}

4 Links🔗ℹ

@link["https://racket-lang.org"]{normal link}

@seclink["scribble-cheatsheet"]{back to top (section link within the same module)}

@seclink["first-example" #:doc '(lib "scribblings/scribble/scribble.scrbl")]{
use @racket[#:doc] to link somewhere else
}

secref is like seclink but you can’t change the text: A First Example
@secref["first-example" #:doc '(lib "scribblings/scribble/scribble.scrbl")]

tech links to a term defined with deftech: technical term
@tech{technical term}

other-doc links to the top of a document: Scribble: The Racket Documentation Tool
@other-doc['(lib "scribblings/scribble/scribble.scrbl")]