]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/document-translation.scm
resolve merge
[lilypond.git] / scm / document-translation.scm
index 5bfc83a5383ba166cc6048e4c7d8fb47c9b03fcc..3e8c308d5b5a8a9a9657963c1d69e0f88192381c 100644 (file)
@@ -1,9 +1,20 @@
-;;;; document-translation.scm -- Functions for engraver documentation
+;;;; This file is part of LilyPond, the GNU music typesetter.
 ;;;;
-;;;; source file of the GNU LilyPond music typesetter
-;;;;
-;;;; (c) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2000--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
 ;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
 (define (engraver-makes-grob? name-symbol grav)
   (memq name-symbol (assoc 'grobs-created (ly:translator-description grav))))
        (engraver-accepts-music-types? (cdr types) grav))))
 
 (define (engraver-doc-string engraver in-which-contexts)
-  (let* ((propsr (cdr (assoc 'properties-read (ly:translator-description engraver))))
-        (propsw (cdr (assoc 'properties-written (ly:translator-description engraver))))
-        (accepted  (cdr (assoc 'events-accepted (ly:translator-description engraver))))
+  (let* ((propsr (assoc-get 'properties-read (ly:translator-description engraver)))
+        (propsw (assoc-get 'properties-written (ly:translator-description engraver)))
+        (accepted  (assoc-get 'events-accepted (ly:translator-description engraver)))
         (name-sym  (ly:translator-name engraver))
         (name-str (symbol->string name-sym))
-        (desc (cdr (assoc 'description (ly:translator-description engraver))))
+        (desc (assoc-get 'description (ly:translator-description engraver)))
         (grobs (engraver-grobs engraver)))
 
     (string-append
         (string-append
          "Music types accepted:\n\n"
          (human-listify
-          (map (lambda (x)
-                 (string-append
-                  "@ref{"
-                  (symbol->string x)
-                  "}")) accepted)))
+          (map ref-ify (sort (map symbol->string accepted) ly:string-ci<?))))
         "")
      "\n\n"
      (if (pair? propsr)
         (string-append
          "Properties (read)"
          (description-list->texi
-          (map (lambda (x) (property->texi 'translation x '())) propsr)
+          (map (lambda (x) (property->texi 'translation x '()))
+               (sort propsr ly:symbol-ci<?))
           #t))
         "")
 
         (string-append
          "Properties (write)"
          (description-list->texi
-          (map (lambda (x) (property->texi 'translation x '())) propsw)
+          (map (lambda (x) (property->texi 'translation x '()))
+               (sort propsw ly:symbol-ci<?))
           #t)))
      (if  (null? grobs)
          ""
          (string-append
           "\n\nThis engraver creates the following layout object(s):\n\n"
-          (human-listify (map ref-ify (uniq-list (sort grobs string<?))))
+          (human-listify (map ref-ify (uniq-list (sort grobs ly:string-ci<?))))
           "."))
 
      "\n\n"
                 (apply append
                        (map
                         (lambda (x)
-                          (let* ((context (cdr (assoc 'context-name x)))
+                          (let* ((context (assoc-get 'context-name x))
                                  (group (assq-ref x 'group-type))
                                  (consists (append
                                             (if group
                                                 (list group)
                                                 '())
-                                            (cdr (assoc 'consists x)))))
+                                            (assoc-get 'consists x))))
                             (if (member name-sym consists)
                                 (list context)
                                 '())))
@@ -86,7 +95,7 @@
                (context-list (human-listify (map ref-ify
                                                  (sort
                                                   (map symbol->string contexts)
-                                                  string<?)))))
+                                                  ly:string-ci<?)))))
           (string-append
            "@code{" name-str "} "
            (if (equal? context-list "none")
     #:text (engraver-doc-string grav #t)))
 
 ;; Second level, part of Context description
-(define name->engraver-table (make-vector 61 '()))
+(define name->engraver-table (make-hash-table 61))
 (map
  (lambda (x)
    (hash-set! name->engraver-table (ly:translator-name x) x))
 
 
 (define (context-doc context-desc)
-  (let* ((name-sym (cdr (assoc 'context-name context-desc)))
+  (let* ((name-sym (assoc-get 'context-name context-desc))
         (name (symbol->string name-sym))
-        (aliases (map symbol->string (cdr (assoc 'aliases context-desc))))
-        (desc-handle (assoc 'description context-desc))
-        (desc (if (and  (pair? desc-handle) (string? (cdr desc-handle)))
-                  (cdr desc-handle) "(not documented)"))
-       
-        (accepts (cdr (assoc 'accepts context-desc)))
-        (consists (cdr (assoc 'consists context-desc)))
-        (props (cdr (assoc 'property-ops context-desc)))
+        (aliases (map symbol->string (assoc-get 'aliases context-desc)))
+        (desc (assoc-get 'description context-desc "(not documented"))
+        (accepts (assoc-get 'accepts context-desc))
+        (consists (assoc-get 'consists context-desc))
+        (props (assoc-get 'property-ops context-desc))
         (grobs  (context-grobs context-desc))
-        (grob-refs (map (lambda (x) (ref-ify x)) grobs)))
+        (grob-refs (map ref-ify (sort grobs ly:string-ci<?))))
 
     (make <texi-node>
       #:name name
        (if (pair? aliases)
           (string-append
            "\n\nThis context also accepts commands for the following context(s):\n\n"
-           (human-listify aliases)
+           (human-listify (sort aliases ly:string-ci<?))
            ".")
           "")
 
        "\n\nThis context creates the following layout object(s):\n\n"
-       (human-listify (uniq-list (sort grob-refs string<?)))
+       (human-listify (uniq-list grob-refs))
        "."
 
        (if (and (pair? props) (not (null? props)))
-          (let ((str (apply string-append (map document-property-operation
-                                               props))))
+          (let ((str (apply string-append
+                            (sort (map document-property-operation props)
+                                  ly:string-ci<?))))
             (if (string-null? str)
                 ""
                 (string-append
            "\n\nContext "
            name
            " can contain\n"
-           (human-listify (map ref-ify (map symbol->string accepts)))
+           (human-listify (map ref-ify (sort (map symbol->string accepts)
+                                             ly:string-ci<?)))
            "."))
 
        (if (null? consists)
           (string-append
            "\n\nThis context is built from the following engraver(s):"
            (description-list->texi
-            (map document-engraver-by-name consists)
+            (map document-engraver-by-name (sort consists ly:symbol-ci<?))
             #t)))))))
 
 (define (engraver-grobs grav)
                 grav)))
     (if (eq? eg #f)
        '()
-       (map symbol->string (cdr (assoc 'grobs-created (ly:translator-description eg)))))))
+       (map symbol->string (assoc-get 'grobs-created (ly:translator-description eg))))))
 
 (define (context-grobs context-desc)
   (let* ((group (assq-ref context-desc 'group-type))
                    (if group
                        (list group)
                        '())
-                   (cdr (assoc 'consists context-desc))))
+                   (assoc-get 'consists context-desc)))
         (grobs  (apply append
                        (map engraver-grobs consists))))
     grobs))
 (define (all-contexts-doc)
   (let* ((layout-alist
          (sort (ly:output-description $defaultlayout)
-               (lambda (x y) (symbol<? (car x) (car y)))))
-        (names (sort (map symbol->string (map car layout-alist)) string<?))
+               (lambda (x y) (ly:symbol-ci<? (car x) (car y)))))
+        (names (sort (map symbol->string (map car layout-alist)) ly:string-ci<?))
         (contexts (map cdr layout-alist)))
 
     (make <texi-node>
 (define all-engravers-list  (ly:get-all-translators))
 (set! all-engravers-list
       (sort all-engravers-list
-           (lambda (a b) (string<? (symbol->string (ly:translator-name a))
+           (lambda (a b) (ly:string-ci<? (symbol->string (ly:translator-name a))
                                    (symbol->string (ly:translator-name b))))))
 
 (define (all-engravers-doc)
     (map engraver-doc all-engravers-list)))
 
 (define (translation-properties-doc-string lst)
-  (let* ((ps (sort (map symbol->string lst) string<?))
+  (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
         (sortedsyms (map string->symbol ps))
         (propdescs
          (map