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 (inherit (package-source guile-lib))
187 (modules '(( guix build utils)))
191 ;; "<body><blockquote><p>foo</p>\n</blockquote></body>",
192 ;; 'html->shtml' would mistakenly close 'blockquote' right
193 ;; before <p>. This patch removes 'p' from the
194 ;; 'parent-constraints' alist to fix that.
195 (substitute* "src/htmlprag.scm"
196 (("^[[:blank:]]*\\(p[[:blank:]]+\\. \\(body td th\\)\\).*")
200 (substitute-keyword-arguments (package-arguments guile-lib)
201 ((#:phases phases '%standard-phases)
202 `(modify-phases ,phases
203 (add-before 'check 'skip-known-failure
205 ;; XXX: The above change causes one test failure among
206 ;; the htmlprag tests.
207 (setenv "XFAIL_TESTS" "htmlprag.scm")
210 (define* (syntax-highlighted-html input
212 (name "highlighted-syntax")
214 "/static/base/css/code.css"))
215 "Return a derivation called NAME that processes all the HTML files in INPUT
216 to (1) add them a link to SYNTAX-CSS-URL, and (2) highlight the syntax of all
217 its <pre class=\"lisp\"> blocks (as produced by 'makeinfo --html')."
219 (with-extensions (list guile-lib/htmlprag-fixed guile-syntax-highlight)
220 (with-imported-modules '((guix build utils))
222 (use-modules (htmlprag)
224 (syntax-highlight scheme)
225 (syntax-highlight lexers)
233 (define (pair-open/close lst)
234 ;; Pair 'open' and 'close' tags produced by 'highlights' and
235 ;; produce nested 'paren' tags instead.
240 ((('open open) rest ...)
243 (loop rest (+ 1 level) '()))
244 (lambda (inner close rest)
246 (cons `(paren ,level ,open ,inner ,close)
248 ((('close str) rest ...)
250 (values (reverse result) str rest)
252 (format (current-error-port)
253 "warning: extra closing paren; context:~% ~y~%"
255 (loop rest 0 (cons `(close ,str) result)))))
257 (loop rest level (cons item result)))
260 (format (current-error-port)
261 "warning: missing ~a closing parens; context:~% ~y%"
262 level (reverse result)))
263 (values (reverse result) "" '())))))
265 (define (highlights->sxml* highlights anchors)
266 ;; Like 'highlights->sxml', but handle nested 'paren tags. This
267 ;; allows for paren matching highlights via appropriate CSS
268 ;; "hover" properties. When a symbol is encountered, look it up
269 ;; in ANCHORS, a vhash, and emit the corresponding href, if any.
270 (define (tag->class tag)
271 (string-append "syntax-" (symbol->string tag)))
274 ((? string? str) str)
275 (('paren level open (body ...) close)
276 `(span (@ (class ,(string-append "syntax-paren"
277 (number->string level))))
279 (span (@ (class "syntax-symbol"))
280 ,@(highlights->sxml* body anchors))
283 ;; Check whether we can emit a hyperlink for TEXT.
284 (match (vhash-assoc text anchors)
286 `(span (@ (class ,(tag->class 'symbol))) ,text))
288 `(a (@ (class ,(tag->class 'symbol)) (href ,target))
291 `(span (@ (class ,(tag->class tag))) ,text)))
294 (define entity->string
300 (e (pk 'unknown-entity e) (primitive-exit 2))))
302 (define (concatenate-snippets pieces)
303 ;; Concatenate PIECES, which contains strings and entities,
304 ;; replacing entities with their corresponding string.
305 (let loop ((pieces pieces)
309 (string-concatenate-reverse strings))
310 (((? string? str) . rest)
311 (loop rest (cons str strings)))
312 ((('*ENTITY* "additional" entity) . rest)
313 (loop rest (cons (entity->string entity) strings)))
314 ((('span _ lst ...) . rest) ;for <span class="roman">
315 (loop (append lst rest) strings))
317 (pk 'unsupported-code-snippet something)
318 (primitive-exit 1)))))
320 (define (syntax-highlight sxml anchors)
321 ;; Recurse over SXML and syntax-highlight code snippets.
322 (let loop ((sxml sxml))
324 (('*TOP* decl body ...)
325 `(*TOP* ,decl ,@(map loop body)))
328 (link (@ (rel "stylesheet")
330 (href #$syntax-css-url)))))
331 (('pre ('@ ('class "lisp")) code-snippet ...)
332 `(pre (@ (class "lisp"))
335 (highlight lex-scheme
336 (concatenate-snippets code-snippet)))
338 ((tag ('@ attributes ...) body ...)
339 `(,tag (@ ,@attributes) ,@(map loop body)))
341 `(,tag ,@(map loop body)))
345 (define (underscore-decode str)
346 ;; Decode STR, an "underscore-encoded" string as produced by
347 ;; makeinfo for indexes, such as "_0025base_002dservices" for
351 (match (string-index str #\_)
353 (string-concatenate-reverse (cons str result)))
355 (let ((char (string->number
356 (substring str (+ index 1) (+ index 5))
358 (loop (string-drop str (+ index 5))
359 (append (list (string (integer->char char))
360 (string-take str index))
363 (define (anchor-id->key id)
364 ;; Convert ID, an anchor ID such as
365 ;; "index-pam_002dlimits_002dservice" to the corresponding key,
366 ;; "pam-limits-service" in this example. Drop the suffix of
367 ;; duplicate anchor IDs like "operating_002dsystem-1".
368 (let ((id (if (any (cut string-suffix? <> id)
369 '("-1" "-2" "-3" "-4" "-5"))
370 (string-drop-right id 2)
373 (string-drop id (string-length "index-")))))
375 (define* (collect-anchors file #:optional (vhash vlist-null))
376 ;; Collect the anchors that appear in FILE, a makeinfo-generated
377 ;; file. Grab those from <dt> tags, which corresponds to
378 ;; Texinfo @deftp, @defvr, etc. Return VHASH augmented with
379 ;; more name/reference pairs.
380 (define string-or-entity?
383 (('*ENTITY* _ ...) #t)
386 (define (worthy-entry? lst)
388 ;; Scheme Variable: <strong>x</strong>
390 ;; <code>cups-configuration</code> parameter: …
391 (let loop ((lst lst))
393 (((? string-or-entity?) rest ...)
395 ((('strong _ ...) _ ...)
399 (let ((shtml (call-with-input-file file html->shtml)))
400 (let loop ((shtml shtml)
403 (('dt ('@ ('id id)) rest ...)
404 (if (and (string-prefix? "index-" id)
405 (worthy-entry? rest))
406 (vhash-cons (anchor-id->key id)
407 (string-append (basename file)
411 ((tag ('@ _ ...) body ...)
412 (fold loop vhash body))
414 (fold loop vhash body))
417 (define (process-html file anchors)
418 ;; Parse FILE and perform syntax highlighting for its Scheme
419 ;; snippets. Install the result to #$output.
420 (format (current-error-port) "processing ~a...~%" file)
421 (let* ((shtml (call-with-input-file file html->shtml))
422 (highlighted (syntax-highlight shtml anchors))
423 (base (string-drop file (string-length #$input)))
424 (target (string-append #$output base)))
425 (mkdir-p (dirname target))
426 (call-with-output-file target
428 (write-shtml-as-html highlighted port)))))
430 (define (copy-as-is file)
431 ;; Copy FILE as is to #$output.
432 (let* ((base (string-drop file (string-length #$input)))
433 (target (string-append #$output base)))
434 (mkdir-p (dirname target))
437 (if (eq? 'symlink (stat:type (lstat file)))
438 (symlink (readlink file) target)
441 (let ((errno (system-error-errno args)))
442 (pk 'error-link file target (strerror errno))
443 (primitive-exit 3))))))
445 (define (html? file stat)
446 (string-suffix? ".html" file))
448 ;; Install a UTF-8 locale so we can process UTF-8 files.
449 (setenv "GUIX_LOCPATH"
450 #+(file-append glibc-utf8-locales "/lib/locale"))
451 (setlocale LC_ALL "en_US.utf8")
453 ;; First process the mono-node 'guix.html' files.
454 (n-par-for-each (parallel-job-count)
456 (let ((anchors (collect-anchors mono)))
457 (process-html mono anchors)))
460 "^guix(-cookbook|)(\\.[a-zA-Z_-]+)?\\.html$"))
462 ;; Next process the multi-node HTML files in two phases: (1)
463 ;; collect the list of anchors, and (2) perform
464 ;; syntax-highlighting.
465 (let* ((multi (find-files #$input "^html_node$"
467 (anchors (n-par-map (parallel-job-count)
470 (fold collect-anchors vlist-null
471 (find-files multi html?))))
473 (n-par-for-each (parallel-job-count)
475 (let ((anchors (assoc-ref anchors (dirname file))))
476 (process-html file anchors)))
477 (append-map (lambda (multi)
478 (find-files multi html?))
481 ;; Last, copy non-HTML files as is.
483 (find-files #$input (negate html?)))))))
485 (computed-file name build))
487 (define* (html-manual source #:key (languages %languages)
491 (options %makeinfo-html-options))
492 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
494 (define manual-source
495 (texinfo-manual-source source
497 #:languages languages
501 (texinfo-manual-images source))
504 (with-imported-modules '((guix build utils))
506 (use-modules (guix build utils)
509 (define (normalize language)
510 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
511 (string-map (match-lambda
514 (string-downcase language)))
516 (define (language->texi-file-name language)
517 (if (string=? language "en")
518 (string-append #$manual-source "/"
520 (string-append #$manual-source "/"
521 #$manual "." language ".texi")))
523 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
524 (setenv "GUIX_LOCPATH"
525 #+(file-append glibc-utf8-locales "/lib/locale"))
526 (setenv "LC_ALL" "en_US.utf8")
528 (setvbuf (current-output-port) 'line)
529 (setvbuf (current-error-port) 'line)
531 ;; 'makeinfo' looks for "htmlxref.cnf" in the current directory, so
532 ;; copy it right here.
533 (copy-file (string-append #$manual-source "/htmlxref.cnf")
536 (for-each (lambda (language)
537 (let* ((texi (language->texi-file-name language))
539 "-c" ,(string-append "TOP_NODE_UP_URL=/manual/"
543 (format #t "building HTML manual for language '~a'...~%"
545 (mkdir-p (string-append #$output "/"
546 (normalize language)))
547 (setenv "LANGUAGE" language)
548 (apply invoke #$(file-append texinfo "/bin/makeinfo")
549 "-o" (string-append #$output "/"
553 (apply invoke #$(file-append texinfo "/bin/makeinfo")
556 (string-append #$output "/"
559 (if (string=? language "en")
561 (string-append "." language))
565 ;; Make sure images are available.
567 (string-append #$output "/" (normalize language)
570 (string-append #$output "/" (normalize language)
571 "/html_node/images"))))
572 (filter (compose file-exists? language->texi-file-name)
575 (let* ((name (string-append manual "-html-manual"))
576 (manual (computed-file name build)))
577 (syntax-highlighted-html manual
578 #:name (string-append name "-highlighted"))))
580 (define* (pdf-manual source #:key (languages %languages)
585 "Return the HTML manuals built from SOURCE for all LANGUAGES, with the given
587 (define manual-source
588 (texinfo-manual-source source
590 #:languages languages
593 ;; FIXME: This union works, except for the table of contents of non-English
594 ;; manuals, which contains escape sequences like "^^ca^^fe" instead of
598 ;; (texlive-union (list texlive-tex-texinfo
599 ;; texlive-generic-epsf
600 ;; texlive-fonts-ec)))
603 (with-imported-modules '((guix build utils))
605 (use-modules (guix build utils)
609 (define (normalize language) ;XXX: deduplicate
610 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
611 (string-map (match-lambda
614 (string-downcase language)))
616 ;; Install a UTF-8 locale so that 'makeinfo' is at ease.
617 (setenv "GUIX_LOCPATH"
618 #+(file-append glibc-utf8-locales "/lib/locale"))
619 (setenv "LC_ALL" "en_US.utf8")
621 (string-append #+(file-append texlive "/bin") ":"
622 #+(file-append texinfo "/bin") ":"
624 ;; Below are command-line tools needed by
625 ;; 'texi2dvi' and friends.
626 #+(file-append sed "/bin") ":"
627 #+(file-append grep "/bin") ":"
628 #+(file-append coreutils "/bin") ":"
629 #+(file-append gawk "/bin") ":"
630 #+(file-append tar "/bin") ":"
631 #+(file-append diffutils "/bin")))
633 (setvbuf (current-output-port) 'line)
634 (setvbuf (current-error-port) 'line)
636 (setenv "HOME" (getcwd)) ;for kpathsea/mktextfm
638 ;; 'SOURCE_DATE_EPOCH' is honored by pdftex.
639 (setenv "SOURCE_DATE_EPOCH" "1")
641 (for-each (lambda (language)
642 (let ((opts `("--pdf"
645 ,(if (string=? language "en")
646 (string-append #$manual-source "/"
648 (string-append #$manual-source "/"
649 #$manual "." language ".texi")))))
650 (format #t "building PDF manual for language '~a'...~%"
652 (mkdir-p (string-append #$output "/"
653 (normalize language)))
654 (setenv "LANGUAGE" language)
657 ;; FIXME: Unfortunately building PDFs for non-Latin
658 ;; alphabets doesn't work:
659 ;; <https://lists.gnu.org/archive/html/help-texinfo/2012-01/msg00014.html>.
660 (guard (c ((invoke-error? c)
661 (format (current-error-port)
662 "~%~%Failed to produce \
663 PDF for language '~a'!~%~%"
665 (apply invoke #$(file-append texinfo "/bin/makeinfo")
667 (string-append #$output "/"
670 (if (string=? language "en")
678 (computed-file (string-append manual "-pdf-manual") build))
680 (define (guix-manual-text-domain source languages)
681 "Return the PO files for LANGUAGES of the 'guix-manual' text domain taken
684 (file-append* source "/po/doc"))
687 (with-imported-modules '((guix build utils))
689 (use-modules (guix build utils))
692 (for-each (lambda (language)
694 (string-append #$output "/" language
698 (invoke #+(file-append gnu-gettext "/bin/msgfmt")
700 (string-append directory "/guix-manual.mo")
701 (string-append #$po-directory "/guix-manual."
703 '#$(delete "en" languages)))))
705 (computed-file "guix-manual-po" build))
707 (define* (html-manual-indexes source
708 #:key (languages %languages)
711 (title (if (string=? "guix" manual)
712 "GNU Guix Reference Manual"
713 "GNU Guix Cookbook"))
716 (with-extensions (list guile-json-3)
717 (with-imported-modules '((guix build utils))
719 (use-modules (guix build utils)
727 (define (normalize language) ;XXX: deduplicate
728 ;; Normalize LANGUAGE. For instance, "zh_CN" becomes "zh-cn".
729 (string-map (match-lambda
732 (string-downcase language)))
734 (define-syntax-rule (with-language language exp ...)
735 (let ((lang (getenv "LANGUAGE")))
738 (setenv "LANGUAGE" language)
739 (setlocale LC_MESSAGES))
743 (setenv "LANGUAGE" lang)
744 (unsetenv "LANGUAGE"))
745 (setlocale LC_MESSAGES)))))
747 ;; (put 'with-language 'scheme-indent-function 1)
748 (define* (translate str language
749 #:key (domain "guix-manual"))
752 (bindtextdomain "guix-manual"
753 #+(guix-manual-text-domain
756 (bindtextdomain "iso_639-3" ;language names
757 #+(file-append iso-codes
759 (write (gettext ,str ,domain))))
761 (with-language language
762 ;; Since the 'gettext' function caches msgid translations,
763 ;; regardless of $LANGUAGE, we have to spawn a new process each
764 ;; time we want to translate to a different language. Bah!
765 (let* ((pipe (open-pipe* OPEN_READ
766 #+(file-append guile-2.2
768 "-c" (object->string exp)))
773 (define (seconds->string seconds language)
774 (let* ((time (make-time time-utc 0 seconds))
775 (date (time-utc->date time)))
776 (with-language language (date->string date "~e ~B ~Y"))))
778 (define (guix-url path)
779 (string-append #$%web-site-url path))
781 (define (sxml-index language title body)
782 ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
783 `(html (@ (lang ,language))
785 (title ,(string-append title " — GNU Guix"))
786 (meta (@ (charset "UTF-8")))
787 (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0")))
789 (link (@ (rel "prefetch") (href ,(guix-url "menu/index.html"))))
791 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/elements.css"))))
792 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/common.css"))))
793 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/messages.css"))))
794 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/navbar.css"))))
795 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/breadcrumbs.css"))))
796 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/buttons.css"))))
797 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/footer.css"))))
799 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/page.css"))))
800 (link (@ (rel "stylesheet") (href ,(guix-url "static/base/css/post.css")))))
802 (header (@ (class "navbar"))
803 (h1 (a (@ (class "branding")
804 (href #$%web-site-url)))
805 (span (@ (class "a11y-offset"))
807 (nav (@ (class "menu"))))
808 (nav (@ (class "breadcrumbs"))
809 (a (@ (class "crumb")
810 (href #$%web-site-url))
815 (define (language-index language)
817 (translate #$title language))
823 (@ (class "page centered-block limit-width"))
825 (p (@ (class "post-metadata centered-text"))
827 ,(seconds->string #$date language))
831 (li (a (@ (href "html_node"))
832 "HTML, with one page per node"))
836 (if (string=? language
842 "HTML, entirely on one page"))
843 ,@(if (member language '("ru" "zh_CN"))
845 `((li (a (@ (href ,(string-append
847 (if (string=? language "en")
854 (define %iso639-languages
856 (assoc-ref (call-with-input-file
857 #+(file-append iso-codes
858 "/share/iso-codes/json/iso_639-3.json")
862 (define (language-code->name code)
863 "Return the full name of a language from its ISO-639-3 code."
864 (let ((code (match (string-index code #\_)
866 (index (string-take code index)))))
867 (any (lambda (language)
868 (and (string=? (or (assoc-ref language "alpha_2")
869 (assoc-ref language "alpha_3"))
871 (assoc-ref language "name")))
874 (define (top-level-index languages)
875 (define title #$title)
880 (@ (class "page centered-block limit-width"))
883 "This document is available in the following
886 ,@(map (lambda (language)
887 `(li (a (@ (href ,(normalize language)))
889 (language-code->name language)
891 #:domain "iso_639-3"))))
894 (define (write-html file sxml)
895 (call-with-output-file file
897 (display "<!DOCTYPE html>\n" port)
898 (sxml->xml sxml port))))
900 (setenv "GUIX_LOCPATH"
901 #+(file-append glibc-utf8-locales "/lib/locale"))
902 (setenv "LC_ALL" "en_US.utf8")
903 (setlocale LC_ALL "en_US.utf8")
905 (for-each (lambda (language)
907 (string-append #$output "/"
908 (normalize language)))
911 (write-html (string-append directory "/index.html")
912 (language-index language)))
915 (write-html (string-append #$output "/index.html")
916 (top-level-index '#$languages))))))
918 (computed-file "html-indexes" build))
920 (define* (pdf+html-manual source
921 #:key (languages %languages)
923 (date (time-second (current-time time-utc)))
925 "Return the union of the HTML and PDF manuals, as well as the indexes."
926 (directory-union (string-append manual "-manual")
930 #:languages languages
933 (list html-manual-indexes
934 html-manual pdf-manual))
937 (define (latest-commit+date directory)
938 "Return two values: the last commit ID (a hex string) for DIRECTORY, and its
939 commit date (an integer)."
940 (let* ((repository (repository-open directory))
941 (head (repository-head repository))
942 (oid (reference-target head))
943 (commit (commit-lookup repository oid)))
944 ;; TODO: Use (git describe) when it's widely available.
945 (values (oid->string oid) (commit-time commit))))
948 (let* ((root (canonicalize-path
949 (string-append (current-source-directory) "/..")))
950 (commit date (latest-commit+date root)))
951 (format (current-error-port)
952 "building manual from work tree around commit ~a, ~a~%"
954 (let* ((time (make-time time-utc 0 date))
955 (date (time-utc->date time)))
956 (date->string date "~e ~B ~Y")))
957 (pdf+html-manual (local-file root "guix" #:recursive? #t
958 #:select? (git-predicate root))
959 #:version (or (getenv "GUIX_MANUAL_VERSION")
960 (string-take commit 7))