working a little on the documentation

This commit is contained in:
Danny Yoo 2011-07-28 13:29:24 -04:00
parent 3add8633e3
commit ab55c29540
3 changed files with 114 additions and 48 deletions

View File

@ -46,4 +46,4 @@ test-more:
doc:
racket make-last-commit-name.rkt
scribble ++xref-in setup/xref load-collections-xref --redirect-main http://docs.racket-lang.org/ --dest generated-docs --dest-name index.html scribblings/manual.scrbl
scribble ++xref-in setup/xref load-collections-xref --redirect-main http://docs.racket-lang.org/ --dest generated-docs --dest-name index.html scribblings/manual.scrbl

View File

@ -1067,6 +1067,43 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
var firstArg = checkString(MACHINE, 'string-length', 0).toString();
return firstArg.length;
});
installPrimitiveProcedure(
'string?',
1,
function(MACHINE) {
return isString(MACHINE.env[MACHINE.env.length - 1]);
});
installPrimitiveProcedure(
'number->string',
1,
function(MACHINE) {
return checkNumber(MACHINE, 'number->string', 0).toString();
});
installPrimitiveProcedure(
'string->symbol',
1,
function(MACHINE) {
return makeSymbol(checkString(MACHINE, 'string->symbol', 0).toString());
});
installPrimitiveProcedure(
'string->number',
1,
function(MACHINE) {
return plt.baselib.numbers.fromString(
checkString(MACHINE, 'string->number', 0).toString());
});
installPrimitiveProcedure(
'box',
@ -1351,14 +1388,6 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
checkNumber(MACHINE, 'expt', 1));
});
installPrimitiveProcedure(
'string?',
1,
function(MACHINE) {
return isString(MACHINE.env[MACHINE.env.length - 1]);
});
installPrimitiveProcedure(
'exact?',
1,
@ -1552,30 +1581,6 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
});
installPrimitiveProcedure(
'number->string',
1,
function(MACHINE) {
return checkNumber(MACHINE, 'number->string', 0).toString();
});
installPrimitiveProcedure(
'string->symbol',
1,
function(MACHINE) {
return makeSymbol(checkString(MACHINE, 'string->symbol', 0).toString());
});
installPrimitiveProcedure(
'string->number',
1,
function(MACHINE) {
return plt.baselib.numbers.fromString(
checkString(MACHINE, 'string->number', 0).toString());
});
installPrimitiveClosure(

View File

@ -347,6 +347,82 @@ Replacing the @racket[10000] with @racket["one-billion-dollars"] should
reliably produce a proper error message.
@section{Using @tt{whalesong}}
Whalesong provides a command-line utility called @tt{whalesong} for
translating Racket to JavaScript. It can be run in several modes:
@itemize[
@item{To create standalone XHTML documents}
@item{To output the compiled JavaScript as a single @filepath{.js} file}
@item{To output the compiled JavaScript as several @filepath{.js} files, one per module. (this isn't done yet...)}
]
Using @tt{whalesong} to generate standalone XHTML documents is
relatively straightforward with the @tt{build} command. To use it,
pass the name of the file to it:
@verbatim|{
$ whalesong build [name-of-racket-file]
}|
An @filepath{.xhtml} will be written to the current directory.
Almost all of the @tt{whalesong} commands support two command line options:
@itemize{
@item{@tt{--compress-javascript}: Use Google Closure's JavaScript
compiler to significantly compress the JavaScript. Using this
currently requires a Java 1.6 JDK.}
@item{@tt{--verbose}: write verbose debugging information to standard error.}
}
For more advanced users, @tt{whalesong} can be used to generate
JavaScript in non-standalone mode. This gives the web developer more
fine-grained control over how to control and deploy the outputted
program.
@subsection{@tt{build}}
Given the name of a program, this builds a standalone @filepath{.xhtml} file that
executes the program in a web browser. The @filepath{.xhtml} should
be completely self-contained.
@subsection{@tt{get-javascript}}
Given the name of a program, writes the JavaScript to standard output,
as well as its dependent modules. The outputted file is meant to be
used as a @tt{SCRIPT} source.
By default, the given program will be treated as a @emph{main} module.
All main modules will be executed when the JavaScript function
@tt{plt.runtime.invokeMains()} is called.
@subsection{@tt{write-javascript-files}}
[NOT DONE YET]
(needs to write a MANIFEST file?)
(this almost seems like we need some concept of a JAR... )
@subsection{@tt{get-runtime}}
Prints out the core runtime library that the files generated by
get-javascript depend on.
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@section{Reference}
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -355,21 +431,6 @@ reliably produce a proper error message.
@subsection{The @filepath{whalesong} command-line}
(This section should describe the whalesong launcher and the options
we can use.)
(We want to add JavaScript compression here as an option.)
(We also need an example that shows how to use the get-javascript and get-runtime
commands to do something interesting...)
@subsection{@tt{build}}
@subsection{@tt{get-runtime}}
@subsection{@tt{get-javascript}}