]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/backend-documentation-lib.scm
(markup-thrower-typecheck)
[lilypond.git] / scm / backend-documentation-lib.scm
index ac7ea8f94ae326b9e115a11b148806b6d20e9a53..20a24dcc158d09c7600af48635d63aa09b56f8b7 100644 (file)
@@ -2,7 +2,7 @@
 ;;;
 ;;; source file of the GNU LilyPond music typesetter
 ;;; 
-;;; (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;; (c) 2000--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 ;;; Jan Nieuwenhuizen <janneke@gnu.org>
 
 
 
 ;; alist of property descriptions
 
+;;
+"
+TODO:
 
-;;;;;; TODO: sort out symbol vs. string stuff.
-;;;;;; TODO: use flatten write iso. string-append; might be possible to fold
-;;;;;; in symbol->string integrally.
-
-(define (backend-property->texi sym)
-  (let* ((name (symbol->string sym))
-       (type (object-property sym 'backend-type?))
-       (typename (type-name type))
-       (desc (object-property sym 'backend-doc)))
-
-
-    (if (equal? desc #f)
-       (error "Unknown property " sym)
-       
-       (cons (string-append "@code{" name "} "
-                      "(" typename ")"
-                      ": "
-
-; index gets too messy
-;                     "@vindex " name "\n"
-                      )
-         desc))))
-
-(define (document-grob-property sym grob-description )
-  "Document SYM, filling in default values."
-  (let* ((handle (assoc sym grob-description))
-        (defval (if (eq? handle #f)
-                    "(unset)"
-                  (scm->texi (cdr handle))))
-        (propdoc (backend-property->texi sym)))
-
-    (cons (car propdoc) (string-append (cdr propdoc)
-                                          "\nDefault value: "
-                                          defval)))
-  )
-
-(define (document-interface where interface grob-description)
-
-  (let* ((level (if (eq? where 'grob) 3 2))
-        (name (car interface))
-        (desc (cadr interface))
-        (props (caddr interface))
-        (docfunc (lambda (pr)
-                   (document-grob-property
-                    pr grob-description )))
-        (docs (map docfunc props)))
 
-    (string-append
-     (texi-section level
-                  (string-append (interface-name (symbol->string name)))
-                  (eq? where 'grob)) ;gur.
-     desc
-     (description-list->texi docs))))
+Grob bla
 
-;; First level Interface description
-(define (document-separate-interface interface)
-  (let ((name (symbol->string (car interface))))
-    (processing name)
-    (string-append
-     (node (interface-name name))
-     (document-interface 'self interface '()))))
-
-
-;; First level grob description
-(define (document-grob iname description)
-  (processing iname)
-  (let* ((metah (assoc 'meta description))
-        
-        (meta (cdr metah))
-        (name (cdr (assoc 'name meta)))
-        (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
-        (ifacedoc (map (lambda (iface)
-                         (document-interface 'grob iface description))
-                       (reverse ifaces)))
-        )
+Created by:
 
-    
-    (string-append
-     (node (grob-name name))
-     (texi-section 2 (grob-name name) #f)
-     "\n"
-     (let* ((grob name)
-           (engravers (filter-list
-                       (lambda (x) (engraver-makes-grob? name x)) all-engravers-list))
-           (engraver-names (map Translator::name engravers))
-           )
+  * preset properties + explanation
 
-       (string-append
-       (symbol->string name) " grobs are created by: "
-       (human-listify (map ref-ify
-                           (map engraver-name engraver-names)))))
+Interfaces:
 
-           (apply string-append ifacedoc))))
+  * properties available.
 
+"
 
 
-(define (engraver-makes-grob? name-symbol grav)
-  (memq name-symbol (assoc 'grobs-created (Translator::description grav)))
-  )
-
-(define (document-all-grobs name)
-  (let* ((doc (apply string-append
-                    (map (lambda (x)
-                           (document-grob (symbol->string (car x)) (cdr x)))
-                         all-grob-descriptions)))
-        (names (map symbol->string (map car all-grob-descriptions))))
-
+(define (interface-doc-string interface grob-description)
+  (let*
+      (
+       (name (car interface))
+       (desc (cadr interface))
+       (props (sort (caddr interface) symbol<?))
+       (docfunc (lambda (pr)
+                 (document-property
+                  pr 'backend grob-description )))
+       (propdocs (map docfunc props))
+       )
+    
     (string-append
-     (texi-node-menu name (map (lambda (x) (cons (grob-name x) ""))
-                              names))
-     doc)))
-
-;; ugh, this works standalone, but not anymore with lily
-(if (not (defined? 'standalone))
-    (begin
-
-      (debug-enable 'backtrace)
-
-      (load "standalone.scm")
-
-      (define (number-pair?  x)
-       (and (pair? x) (number? (car x)) (number? (cdr x))))
-      (define (ly-grob? x) #f)
-      (define (ly-input-location? x) #f)
-      (define (dir? x) #f)
-      (define (moment? x) #f)
-      ))
-
-(use-modules (ice-9 string-fun))
+     desc
+     "\n\n"
+     (description-list->texi propdocs))
+
+    ))
+
+
+(define iface->grob-table (make-vector 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)))
+       )
+
+     (map (lambda (iface)
+           (hashq-set!
+            iface->grob-table iface
+            (cons (car x)
+                  (hashq-ref iface->grob-table iface '())
+                  )))
+         ifaces)
+     ))
+ all-grob-descriptions)
 
-(if standalone
-  (begin
-    (display "(define (list-interface-names) '") 
-    (write (ugh-standalone-list-interface-names))
-    (display ")")
-    (exit 0)))
+;; First level Interface description
+(define (interface-doc interface)
+  (let ((name (symbol->string (car interface))))
+    (make <texi-node>
+      #:name name
+      #:text (string-append
+             (interface-doc-string (cdr interface) #f)
+             "\n\n"
+             "This grob interface is used in the following graphical objects: "
+
+             (human-listify
+              (map ref-ify
+                   (map symbol->string
+                        (hashq-ref iface->grob-table (car interface) '() )))))
+
+      )))
+
+(define (grob-doc description)
+  "Given a property alist DESCRIPTION, make a documentation
+node."
+  
+  (let*
+      (
+       (metah (assoc 'meta description))
+       
+       (meta (cdr metah))
+       (name (cdr (assoc 'name meta)))
+       (ifaces (map lookup-interface (cdr (assoc 'interfaces meta))))
+       (ifacedoc (map (lambda (iface)
+                       (string-append
+"@html
+<hr>
+@end html
+
+@subsubheading "
+(ref-ify (symbol->string (car iface)))
+
+"\n\n"
+                       (interface-doc-string iface description)))
+                     (reverse ifaces)))
+       (engravers (filter-list
+                  (lambda (x) (engraver-makes-grob? name x)) all-engravers-list))
+       (namestr (symbol->string name))
+       (engraver-names (map ly:translator-name engravers))
+       )
 
+    (make <texi-node>
+      #:name namestr
+      #:text
+      (string-append
+       namestr " grobs are created by: "
+       (human-listify (map ref-ify
+                          (map engraver-name engraver-names)))
+       (apply string-append ifacedoc)
+       ))
+    ))
+
+(define (all-grobs-doc)
+  (make <texi-node>
+    #:name "All Graphical objects"
+    #:desc "Description and defaults for all Grobs"
+    #:children
+    (map (lambda (x) (grob-doc (cdr x)))  all-grob-descriptions)))
 
 (define interface-description-alist
   (hash-fold
    (lambda (key val prior)
      (cons (cons key val)  prior)
      )
-   '() (ly-all-grob-interfaces)))
+   '() (ly:all-grob-interfaces)))
 
 (set! interface-description-alist (sort interface-description-alist alist<?))
 
 
 (define (check-dangling-properties prop)
   (if (not (object-property prop 'iface-marked))
-      (error  "\nDangling property: "  prop))
-  )
+      (error  "\ngrob-property-description.scm: Can't find interface for property:" prop)))
 
 (map check-dangling-properties all-backend-properties)
 
 
 (define (lookup-interface name)
   (let*  (
-         (entry  (hashq-ref (ly-all-grob-interfaces) name #f))
+         (entry  (hashq-ref (ly:all-grob-interfaces) name #f))
          )
 
     (if (equal? entry #f)
     entry
 ))
 
-;(write  (map car  interface-description-alist) (current-error-port))
-;(display  (lookup-interface 'volta-bracket-interface))
+(define (all-interfaces-doc)
+  (make <texi-node>
+    #:name "Graphical Object Interfaces"
+    #:desc "Building blocks of graphical objects"
+    #:children
+    (map interface-doc interface-description-alist)
+    ))
 
-(define (document-all-interfaces name)
-  (string-append
-   (texi-node-menu name (map (lambda (x)
-                              (cons (interface-name (symbol->string x)) ""))
-                            (map cadr interface-description-alist)))
-   (apply string-append
-         (map document-separate-interface
-              (map cdr interface-description-alist)))))
-
-(define (document-all-backend-properties name)
+(define (all-backend-properties-doc)
   (let*
       (
        (ps (sort (map symbol->string all-backend-properties) string<?))
        (descs (map (lambda (prop)
-                    (backend-property->texi (string->symbol prop)))
+                    (document-property (string->symbol prop) 'backend #f))
                   ps))
        (texi (description-list->texi descs))
        )
-    
-    (string-append
-     (node name)
-     (texi-section 1 name #f)
-     texi)
-  )
-  )
-
-;;;;;;;;;;;;;;;;
-
+    (make <texi-node>
+      #:name "backend properties"
+      #:desc "all the properties in use as grob properties"
+      #:text texi)
+  ))
+
+;(dump-node (grob-doc (cdadr all-grob-descriptions))  (current-output-port) 0 )
+(define (backend-doc-node)
+  (make <texi-node>
+    #:name "Backend"
+    #:desc "Reference for the layout engine"
+    #:children
+    (list
+     (all-grobs-doc)
+     (all-interfaces-doc)
+     (all-backend-properties-doc)
+     )
+  ))