From 3c4cf9de5d455b9caa8722d05cf2dd4ff5da8c84 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Sat, 18 Jun 2016 22:28:11 -0400 Subject: [PATCH] add documentation --- hygienic-reader-extension/info.rkt | 5 +++ .../hygienic-reader-extension.scrbl | 42 +++++++++++++++++++ info.rkt | 5 +++ 3 files changed, 52 insertions(+) create mode 100644 hygienic-reader-extension/info.rkt create mode 100644 hygienic-reader-extension/scribblings/hygienic-reader-extension.scrbl diff --git a/hygienic-reader-extension/info.rkt b/hygienic-reader-extension/info.rkt new file mode 100644 index 0000000..6fa8cc9 --- /dev/null +++ b/hygienic-reader-extension/info.rkt @@ -0,0 +1,5 @@ +#lang info + +(define scribblings + '(["scribblings/hygienic-reader-extension.scrbl" ()])) + diff --git a/hygienic-reader-extension/scribblings/hygienic-reader-extension.scrbl b/hygienic-reader-extension/scribblings/hygienic-reader-extension.scrbl new file mode 100644 index 0000000..91e1be1 --- /dev/null +++ b/hygienic-reader-extension/scribblings/hygienic-reader-extension.scrbl @@ -0,0 +1,42 @@ +#lang scribble/manual + +@(require (for-label racket/base + racket/contract/base + hygienic-reader-extension/extend-reader + )) + +@title{Making reader extensions hygienic} + +source code: @url{https://github.com/AlexKnauth/hygienic-reader-extension} + +@defmodule[hygienic-reader-extension/extend-reader] + +@defproc[(extend-reader + [reader-proc (-> A ... any/c)] + [extend-readtable (-> readtable? #:outer-scope (-> syntax? syntax?) readtable?)]) + (-> A ... any/c)]{ +Extends the given @racket[reader-proc] by making a function that calls +it with the @racket[current-readtable] parameter extended with the +result of calling @racket[extend-readtable] function. + +In addition to a readtable, it passes an @racket[outer-scope] argument +to the @racket[extend-readtable] function, which that function can +pass into the readtable procedures it adds. Those readtable procedures +should use the @racket[hygienic-app] function to transform any input +syntax objects into the output syntax object. +} + +@defproc[(hygienic-app [proc (-> syntax? syntax?)] + [stx syntax?] + [#:outer-scope outer-scope (-> syntax? syntax?)]) + syntax?]{ +Applies @racket[proc] to @racket[stx], but with extra scopes added to +the input and output to make it hygienic. + +This is meant to be used within a readtable procedure added by the +@racket[extend-readtable] argument to the @racket[extend-reader] +function. The @racket[outer-scope] argument should come from the +@racket[outer-scope] argument passed to that @racket[extend-readtable] +function. +} + diff --git a/info.rkt b/info.rkt index 37d03b4..2e4367e 100644 --- a/info.rkt +++ b/info.rkt @@ -6,3 +6,8 @@ '("base" )) +(define build-deps + '("scribble-lib" + "racket-doc" + )) +