doc: Generalize build procedures of HTML indexes.

* doc/build.scm (html-manual-indexes)[build](sxml-index): Generalize;
add a 'title' and a 'body' parameter and honor them.
(language-index): New procedure.
(write-index): Remove.
(write-html): New procedure.
Use 'write-html' and 'language-index'.
This commit is contained in:
Ludovic Courtès 2019-07-15 11:51:43 +02:00
parent cb45aad9b0
commit 21bec78357
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 45 additions and 41 deletions

View File

@ -424,10 +424,7 @@ from SOURCE."
(define (guix-url path) (define (guix-url path)
(string-append #$%web-site-url path)) (string-append #$%web-site-url path))
(define (sxml-index language) (define (sxml-index language title body)
(define title
(translate "GNU Guix Reference Manual" language))
;; FIXME: Avoid duplicating styling info from guix-artwork.git. ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
`(html (@ (lang ,language)) `(html (@ (lang ,language))
(head (head
@ -458,45 +455,53 @@ from SOURCE."
(a (@ (class "crumb") (a (@ (class "crumb")
(href #$%web-site-url)) (href #$%web-site-url))
"Home")) "Home"))
(main ,body
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(p (@ (class "post-metadata centered-text"))
#$version " — "
,(seconds->string #$date language))
(div
(ul
(li (a (@ (href "html_node"))
"HTML, with one page per node"))
(li (a (@ (href
,(string-append
#$manual
(if (string=? language
"en")
""
(string-append "."
language))
".html")))
"HTML, entirely on one page"))
,@(if (member language '("ru" "zh_CN"))
'()
`((li (a (@ (href ,(string-append
#$manual
(if (string=? language "en")
""
(string-append "."
language))
".pdf"))))
"PDF")))))))
(footer)))) (footer))))
(define (write-index language file) (define (language-index language)
(define title
(translate "GNU Guix Reference Manual" language))
(sxml-index
language title
`(main
(article
(@ (class "page centered-block limit-width"))
(h2 ,title)
(p (@ (class "post-metadata centered-text"))
#$version " — "
,(seconds->string #$date language))
(div
(ul
(li (a (@ (href "html_node"))
"HTML, with one page per node"))
(li (a (@ (href
,(string-append
#$manual
(if (string=? language
"en")
""
(string-append "."
language))
".html")))
"HTML, entirely on one page"))
,@(if (member language '("ru" "zh_CN"))
'()
`((li (a (@ (href ,(string-append
#$manual
(if (string=? language "en")
""
(string-append "."
language))
".pdf"))))
"PDF")))))))))
(define (write-html file sxml)
(call-with-output-file file (call-with-output-file file
(lambda (port) (lambda (port)
(display "<!DOCTYPE html>\n" port) (display "<!DOCTYPE html>\n" port)
(sxml->xml (sxml-index language) port)))) (sxml->xml sxml port))))
(setenv "GUIX_LOCPATH" (setenv "GUIX_LOCPATH"
#+(file-append glibc-utf8-locales "/lib/locale")) #+(file-append glibc-utf8-locales "/lib/locale"))
@ -512,9 +517,8 @@ from SOURCE."
(normalize language))) (normalize language)))
(mkdir-p directory) (mkdir-p directory)
(write-index language (write-html (string-append directory "/index.html")
(string-append directory (language-index language)))
"/index.html")))
'#$languages)))) '#$languages))))
(computed-file "html-indexes" build)) (computed-file "html-indexes" build))