Scribble Cheatsheet
@title[#:tag "scribble-cheatsheet"]{Scribble Cheatsheet}
@author{a11ce}
@author[(author+email "Dr. Racket-Emailhaver" "dontemailme@racket-lang.org")]
1 Section Header
@section{Section Header}
1.1 Subsection Header
@subsection{Subsection Header}
1.1.1 Subsubsection header
@subsubsection{Subsubsection header}
@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
(require racket/positronics) | package: base |
@defmodule[racket/positronics]
racketblocks require S-expressions and normalize terms (including formatting).
@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
@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.
2.5 Others
Use defthing to describe non-procedure identifiers.
value
horse : animal?
@defthing[horse animal?]{ Everyone knows what a horse is. }
3 Formatting
Margin note (not actually in the margin)
@margin-note{Margin note (not actually in the margin)}
@margin-note*{Margin note* (actually in the margin)}
@italic{Italic}
@bold{Bold}
More: subscript, subscript, larger, smaller.
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 }
@tech{technical term}