documentation more consistent
This commit is contained in:
+12
-12
@@ -3,7 +3,7 @@
|
||||
@(require (for-label racket/base
|
||||
"../private/js-transform.rkt"))
|
||||
|
||||
@title{JavaScript Transformation}
|
||||
@title[#:tag "js-transform"]{JavaScript Transformation}
|
||||
@author[@author+email["Hans Dijkema" "hans@dijkewijk.nl"]]
|
||||
|
||||
@defmodule[racket-webview/private/js-transform]
|
||||
@@ -47,7 +47,7 @@ This generates JavaScript source that assigns a function to
|
||||
sets an attribute, and writes a message to the JavaScript console.
|
||||
}
|
||||
|
||||
@section{Primitive values}
|
||||
@section[#:tag "js-transform-primitive-values"]{Primitive values}
|
||||
|
||||
Numbers are emitted as JavaScript numeric literals. Strings are emitted as
|
||||
double-quoted JavaScript strings, with embedded double quotes escaped.
|
||||
@@ -68,7 +68,7 @@ Symbols can be quoted to produce JavaScript string values:
|
||||
(send console log 'hello))
|
||||
]
|
||||
|
||||
@section{Function calls and method calls}
|
||||
@section[#:tag "js-transform-function-calls-and-method-calls"]{Function calls and method calls}
|
||||
|
||||
A form that is not recognized as a special DSL form is treated as a JavaScript
|
||||
function call:
|
||||
@@ -109,7 +109,7 @@ document.getElementById("hi")
|
||||
Using @racket[send] keeps the method-call structure explicit in the DSL. It is
|
||||
usually clearer than writing dotted JavaScript names directly as function names.
|
||||
|
||||
@section{Operators}
|
||||
@section[#:tag "js-transform-operators"]{Operators}
|
||||
|
||||
The DSL supports a small set of JavaScript infix operators.
|
||||
|
||||
@@ -138,7 +138,7 @@ For example:
|
||||
(return (* x x)))))
|
||||
]
|
||||
|
||||
@section{Definitions and assignments}
|
||||
@section[#:tag "js-transform-definitions-and-assignments"]{Definitions and assignments}
|
||||
|
||||
@defform[(define (name arg ...) body ...)]{
|
||||
|
||||
@@ -165,7 +165,7 @@ Generates a JavaScript assignment.
|
||||
This produces an assignment to @tt{window.answer}.
|
||||
}
|
||||
|
||||
@section{Functions}
|
||||
@section[#:tag "js-transform-functions"]{Functions}
|
||||
|
||||
@defform[(lambda (arg ...) body ...)]{
|
||||
Generates a JavaScript function expression.
|
||||
@@ -194,7 +194,7 @@ A function body may contain more than one DSL statement:
|
||||
(return (* x x)))))
|
||||
]
|
||||
|
||||
@section{Control flow and statement blocks}
|
||||
@section[#:tag "js-transform-control-flow-and-statement-blocks"]{Control flow and statement blocks}
|
||||
|
||||
@defform[(if condition then-expr else-expr)]{
|
||||
|
||||
@@ -236,7 +236,7 @@ Generates a JavaScript @tt{return} statement.
|
||||
]
|
||||
}
|
||||
|
||||
@section{Sequential bindings}
|
||||
@section[#:tag "js-transform-sequential-bindings"]{Sequential bindings}
|
||||
|
||||
@defform[(let* ((id expr) ...) body ...)]{
|
||||
|
||||
@@ -256,7 +256,7 @@ context. Use @racket[let*] instead, so that the generated JavaScript bindings
|
||||
remain explicitly sequential.
|
||||
}
|
||||
|
||||
@section{Lists}
|
||||
@section[#:tag "js-transform-lists"]{Lists}
|
||||
|
||||
@defform[(list expr ...)]{
|
||||
|
||||
@@ -287,7 +287,7 @@ console.log([ x].concat([ y].concat([ z])));
|
||||
}|
|
||||
}
|
||||
|
||||
@section{Embedding Racket values}
|
||||
@section[#:tag "js-transform-embedding-racket-values"]{Embedding Racket values}
|
||||
|
||||
@defform[(eval value)]{
|
||||
|
||||
@@ -306,7 +306,7 @@ The value is converted to JavaScript source text before the generated JavaScript
|
||||
is returned.
|
||||
}
|
||||
|
||||
@section{Example}
|
||||
@section[#:tag "js-transform-example"]{Example}
|
||||
|
||||
The following example combines function definition, method calls, list
|
||||
construction, sequential bindings and a lambda expression passed to a JavaScript
|
||||
@@ -327,7 +327,7 @@ method:
|
||||
This generates a JavaScript function that logs an array, constructs the same
|
||||
array in a local binding, maps over it, and returns the mapped result.
|
||||
|
||||
@section{Limitations}
|
||||
@section[#:tag "js-transform-limitations"]{Limitations}
|
||||
|
||||
This transformer is intentionally small. It is not a complete JavaScript
|
||||
parser, not a JavaScript evaluator and not a general Racket-to-JavaScript
|
||||
|
||||
Reference in New Issue
Block a user