This file is indexed.

/usr/share/lilypond/2.14.2/scm/document-translation.scm is in lilypond-data 2.14.2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
;;;; 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))))

(define (engraver-accepts-music-type? name-symbol grav)
  (memq name-symbol (assoc 'events-accepted (ly:translator-description grav))))

(define (engraver-accepts-music-types? types grav)
  (if (null? types)
      #f
      (or
       (engraver-accepts-music-type? (car types) grav)
       (engraver-accepts-music-types? (cdr types) grav))))

(define (engraver-doc-string engraver in-which-contexts)
  (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 (assoc-get 'description (ly:translator-description engraver)))
	 (grobs (engraver-grobs engraver)))

    (string-append
     desc
     "\n\n"
     (if (pair? accepted)
	 (string-append
	  "Music types accepted:\n\n"
	  (human-listify
	   (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 '()))
	        (sort propsr ly:symbol-ci<?))
	   #t))
	 "")

     (if (null? propsw)
	 ""
	 (string-append
	  "Properties (write)"
	  (description-list->texi
	   (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 ly:string-ci<?))))
	   "."))

     "\n\n"

     (if in-which-contexts
	 (let* ((layout-alist (ly:output-description $defaultlayout))
		(context-description-alist (map cdr layout-alist))
		(contexts
		 (apply append
			(map
			 (lambda (x)
			   (let* ((context (assoc-get 'context-name x))
				  (group (assq-ref x 'group-type))
				  (consists (append
					     (if group
						 (list group)
						 '())
					     (assoc-get 'consists x))))
			     (if (member name-sym consists)
				 (list context)
				 '())))
			 context-description-alist)))
		(context-list (human-listify (map ref-ify
						  (sort
						   (map symbol->string contexts)
						   ly:string-ci<?)))))
	   (string-append
	    "@code{" name-str "} "
	    (if (equal? context-list "none")
		"is not part of any context"
		(string-append
		 "is part of the following context(s): "
		 context-list))
	    "."))
	 ""))))

;; First level Engraver description
(define (engraver-doc grav)
  (make <texi-node>
    #:name (symbol->string (ly:translator-name grav))
    #:text (engraver-doc-string grav #t)))

;; Second level, part of Context description
(define name->engraver-table (make-hash-table 61))
(map
 (lambda (x)
   (hash-set! name->engraver-table (ly:translator-name x) x))
 (ly:get-all-translators))

(define (find-engraver-by-name name)
  "NAME is a symbol."
  (hash-ref name->engraver-table name #f))

(define (document-engraver-by-name name)
  "NAME is a symbol."

  (let* ((eg (find-engraver-by-name name)))

    (cons (string-append "@code{" (ref-ify (symbol->string name)) "}")
	  (engraver-doc-string eg #f))))

(define (document-property-operation op)
  (let ((tag (car op))
	(context-sym (cadr op))
	(args (cddr op))
	)

    (cond
     ((equal?  tag 'push)
      (let*
	  ((value (car args))
	   (path (cdr args)))

      (string-append
       "@item Set "
       (format "grob-property @code{~a} "
	       (string-join (map symbol->string path) " "))
       (format "in @ref{~a} to ~a."
	       context-sym (scm->texi value))
       "\n")))
     ((equal? (object-property context-sym 'is-grob?) #t) "")
     ((equal? tag 'assign)
      (format "@item Set translator property @code{~a} to ~a.\n"
	      context-sym
	      (scm->texi (car args))))
     )))


(define (context-doc context-desc)
  (let* ((name-sym (assoc-get 'context-name context-desc))
	 (name (symbol->string name-sym))
	 (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 ref-ify (sort grobs ly:string-ci<?))))

    (make <texi-node>
      #:name name
      #:text
      (string-append
       desc
       (if (pair? aliases)
	   (string-append
	    "\n\nThis context also accepts commands for the following context(s):\n\n"
	    (human-listify (sort aliases ly:string-ci<?))
	    ".")
	   "")

       "\n\nThis context creates the following layout object(s):\n\n"
       (human-listify (uniq-list grob-refs))
       "."

       (if (and (pair? props) (not (null? props)))
	   (let ((str (apply string-append
		             (sort (map document-property-operation props)
			           ly:string-ci<?))))
	     (if (string-null? str)
		 ""
		 (string-append
		  "\n\nThis context sets the following properties:\n\n"
		  "@itemize @bullet\n"
		  str
		  "@end itemize\n")))
	   "")

       (if (null? accepts)
	   "\n\nThis context is a `bottom' context; it cannot contain other contexts."
	   (string-append
	    "\n\nContext "
	    name
	    " can contain\n"
	    (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 (sort consists ly:symbol-ci<?))
	     #t)))))))

(define (engraver-grobs grav)
  (let* ((eg (if (symbol? grav)
		 (find-engraver-by-name grav)
		 grav)))
    (if (eq? eg #f)
	'()
	(map symbol->string (assoc-get 'grobs-created (ly:translator-description eg))))))

(define (context-grobs context-desc)
  (let* ((group (assq-ref context-desc 'group-type))
	 (consists (append
		    (if group
			(list group)
			'())
		    (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) (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>
      #:name "Contexts"
      #:desc "Complete descriptions of all contexts."
      #:children
      (map context-doc contexts))))

(define all-engravers-list  (ly:get-all-translators))
(set! all-engravers-list
      (sort all-engravers-list
	    (lambda (a b) (ly:string-ci<? (symbol->string (ly:translator-name a))
				    (symbol->string (ly:translator-name b))))))

(define (all-engravers-doc)
  (make <texi-node>
    #:name "Engravers and Performers"
    #:desc "All separate engravers and performers."
    #:text "See @ruser{Modifying context plug-ins}."
    #:children
    (map engraver-doc all-engravers-list)))

(define (translation-properties-doc-string lst)
  (let* ((ps (sort (map symbol->string lst) ly:string-ci<?))
	 (sortedsyms (map string->symbol ps))
	 (propdescs
	  (map
	   (lambda (x) (property->texi 'translation  x '()))
	   sortedsyms))
	 (texi (description-list->texi propdescs #f)))
    texi))

(define (translation-doc-node)
  (make <texi-node>
    #:name "Translation"
    #:desc "From music to layout."
    #:children
    (list
     (all-contexts-doc)
     (all-engravers-doc)
     (make <texi-node>
       #:name "Tunable context properties"
       #:desc "All tunable context properties."
       #:text (translation-properties-doc-string
	       all-user-translation-properties))

     (make <texi-node>
       #:name "Internal context properties"
       #:desc "All internal context properties."
       #:text (translation-properties-doc-string
	       all-internal-translation-properties)))))