1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 ;; This file contains machinery to build HTML and PDF copies of the manual
22 ;; that can be readily published on the web site. To do that, run:
24 ;; guix build -f build.scm
26 ;; The result is a directory hierarchy that can be used as the manual/
27 ;; sub-directory of the web site.
37 (gnu packages gettext)
39 (gnu packages guile-xyz)
40 (gnu packages iso-codes)
41 (gnu packages texinfo)
47 (@@ (guix self) file-append*))
49 (define translated-texi-manuals
50 (@@ (guix self) translate-texi-manuals))
53 (@@ (guix self) info-manual))
56 ;; The manual to build--i.e., the base name of a .texi file, such as "guix"
57 ;; or "guix-cookbook".
58 (or (getenv "GUIX_MANUAL")
62 ;; The cookbook is currently only translated into German.
63 (if (string=? %manual "guix-cookbook")
65 '("de" "en" "es" "fr" "ru" "zh_CN")))
67 (define (texinfo-manual-images source)
68 "Return a directory containing all the images used by the user manual, taken
69 from SOURCE, the root of the source tree."
71 (module-ref (resolve-interface '(gnu packages graphviz))
75 (file-append* source "doc/images"))
78 (with-imported-modules '((guix build utils))
80 (use-modules (guix build utils)
83 (define (dot->image dot-file format)
84 (invoke #+(file-append graphviz "/bin/dot")
85 "-T" format "-Gratio=.9" "-Gnodesep=.005"
86 "-Granksep=.00005" "-Nfontsize=9"
87 "-Nheight=.1" "-Nwidth=.1"
88 "-o" (string-append #$output "/"
89 (basename dot-file ".dot")
95 (for-each (lambda (dot-file)
96 (for-each (cut dot->image dot-file <>)
98 (find-files #$images "\\.dot$"))
101 (for-each (lambda (png-file)
102 (install-file png-file #$output))
103 (find-files #$images "\\.png$")))))
105 (computed-file "texinfo-manual-images" build))
107 (define* (texinfo-manual-source source #:key
109 (languages %languages)
111 "Gather all the source files of the Texinfo manuals from SOURCE--.texi file
112 as well as images, OS examples, and translations."
113 (define documentation
114 (file-append* source "doc"))
117 (file-append* source "gnu/system/examples"))
120 (with-imported-modules '((guix build utils))
122 (use-modules (guix build utils)
125 (define (make-version-texi language)
126 ;; Create the 'version.texi' file for LANGUAGE.
127 (let ((file (if (string=? language "en")
129 (string-append "version-" language ".texi"))))
130 (call-with-output-file (string-append #$output "/" file)
132 (let* ((version #$version)
133 (time (make-time time-utc 0 #$date))
134 (date (time-utc->date time)))
137 @set UPDATED-MONTH ~a
140 (date->string date "~e ~B ~Y")
141 (date->string date "~B ~Y")
142 version version))))))
144 (install-file #$(file-append documentation "/htmlxref.cnf")
147 (for-each (lambda (texi)
148 (install-file texi #$output))
149 (append (find-files #$documentation "\\.(texi|scm|json)$")
150 (find-files #$(translated-texi-manuals source)
153 ;; Create 'version.texi'.
154 (for-each make-version-texi '#$languages)
156 ;; Copy configuration templates that the manual includes.
157 (for-each (lambda (template)
160 #$output "/os-config-"
161 (basename template ".tmpl")
163 (find-files #$examples "\\.tmpl$"))
165 (symlink #$(texinfo-manual-images source)
166 (string-append #$output "/images")))))
168 (computed-file "texinfo-manual-source" build))
170 (define %web-site-url
171 ;; URL of the web site home page.
172 (or (getenv "GUIX_WEB_SITE_URL")
175 (define %makeinfo-html-options
176 ;; Options passed to 'makeinfo --html'.
177 '("--css-ref=https://www.gnu.org/software/gnulib/manual.css"
178 "-c" "EXTRA_HEAD=<meta name=\"viewport\" \
179 content=\"width=device-width, initial-scale=1\" />"))
181 (define guile-lib/htmlprag-fixed
182 ;; Guile-Lib with a hotfix for (htmlprag).
186 (substitute-keyword-arguments (package-arguments guile-lib)
187 ((#:phases phases '%standard-phases)
188 `(modify-phases ,phases
189 (add-before 'build 'fix-htmlprag
192 ;; "<body><blockquote><p>foo</p>\n</blockquote></body>",
193 ;; 'html->shtml' would mistakenly close 'blockquote' right
194 ;; before <p>. This patch removes 'p' from the
195 ;; 'parent-constraints' alist to fix that.
196 (substitute* "src/htmlprag.scm"
197 (("^[[:blank:]]*\\(p[[:blank:]]+\\. \\(body td th\\)\\).*")
200 (add-before 'check 'skip-known-failure
202 ;; XXX: The above change causes one test failure among
203 ;; the htmlprag tests.
204 (setenv "XFAIL_TESTS" "htmlprag.scm")
207 (define* (syntax-highlighted-html input
209 (name "highlighted-syntax")
211 "/static/base/css/code.css"))
212 "Return a derivation called NAME that processes all the HTML files in INPUT
213 to (1) add them a link to SYNTAX-CSS-URL, and (2) highlight the syntax of all
214 its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
216 (with-extensions (list guile-lib/htmlprag-fixed guile-syntax-highlight)
217 (with-imported-modules '((guix build utils))
219 (use-modules (htmlprag)
221 (syntax-highlight scheme)
222 (syntax-highlight lexers)
230 (define (pair-open/close lst)
231 ;; Pair 'open' and 'close' tags produced by 'highlights' and
232 ;; produce nested 'paren' tags instead.
237 ((('open open) rest ...)
240 (loop rest (+ 1 level) '()))
241 (lambda (inner close rest)
243 (cons `(paren ,level ,open ,inner ,close)
245 ((('close str) rest ...)
247 (values (reverse result) str rest)
249 (format (current-error-port)
250 "warning: extra closing paren; context:~% ~y~%"
252 (loop rest 0 (cons `(close ,str) result)))))
254 (loop rest level (cons item result)))
257 (format (current-error-port)
258 "warning: missing ~a closing parens; context:~% ~y%"
259 level (reverse result)))
260 (values (reverse result) "" '())))))
262 (define (highlights->sxml* highlights anchors)
263 ;; Like 'highlights->sxml', but handle nested 'paren tags. This
264 ;; allows for paren matching highlights via appropriate CSS
265 ;; "hover" properties. When a symbol is encountered, look it up
266 ;; in ANCHORS, a vhash, and emit the corresponding href, if any.
267 (define (tag->class tag)
268 (string-append "syntax-" (symbol->string tag)))
271 ((? string? str) str)
272 (('paren level open (body ...) close)
273 `(span (@ (class ,(string-append "syntax-paren"
274 (number->string level))))
276 (span (@ (class "syntax-symbol"))
277 ,@(highlights->sxml* body anchors))
280 ;; Check whether we can emit a hyperlink for TEXT.
281 (match (vhash-assoc text anchors)
283 `(span (@ (class ,(tag->class 'symbol))) ,text))
285 `(a (@ (class ,(tag->class 'symbol)) (href ,target))
288 `(span (@ (class ,(tag->class tag))) ,text)))
291 (define entity->string
297 (e (pk 'unknown-entity e) (primitive-exit 2))))
299 (define (concatenate-snippets pieces)
300 ;; Concatenate PIECES, which contains strings and entities,
301 ;; replacing entities with their corresponding string.
302 (let loop ((pieces pieces)
306 (string-concatenate-reverse strings))
307 (((? string? str) . rest)
308 (loop rest (cons str strings)))
309 ((('*ENTITY* "additional" entity) . rest)
310 (loop rest (cons (entity->string entity) strings)))
311 ((('span _ lst ...) . rest) ;for <span class="roman">
312 (loop (append lst rest) strings))
313 ((('var name) . rest) ;for @var{name} within @lisp
314 (loop rest (cons name strings))) ;XXX: losing formatting
316 (pk 'unsupported-code-snippet something)
317 (primitive-exit 1)))))
319 (define (syntax-highlight sxml anchors)
320 ;; Recurse over SXML and syntax-highlight code snippets.
321 (let loop ((sxml sxml))
323 (('*TOP* decl body ...)
324 `(*TOP* ,decl ,@(map loop body)))
327 (link (@ (rel "stylesheet")
329 (href #$syntax-css-url)))))
330 (('pre ('@ ('class "lisp")) code-snippet ...)
331 `(pre (@ (class "lisp"))
334 (highlight lex-scheme
335 (concatenate-snippets code-snippet)))
337 ((tag ('@ attributes ...) body ...)
338 `(,tag (@ ,@attributes) ,@(map loop body)))
340 `(,tag ,@(map loop body)))
344 (define (underscore-decode str)
345 ;; Decode STR, an "underscore-encoded" string as produced by
346 ;; makeinfo for indexes, such as "_0025base_002dservices" for
350 (match (string-index str #\_)
352 (string-concatenate-reverse (cons str result)))
354 (let ((char (string->number
355 (substring str (+ index 1) (+ index 5))
357 (loop (string-drop str (+ index 5))
358 (append (list (string (integer->char char))
359 (string-take str index))
362 (define (anchor-id->key id)
363 ;; Convert ID, an anchor ID such as
364 ;; "index-pam_002dlimits_002dservice" to the corresponding key,
365 ;; "pam-limits-service" in this example. Drop the suffix of
366 ;; duplicate anchor IDs like "operating_002dsystem-1".
367 (let ((id (if (any (cut string-suffix? <> id)
368 '("-1" "-2" "-3" "-4" "-5"))
369 (string-drop-right id 2)
372 (string-drop id (string-length "index-")))))
374 (define* (collect-anchors file #:optional (vhash vlist-null))
375 ;; Collect the anchors that appear in FILE, a makeinfo-generated
376 ;; file. Grab those from <dt> tags, which corresponds to
377 ;; Texinfo @deftp, @defvr, etc. Return VHASH augmented with
378 ;; more name/reference pairs.
379 (define string-or-entity?
382 (('*ENTITY* _ ...) #t)
385 (define (worthy-entry? lst)
387 ;; Scheme Variable: <strong>x</strong>
389 ;; <code>cups-configuration</code> parameter: …
390 (let loop ((lst lst))
392 (((? string-or-entity?) rest ...)
394 ((('strong _ ...) _ ...)
398 (let ((shtml (call-with-input-file file html->shtml)))
399 (let loop ((shtml shtml)
402 (('dt ('@ ('id id)) rest ...)
403 (if (and (string-prefix? "index-" id)
404 (worthy-entry? rest))
405 (vhash-cons (anchor-id->key id)
406 (string-append (basename file)
410 ((tag ('@ _ ...) body ...)
411 (fold loop vhash body))
413 (fold loop vhash body))
416 (define (process-html file anchors)
417 ;; Parse FILE and perform syntax highlighting for its Scheme
418 ;; snippets. Install the result to #$output.
419 (format (current-error-port) "processing ~a...~%" file)
420 (let* ((shtml (call-with-input-file file html->shtml))
421 (highlighted (syntax-highlight shtml anchors))
422 (base (string-drop file (string-length #$input)))
423 (target (string-append #$output base)))
424 (mkdir-p (dirname target))
425 (call-with-output-file target
427 (write-shtml-as-html highlighted port)))))
429 (define (copy-as-is file)
430 ;; Copy FILE as is to #$output.
431 (let* ((base (string-drop file (string-length #$input)))
432 (target (string-append #$output base)))
433 (mkdir-p (dirname target))
436 (if (eq? 'symlink (stat:type (lstat file)))
437 (symlink (readlink file) target)
440 (let ((errno (system-error-errno args)))
441 (pk 'error-link file target (strerror errno))
442 (primitive-exit 3))))))
444 (define (html? file stat)
445 (string-suffix? ".html" file))
447 ;; Install a UTF-8 locale so we can process UTF-8 files.
448 (setenv "GUIX_LOCPATH"
449 #+(file-append glibc-utf8-locales "/lib/locale"))
450 (setlocale LC_ALL "en_US.utf8")
452 ;; First process the mono-node 'guix.html' files.
453 (n-par-for-each (parallel-job-count)
455 (let ((anchors (collect-anchors mono)))
456 (process-html mono anchors)))
459 "^guix(-cookbook|)(\\.[a-zA-Z_-]+)?\\.html$"))
461 ;; Next process the multi-node HTML files in two phases: (1)
462 ;; collect the list of anchors, and (2) perform
463 ;; syntax-highlighting.
464 (let* ((multi (find-files #$input "^html_node$"
466 (anchors (n-par-map (parallel-job-count)
469 (fold collect-anchors vlist-null
470 (find-files multi html?))))
472 (n-par-for-each (parallel-job-count)
474 (let ((anchors (assoc-ref anchors (dirname file))))
475 (process-html file anchors)))
476 (append-map (lambda (multi)
477 (find-files multi html?))
480 ;; Last, copy non-HTML files as is.
482 (find-files #$input (negate html?)))))))
484 (computed-file name build))
486 (define* (html-manual source #:key (languages %languages)
490 (options %makeinfo-html-options))
491 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
493 (define manual-source
494 (texinfo-manual-source source
496 #:languages languages
500 (texinfo-manual-images source))
503 (with-imported-modules '((guix build utils))
505 (use-modules (guix build utils)
508 (define (normalize language)
509 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
510 (string-map (match-lambda
513 (string-downcase language)))
515 (define (language->texi-file-name language)
516 (if (string=? language "en")
517 (string-append #$manual-source "/"
519 (string-append #$manual-source "/"
520 #$manual "." language ".texi")))
522 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
523 (setenv "GUIX_LOCPATH"
524 #+(file-append glibc-utf8-locales "/lib/locale"))
525 (setenv "LC_ALL" "en_US.utf8")
527 (setvbuf (current-output-port) 'line)
528 (setvbuf (current-error-port) 'line)
530 ;; 'makeinfo' looks for "htmlxref.cnf" in the current directory, so
531 ;; copy it right here.
532 (copy-file (string-append #$manual-source "/htmlxref.cnf")
535 (for-each (lambda (language)
536 (let* ((texi (language->texi-file-name language))
538 "-c" ,(string-append "TOP_NODE_UP_URL=/manual/"
542 (format #t "building HTML manual for language '~a'...~%"
544 (mkdir-p (string-append #$output "/"
545 (normalize language)))
546 (setenv "LANGUAGE" language)
547 (apply invoke #$(file-append texinfo "/bin/makeinfo")
548 "-o" (string-append #$output "/"
552 (apply invoke #$(file-append texinfo "/bin/makeinfo")
555 (string-append #$output "/"
558 (if (string=? language "en")
560 (string-append "." language))
564 ;; Make sure images are available.
566 (string-append #$output "/" (normalize language)
569 (string-append #$output "/" (normalize language)
570 "/html_node/images"))))
571 (filter (compose file-exists? language->texi-file-name)
574 (let* ((name (string-append manual "-html-manual"))
575 (manual (computed-file name build)))
576 (syntax-highlighted-html manual
577 #:name (string-append name "-highlighted"))))
579 (define* (pdf-manual source #:key (languages %languages)
584 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
586 (define manual-source
587 (texinfo-manual-source source
589 #:languages languages
592 ;; FIXME: This union works, except for the table of contents of non-English
593 ;; manuals, which contains escape sequences like "^^ca^^fe" instead of
597 ;; (texlive-union (list texlive-tex-texinfo
598 ;; texlive-generic-epsf
599 ;; texlive-fonts-ec)))
602 (with-imported-modules '((guix build utils))
604 (use-modules (guix build utils)
608 (define (normalize language) ;XXX: deduplicate
609 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
610 (string-map (match-lambda
613 (string-downcase language)))
615 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
616 (setenv "GUIX_LOCPATH"
617 #+(file-append glibc-utf8-locales "/lib/locale"))
618 (setenv "LC_ALL" "en_US.utf8")
620 (string-append #+(file-append texlive "/bin") ":"
621 #+(file-append texinfo "/bin") ":"
623 ;; Below are command-line tools needed by
624 ;; 'texi2dvi' and friends.
625 #+(file-append sed "/bin") ":"
626 #+(file-append grep "/bin") ":"
627 #+(file-append coreutils "/bin") ":"
628 #+(file-append gawk "/bin") ":"
629 #+(file-append tar "/bin") ":"
630 #+(file-append diffutils "/bin")))
632 (setvbuf (current-output-port) 'line)
633 (setvbuf (current-error-port) 'line)
635 (setenv "HOME" (getcwd)) ;for kpathsea/mktextfm
637 ;; 'SOURCE_DATE_EPOCH' is honored by pdftex.
638 (setenv "SOURCE_DATE_EPOCH" "1")
640 (for-each (lambda (language)
641 (let ((opts `("--pdf"
644 ,(if (string=? language "en")
645 (string-append #$manual-source "/"
647 (string-append #$manual-source "/"
648 #$manual "." language ".texi")))))
649 (format #t "building PDF manual for language '~a'...~%"
651 (mkdir-p (string-append #$output "/"
652 (normalize language)))
653 (setenv "LANGUAGE" language)
656 ;; FIXME: Unfortunately building PDFs for non-Latin
657 ;; alphabets doesn't work:
658 ;; <https://lists.gnu.org/archive/html/help-texinfo/2012-01/msg00014.html>.
659 (guard (c ((invoke-error? c)
660 (format (current-error-port)
661 "~%~%Failed to produce \
662 PDF for language '~a'!~%~%"
664 (apply invoke #$(file-append texinfo "/bin/makeinfo")
666 (string-append #$output "/"
669 (if (string=? language "en")
677 (computed-file (string-append manual "-pdf-manual") build))
679 (define (guix-manual-text-domain source languages)
680 "Return the PO files for LANGUAGES of the 'guix-manual' text domain taken
683 (file-append* source "/po/doc"))
686 (with-imported-modules '((guix build utils))
688 (use-modules (guix build utils))
691 (for-each (lambda (language)
693 (string-append #$output "/" language
697 (invoke #+(file-append gnu-gettext "/bin/msgfmt")
699 (string-append directory "/guix-manual.mo")
700 (string-append #$po-directory "/guix-manual."
702 '#$(delete "en" languages)))))
704 (computed-file "guix-manual-po" build))
706 (define* (html-manual-indexes source
707 #:key (languages %languages)
710 (title (if (string=? "guix" manual)
711 "GNU Guix Reference Manual"
712 "GNU Guix Cookbook"))
715 (with-extensions (list guile-json-3)
716 (with-imported-modules '((guix build utils))
718 (use-modules (guix build utils)
726 (define (normalize language) ;XXX: deduplicate
727 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
728 (string-map (match-lambda
731 (string-downcase language)))
733 (define-syntax-rule (with-language language exp ...)
734 (let ((lang (getenv "LANGUAGE")))
737 (setenv "LANGUAGE" language)
738 (setlocale LC_MESSAGES))
742 (setenv "LANGUAGE" lang)
743 (unsetenv "LANGUAGE"))
744 (setlocale LC_MESSAGES)))))
746 ;; (put 'with-language 'scheme-indent-function 1)
747 (define* (translate str language
748 #:key (domain "guix-manual"))
751 (bindtextdomain "guix-manual"
752 #+(guix-manual-text-domain
755 (bindtextdomain "iso_639-3" ;language names
756 #+(file-append iso-codes
758 (write (gettext ,str ,domain))))
760 (with-language language
761 ;; Since the 'gettext' function caches msgid translations,
762 ;; regardless of $LANGUAGE, we have to spawn a new process each
763 ;; time we want to translate to a different language. Bah!
764 (let* ((pipe (open-pipe* OPEN_READ
765 #+(file-append guile-2.2
767 "-c" (object->string exp)))
772 (define (seconds->string seconds language)
773 (let* ((time (make-time time-utc 0 seconds))
774 (date (time-utc->date time)))
775 (with-language language (date->string date "~e ~B ~Y"))))
777 (define (guix-url path)
778 (string-append #$%web-site-url path))
780 (define (sxml-index language title body)
781 ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
782 `(html (@ (lang ,language))
784 (title ,(string-append title " — GNU Guix"))
785 (meta (@ (charset "UTF-8")))
786 (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
788 (link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
790 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
791 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
792 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
793 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
794 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
795 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
796 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
798 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
799 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
801 (header (@ (class "navbar"))
802 (h1 (a (@ (class "branding")
803 (href #$%web-site-url)))
804 (span (@ (class "a11y-offset"))
806 (nav (@ (class "menu"))))
807 (nav (@ (class "breadcrumbs"))
808 (a (@ (class "crumb")
809 (href #$%web-site-url))
814 (define (language-index language)
816 (translate #$title language))
822 (@ (class "page centered-block limit-width"))
824 (p (@ (class "post-metadata centered-text"))
826 ,(seconds->string #$date language))
830 (li (a (@ (href "html_node"))
831 "HTML, with one page per node"))
835 (if (string=? language
841 "HTML, entirely on one page"))
842 ,@(if (member language '("ru" "zh_CN"))
844 `((li (a (@ (href ,(string-append
846 (if (string=? language "en")
853 (define %iso639-languages
855 (assoc-ref (call-with-input-file
856 #+(file-append iso-codes
857 "/share/iso-codes/json/iso_639-3.json")
861 (define (language-code->name code)
862 "Return the full name of a language from its ISO-639-3 code."
863 (let ((code (match (string-index code #\_)
865 (index (string-take code index)))))
866 (any (lambda (language)
867 (and (string=? (or (assoc-ref language "alpha_2")
868 (assoc-ref language "alpha_3"))
870 (assoc-ref language "name")))
873 (define (top-level-index languages)
874 (define title #$title)
879 (@ (class "page centered-block limit-width"))
882 "This document is available in the following
885 ,@(map (lambda (language)
886 `(li (a (@ (href ,(normalize language)))
888 (language-code->name language)
890 #:domain "iso_639-3"))))
893 (define (write-html file sxml)
894 (call-with-output-file file
896 (display "<!DOCTYPE html>\n" port)
897 (sxml->xml sxml port))))
899 (setenv "GUIX_LOCPATH"
900 #+(file-append glibc-utf8-locales "/lib/locale"))
901 (setenv "LC_ALL" "en_US.utf8")
902 (setlocale LC_ALL "en_US.utf8")
904 (for-each (lambda (language)
906 (string-append #$output "/"
907 (normalize language)))
910 (write-html (string-append directory "/index.html")
911 (language-index language)))
914 (write-html (string-append #$output "/index.html")
915 (top-level-index '#$languages))))))
917 (computed-file "html-indexes" build))
919 (define* (pdf+html-manual source
920 #:key (languages %languages)
922 (date (time-second (current-time time-utc)))
924 "Return the union of the HTML and PDF manuals, as well as the indexes."
925 (directory-union (string-append manual "-manual")
929 #:languages languages
932 (list html-manual-indexes
933 html-manual pdf-manual))
936 (define (latest-commit+date directory)
937 "Return two values: the last commit ID (a hex string) for DIRECTORY, and its
938 commit date (an integer)."
939 (let* ((repository (repository-open directory))
940 (head (repository-head repository))
941 (oid (reference-target head))
942 (commit (commit-lookup repository oid)))
943 ;; TODO: Use (git describe) when it's widely available.
944 (values (oid->string oid) (commit-time commit))))
947 (let* ((root (canonicalize-path
948 (string-append (current-source-directory) "/..")))
949 (commit date (latest-commit+date root)))
950 (format (current-error-port)
951 "building manual from work tree around commit ~a, ~a~%"
953 (let* ((time (make-time time-utc 0 date))
954 (date (time-utc->date time)))
955 (date->string date "~e ~B ~Y")))
956 (pdf+html-manual (local-file root "guix" #:recursive? #t
957 #:select? (git-predicate root))
958 #:version (or (getenv "GUIX_MANUAL_VERSION")
959 (string-take commit 7))