]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/document-backend.scm
resolve merge
[lilypond.git] / scm / document-backend.scm
index d77a194d3194c3d79e0d1387d31e05bc444c27bb..4d55382fc40bfc6af449d2e11f1be6dcd537c01c 100644 (file)
@@ -1,14 +1,47 @@
-;;;; backend-documentation-lib.scm -- Functions for backend 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 (sort-grob-properties x)
+  ;; force 'meta to the end of each prop-list
+  (let ((meta (assoc 'meta x)))
+    (append (sort (assoc-remove! x 'meta) ly:alist-ci<?)
+            (list meta))))
+
+;; properly sort all grobs, properties, and interfaces
+;; within the all-grob-descriptions alist
+(map
+  (lambda (x)
+    (let* ((props      (assoc-ref all-grob-descriptions (car x)))
+           (meta       (assoc-ref props 'meta))
+           (interfaces (assoc-ref meta 'interfaces)))
+      (set! all-grob-descriptions
+        (sort (assoc-set! all-grob-descriptions (car x)
+               (sort-grob-properties
+                (assoc-set! props 'meta
+                 (assoc-set! meta 'interfaces
+                  (sort interfaces ly:symbol-ci<?)))))
+              ly:alist-ci<?))))
+  all-grob-descriptions)
 
 (define (interface-doc-string interface grob-description)
   (let* ((name (car interface))
         (desc (cadr interface))
-        (props (sort (caddr interface) symbol<?))
+        (props (caddr interface))
         (docfunc (lambda (pr)
                    (property->texi
                     'backend pr grob-description)))
          (description-list->texi internal-propdocs #t))
         ""))))
 
-(define iface->grob-table (make-vector 61 '()))
+(define iface->grob-table (make-hash-table 61))
 ;; extract ifaces, and put grob into the hash table.
 (map
  (lambda (x)
-   (let* ((metah (assoc 'meta (cdr x)))
-         (meta (cdr metah))
-         (ifaces (cdr (assoc 'interfaces meta))))
+   (let* ((meta (assoc-get 'meta (cdr x)))
+         (ifaces (assoc-get 'interfaces meta)))
 
      (map (lambda (iface)
            (hashq-set!
@@ -61,7 +93,7 @@
                                     (hashq-ref iface->grob-table
                                                (car interface)
                                                '()))
-                               string<?)))))
+                               ly:string-ci<?)))))
     (make <texi-node>
       #:name name
       #:text (string-append
   "Given a property alist DESCRIPTION, make a documentation
 node."
 
-  (let* ((metah (assoc 'meta description))
-        (meta (cdr metah))
-        (name (cdr (assoc 'name meta)))
+  (let* ((meta (assoc-get 'meta description))
+        (name (assoc-get 'name meta))
         ;;       (bla (display name))
-        (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
-        (ifacedoc (map (lambda (iface)
-                         (if (pair? iface)
-                             (ref-ify (symbol->string (car iface)))
-                             (ly:error (_ "pair expected in doc ~s") name)))
-                       (reverse ifaces)))
+        (ifaces (map lookup-interface (assoc-get 'interfaces meta)))
+        (ifacedoc (map ref-ify
+                       (sort
+                        (map (lambda (iface)
+                               (if (pair? iface)
+                                   (symbol->string (car iface))
+                                   (ly:error (_ "pair expected in doc ~s") name)))
+                             ifaces)
+                        ly:string-ci<?)))
         (engravers (filter
                     (lambda (x) (engraver-makes-grob? name x))
                     all-engravers-list))
@@ -139,7 +173,8 @@ node."
      (cons (cons key val)  prior))
    '() (ly:all-grob-interfaces)))
 
-(set! interface-description-alist (sort interface-description-alist alist<?))
+(set! interface-description-alist
+  (sort interface-description-alist ly:alist-ci<?))
 
 ;;;;;;;;;; check for dangling backend properties.
 (define (mark-interface-properties entry)
@@ -171,7 +206,7 @@ node."
     (map interface-doc interface-description-alist)))
 
 (define (backend-properties-doc-string lst)
-  (let* ((ps (sort (map symbol->string lst) string<?))
+  (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
         (descs (map (lambda (prop)
                       (property->texi 'backend (string->symbol prop) '())) ps))
         (texi (description-list->texi descs #f)))