diff --git a/day1/main.scrbl b/day1/main.scrbl index 84169d8..a8cae2d 100644 --- a/day1/main.scrbl +++ b/day1/main.scrbl @@ -1,9 +1,18 @@ #lang scribble/lp2 -@(require scribble/manual "../helper.rkt") +@(require scribble/manual aoc-racket/helper) @aoc-title[1] -Our @(input) is a string of parentheses that controls an elevator. A left parenthesis @litchar{(} means go up one floor, and a right parenthesis @litchar{)} means go down. +Our @link-rp["day1/input.txt"]{input} is a string of parentheses that controls an elevator. A left parenthesis @litchar{(} means go up one floor, and a right parenthesis @litchar{)} means go down. + +@chunk[ + + + + + + ] + @section{Where does the elevator land?} @@ -108,13 +117,4 @@ The two are similar. The choice comes down to readability and efficiency — me (check-equal? (q2-for/first input-str) 1795) (check-equal? (q2-for/or input-str) 1795))] -@section{Joining the parts} - -@chunk[<*> - - - - - - ] diff --git a/helper.rkt b/helper.rkt index d92bcd6..745b12b 100644 --- a/helper.rkt +++ b/helper.rkt @@ -1,10 +1,18 @@ #lang at-exp racket/base (require scribble/manual) (provide (all-defined-out)) +(require (for-syntax racket/base racket/syntax) racket/runtime-path) +(provide (for-syntax #%datum)) (define (aoc-title which) (define which-str (number->string which)) -@title[#:style manual-doc-style]{@link[@string-append["http://adventofcode.com/day/" @which-str]]{Day @which-str}}) + @title[#:style manual-doc-style]{@link[@string-append["http://adventofcode.com/day/" @which-str]]{Day @which-str}}) -(define (input) - @link["input.txt"]{input}) \ No newline at end of file +(define-syntax (link-rp stx) + (syntax-case stx () + [(_ where text-args ...) + (with-syntax ([rp-name (generate-temporary)]) + #'(begin + (require racket/runtime-path) + (define-runtime-path rp-name (expand-user-path where)) + @(link (path->string rp-name) text-args ...)))])) \ No newline at end of file