summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-07-15 11:51:43 +0200
committerLudovic Courtès <ludo@gnu.org>2019-07-15 12:53:27 +0200
commit4e67f2048839c17e7d09f6c1775473018c8815c6 (patch)
tree5a087a5cbda71491ed69f9d428d589c29c15fb6d
parent5ce869f66df61146ece4caa7109f93eb3c6b2f3d (diff)
downloadguix-4e67f2048839c17e7d09f6c1775473018c8815c6.tar.gz
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'.
-rw-r--r--doc/build.scm86
1 files changed, 45 insertions, 41 deletions
diff --git a/doc/build.scm b/doc/build.scm
index e628a91048..c0952ecb89 100644
--- a/doc/build.scm
+++ b/doc/build.scm
@@ -424,10 +424,7 @@ from SOURCE."
           (define (guix-url path)
             (string-append #$%web-site-url path))
 
-          (define (sxml-index language)
-            (define title
-              (translate "GNU Guix Reference Manual" language))
-
+          (define (sxml-index language title body)
             ;; FIXME: Avoid duplicating styling info from guix-artwork.git.
             `(html (@ (lang ,language))
                    (head
@@ -458,45 +455,53 @@ from SOURCE."
                          (a (@ (class "crumb")
                                (href #$%web-site-url))
                             "Home"))
-                    (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")))))))
+                    ,body
                     (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
               (lambda (port)
                 (display "<!DOCTYPE html>\n" port)
-                (sxml->xml (sxml-index language) port))))
+                (sxml->xml sxml port))))
 
           (setenv "GUIX_LOCPATH"
                   #+(file-append glibc-utf8-locales "/lib/locale"))
@@ -512,9 +517,8 @@ from SOURCE."
                                        (normalize language)))
 
                       (mkdir-p directory)
-                      (write-index language
-                                   (string-append directory
-                                                  "/index.html")))
+                      (write-html (string-append directory "/index.html")
+                                  (language-index language)))
                     '#$languages))))
 
   (computed-file "html-indexes" build))