+;;;; This file is part of LilyPond, the GNU music typesetter.
+;;;;
+;;;; Copyright (C) 2000--2015 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/>.
+
+(use-modules (oop goops)
+ (srfi srfi-13)
+ (srfi srfi-1))
+
+(if (guile-v2)
+ (use-modules (ice-9 curried-definitions)))
+
+(define-class <texi-node> ()
+ (appendix #:init-value #f #:accessor appendix? #:init-keyword #:appendix)
+ (children #:init-value '() #:accessor node-children #:init-keyword #:children)
+ (text #:init-value "" #:accessor node-text #:init-keyword #:text)
+ (name #:init-value "" #:accessor node-name #:init-keyword #:name)
+ (description #:init-value "" #:accessor node-desc #:init-keyword #:desc))
+
+(define (menu-entry x)
+ (cons
+ (node-name x)
+ (node-desc x)))
+
+(define* (dump-node node port level)
+ (display
+ (string-append
+ "\n@node "
+ (if (= level 0) "Top" (node-name node))
+ "\n"
+ (if (appendix? node)
+ (texi-appendix-section-command level)
+ (texi-section-command level))
+ " "
+ (node-name node)
+ "\n\n"
+ (node-text node)
+ "\n\n"
+ (if (pair? (node-children node))
+ (texi-menu
+ (map menu-entry (node-children node)))
+ ""))
+ port)
+ (for-each (lambda (x) (dump-node x port (+ 1 level)))
+ (node-children node)))