www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit e3dd74b99e7f8da74d91244fc6203e0b412106f9
parent 6b38ab6f69b1927a6c070c1c6074972048a251eb
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Tue, 21 Mar 2017 23:07:05 +0100

Improved a bit the front page in the PDF version, show the document version in the "version" text that scribble already inserts at the top.

Diffstat:
Mscribblings/phc-thesis.scrbl | 44+++-----------------------------------------
Mscribblings/state-of-the-art.scrbl | 3++-
Mscribblings/util.rkt | 60+++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 62 insertions(+), 45 deletions(-)

diff --git a/scribblings/phc-thesis.scrbl b/scribblings/phc-thesis.scrbl @@ -7,49 +7,11 @@ racket/string] @(use-mathjax) -@title[#:style (with-html5 manual-doc-style)]{Thesis} +@title[#:style (with-html5 manual-doc-style) + #:version (version-text)]{Thesis} @author[@author+email["Georges Dupéron" "georges.duperon@gmail.com"]] -@(with-handlers ([(λ (e) (eq? e 'git-failure)) - (λ (e) - ;; unknown version (for now, just put the empty string). - "")]) - (define stderr (open-output-string)) - (define result - (parameterize ([current-error-port stderr] - [current-input-port (open-input-string "")]) - (list - "Document version: " - (tt - (string-trim - (with-output-to-string - (λ () - (let ([git (find-executable-path "git")]) - (unless (system* git "show" "-s" "--date=short" "--format=%cd" - "HEAD") - (raise 'git-failure)))))) - "-" "-" - (string-trim - (with-output-to-string - (λ () - (let ([git (find-executable-path "git")]) - (unless (system* git "rev-parse" "--short" "HEAD") - (raise 'git-failure)))))) - (if (non-empty-string? - (string-trim - (with-output-to-string - (λ () - (let ([git (find-executable-path "git")]) - (unless (system* git "diff" "--shortstat") - (raise 'git-failure))))))) - "x" - "")) - "."))) - (if (non-empty-string? (get-output-string stderr)) - (begin (displayln (get-output-string stderr)) - (raise 'git-failure)) - result)) - +@;@(version-text "Document version: " ".") @(cond-element [html (list "Download a " diff --git a/scribblings/state-of-the-art.scrbl b/scribblings/state-of-the-art.scrbl @@ -3,7 +3,8 @@ @require["util.rkt"] @(use-mathjax) -@title[#:style (with-html5 manual-doc-style)]{State of the art} +@title[#:style (with-html5 manual-doc-style) + #:version (version-text)]{State of the art} @asection{ @atitle{Extending the type system via macros (type-expander)} diff --git a/scribblings/util.rkt b/scribblings/util.rkt @@ -1,6 +1,7 @@ #lang racket (provide (rename-out [my-title title]) + (rename-out [my-author+email author+email]) asection atitle aquote @@ -13,7 +14,8 @@ (rename-out [note* note]) define-footnote ;; TODO: does not use the (superscript …) (all-from-out "abbreviations.rkt") - (all-from-out scribble-math)) + (all-from-out scribble-math) + version-text) (require racket/stxparam racket/splicing @@ -31,12 +33,64 @@ (use-mathjax) (define (tex-header tex) - (elem #:style (style #f (list (tex-addition tex))))) + (elem #:style (style #f (list (tex-addition (string->bytes/utf-8 tex)))))) + +(define (my-author+email author email) + (cond-element + [html (author+email author email)] + ;; TODO: urlencode the email maybe? + [latex (list (hyperlink (string-append "mailto:" email) author) + (note (hyperlink (string-append "mailto:" email) email)))] + [else (author+email author email)] + )) + +(define (version-text [prefix ""] [postfix ""]) + (with-handlers ([(λ (e) (eq? e 'git-failure)) + (λ (e) + ;; unknown version (for now, just put the empty string). + "")]) + (define stderr (open-output-string)) + (define result + (parameterize ([current-error-port stderr] + [current-input-port (open-input-string "")]) + (string-append + prefix + ;(tt + (string-trim + (with-output-to-string + (λ () + (let ([git (find-executable-path "git")]) + (unless (system* git "show" "-s" "--date=short" "--format=%cd" + "HEAD") + (raise 'git-failure)))))) + "-" "-" + (string-trim + (with-output-to-string + (λ () + (let ([git (find-executable-path "git")]) + (unless (system* git "rev-parse" "--short" "HEAD") + (raise 'git-failure)))))) + (if (non-empty-string? + (string-trim + (with-output-to-string + (λ () + (let ([git (find-executable-path "git")]) + (unless (system* git "diff" "--shortstat") + (raise 'git-failure))))))) + "x" + "") + "-" "-" + (version);) + postfix))) + (if (non-empty-string? (get-output-string stderr)) + (begin (displayln (get-output-string stderr)) + (raise 'git-failure)) + result))) ;; TODO: merge the handling of unicode chars into scribble-math. (define m (list setup-math - (tex-header "\renewcommand{\rmdefault}{cmr}"))) + (tex-header "\\renewcommand{\\rmdefault}{cmr}"))) (define my-title ;; TODO: use this for the other wrapped procs in this file (make-keyword-procedure