File: gtk-doc.dsl.in

package info (click to toggle)
gtk-doc 1.3-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 988 kB
  • ctags: 20
  • sloc: perl: 5,673; sh: 701; lisp: 118; makefile: 87
file content (464 lines) | stat: -rw-r--r-- 14,385 bytes parent folder | download | duplicates (5)
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY dbstyle PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA DSSSL>
]>

<style-sheet>
<style-specification use="docbook">
<style-specification-body>

(define gtkdoc-version "")
(define gtkdoc-bookname "")

;; These are some customizations to the standard HTML output produced by the
;; Modular DocBook Stylesheets.
;; I've copied parts of a few functions from the stylesheets so these should
;; be checked occasionally to ensure they are up to date.
;;
;; The last check was with version 1.40 of the stylesheets.
;; It will not work with versions < 1.19 since the $shade-verbatim-attr$
;; function was added then. Versions 1.19 to 1.39 may be OK, if you're lucky!

;;(define %generate-book-toc% #f)

;; If a Chapter has role="no-toc" we don't generate a table of contents.
;; This is useful if a better contents page has been added manually, e.g. for
;; the GTK+ Widgets & Objects page. (But it is a bit of a hack.)
(define ($generate-chapter-toc$)
  (not (equal? (attribute-string (normalize "role") (current-node)) "no-toc")))

(define %chapter-autolabel% 
  ;; Are chapters enumerated?
  #f)

(define %use-id-as-filename% #t)

(define %html-ext% ".html")

(define ($user-html-header$ #!optional
                            (home (empty-node-list))
                            (up (empty-node-list))
                            (prev (empty-node-list))
                            (next (empty-node-list)))
  (make sequence
    (if (not (string=? gtkdoc-version ""))
	(make empty-element gi: "META"
	      attributes: (list
			   (list "NAME" "GENERATOR")
			   (list "CONTENT" (string-append
					  "GTK-Doc V"
					  gtkdoc-version
					  " (SGML mode)"))))
	(empty-sosofo))
    (make element gi: "STYLE"
	  attributes: (list (list "TYPE" "text/css"))
	  (literal ".synopsis, .classsynopsis {
    background: #eeeeee;
    border: solid 1px #aaaaaa;
    padding: 0.5em;
}
.programlisting {
    background: #eeeeff;
    border: solid 1px #aaaaff;
    padding: 0.5em;
}
.variablelist {
    padding: 4px;
    margin-left: 3em;
}
.navigation {
    background: #ffeeee;
    border: solid 1px #ffaaaa;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}
.navigation a {
    color: #770000;
}
.navigation a:visited {
    color: #550000;
}
.navigation .title {
    font-size: 200%;
}"))))


(mode book-titlepage-recto-mode
  (element title 
    (make element gi: "TABLE"
	  attributes: (list
		       (list "CLASS" "navigation")
		       (list "WIDTH" %gentext-nav-tblwidth%)
		       (list "CELLPADDING" "2")
		       (list "CELLSPACING" "0"))
	  (make element gi: "TR"
		(make element gi: "TH"
		      attributes: (list
				   (list "ALIGN" "center")
                                  (list "VALIGN" "MIDDLE"))
		      (make element gi: "P"
			    attributes: (list (list "CLASS" (gi)))
			    (process-children-trim)
			    (make empty-element gi: "A"
				  attributes: (list (list "NAME" (element-id))))))))))

(define (book-titlepage-separator side)
  (empty-sosofo))


;; This overrides the variablelist definition (copied from 1.76,
;; dblists.dsl).  It changes the table background color, cell spacing
;; and cell padding.
;;
;; I have also removed the code to handle the non-table case.
(element variablelist
    (make sequence
      (if %spacing-paras%
          (make element gi: "P" (empty-sosofo))
          (empty-sosofo))
      (para-check)

      (make element gi: "TABLE"
            attributes: '(("CLASS" "variablelist")
			  ("BORDER" "0")
			  ("CELLSPACING" "0")
			  ("CELLPADDING" "4"))
            (if %html40%
                (make element gi: "TBODY"
                      (with-mode variablelist-table
                        (process-children)))
                (with-mode variablelist-table
                  (process-children))))
      (para-check 'restart)))

(mode variablelist-table
  (element (variablelist title)
    (make element gi: "TR"
          attributes: '(("CLASS" "TITLE"))
          (make element gi: "TH"
                attributes: '(("ALIGN" "LEFT")
                              ("VALIGN" "TOP")
                              ("COLSPAN" "2"))
                (process-children))))

  (element varlistentry
    (let* ((terms      (select-elements (children (current-node))
                                        (normalize "term")))
           (listitem   (select-elements (children (current-node))
                                        (normalize "listitem"))))

      (make element gi: "TR"
            (make element gi: "TD"
                  attributes: '(("ALIGN" "LEFT")
                                ("VALIGN" "TOP"))
                  (make empty-element gi: "A"
                        attributes: (list
                                     (list "NAME" (element-id))))
                  (process-node-list terms))
            (make element gi: "TD"
                  attributes: '(("ALIGN" "LEFT")
                                ("VALIGN" "TOP"))
                  (process-node-list listitem)))))
  
  (element (varlistentry term)
    (make sequence
      (if %css-decoration%
          (make element gi: "SPAN"
                attributes: '(("STYLE" "white-space: nowrap"))
                (process-children-trim))
          (make element gi: "NOBR"
                (process-children-trim)))
      (if (not (last-sibling?))
          (literal ", ")
          (literal ""))))

  (element (varlistentry listitem)
    (process-children))
)


;; This overrides the refsect2 definition (copied from 1.20, dbrfntry.dsl).
;; It puts a horizontal rule before each function/struct/... description,
;; except the first one in the refsect1.
(element refsect2
  (make sequence
    (if (first-sibling?)
	(empty-sosofo)
	(make empty-element gi: "HR"))
    ($block-container$)))

;; Override the book declaration, so that we generate a crossreference
;; for the book

(element book 
  (let* ((bookinfo  (select-elements (children (current-node)) (normalize "bookinfo")))
	 (ititle   (select-elements (children bookinfo) (normalize "title")))
	 (title    (if (node-list-empty? ititle)
		       (select-elements (children (current-node)) (normalize "title"))
		       (node-list-first ititle)))
	 (nl       (titlepage-info-elements (current-node) bookinfo))
	 (tsosofo  (with-mode head-title-mode
		     (process-node-list title)))
	 (dedication (select-elements (children (current-node)) (normalize "dedication"))))
    (make sequence
     (html-document 
      tsosofo
      (make element gi: "DIV"
	    attributes: '(("CLASS" "BOOK"))
	    (if %generate-book-titlepage%
		(make sequence
		  (book-titlepage nl 'recto)
		  (book-titlepage nl 'verso))
		(empty-sosofo))
	    
	    (if (node-list-empty? dedication)
		(empty-sosofo)
		(with-mode dedication-page-mode
		  (process-node-list dedication)))
	    
	    (if (not (generate-toc-in-front))
		(process-children)
		(empty-sosofo))
	    
	    (if %generate-book-toc%
		(build-toc (current-node) (toc-depth (current-node)))
		(empty-sosofo))
	    
	    ;;	  (let loop ((gilist %generate-book-lot-list%))
	    ;;	    (if (null? gilist)
	    ;;		(empty-sosofo)
	    ;;		(if (not (node-list-empty? 
	    ;;			  (select-elements (descendants (current-node))
	    ;;					   (car gilist))))
	    ;;		    (make sequence
	    ;;		      (build-lot (current-node) (car gilist))
	    ;;		      (loop (cdr gilist)))
	    ;;		    (loop (cdr gilist)))))
	  
	    (if (generate-toc-in-front)
		(process-children)
		(empty-sosofo))))
     (make entity 
       system-id: "index.sgml"
       (with-mode generate-index-mode
	 (process-children))))))

;; Mode for generating cross references

(define (process-child-elements)
  (process-node-list
   (node-list-map (lambda (snl)
                    (if (equal? (node-property 'class-name snl) 'element)
                        snl
                        (empty-node-list)))
                  (children (current-node)))))

(mode generate-index-mode
  (element anchor
    (if (attribute-string "href" (current-node))
	(empty-sosofo)
	(make formatting-instruction data:
	      (string-append "\less-than-sign;ANCHOR id =\""
			     (attribute-string "id" (current-node))
			     "\" href=\""
			     (if (not (string=? gtkdoc-bookname ""))
				 (string-append gtkdoc-bookname "/")
				 "")
			     (href-to (current-node))
			     "\"\greater-than-sign;
"))))

  ;; We also want to be able to link to complete RefEntry.
  (element refentry
    (make sequence
      (make formatting-instruction data:
	    (string-append "\less-than-sign;ANCHOR id =\""
			   (attribute-string "id" (current-node))
			   "\" href=\""
			   (if (not (string=? gtkdoc-bookname ""))
			       (string-append gtkdoc-bookname "/")
			       "")
			   (href-to (current-node))
			   "\"\greater-than-sign;
"))
      (process-child-elements)))

  (default
    (process-child-elements)))

;; For hypertext links for which no target is found in the document, we output
;; our own special tag which we use later to resolve cross-document links.
(element link 
  (let* ((target (element-with-id (attribute-string (normalize "linkend")))))
    (if (node-list-empty? target)
      (make element gi: "GTKDOCLINK"
	    attributes: (list
			 (list "HREF" (attribute-string (normalize "linkend"))))
            (process-children))
      (make element gi: "A"
            attributes: (list
                         (list "HREF" (href-to target)))
            (process-children)))))


;; This overrides default-header-nav-tbl-noff (copied from 1.20, dbnavig.dsl).
;; I want 'Home' and 'Up' links at the top of each page, and white text on
;; black.
(define (default-header-nav-tbl-noff elemnode prev next prevsib nextsib)
  (let* ((up (parent elemnode))
	 (home (nav-home elemnode))
	 (show-title? (nav-banner? elemnode))
	 (title-sosofo
	      (make element gi: "TH"
		    attributes: (list
				 (list "WIDTH" "100%")
				 (list "align" "center"))
		    (if show-title?
			(nav-banner elemnode)
			(empty-sosofo))))
	 (show-banner? (or show-title?
			   (not (node-list-empty? prev))
			   (not (node-list-empty? next))
			   (nav-context? elemnode)))
	 (banner-sosofo
	      (make element gi: "TR"
		    attributes: (list
				 (list "VALIGN" "middle"))
		    (if (not (node-list-empty? prev))
			(make element gi: "TD"
			      (make element gi: "A"
				    attributes: (list
						 (list "ACCESSKEY" "p")
						 (list "HREF"
						       (href-to prev)))
				    (make empty-element gi: "IMG"
					  attributes: (list
						       (list "SRC" "left.png")
						       (list "WIDTH" "24")
						       (list "HEIGHT" "24")
						       (list "BORDER" "0")
						       (list "ALT" "Prev")))))
			(empty-sosofo))
		    (if (nav-up? elemnode)
			(make element gi: "TD"
			      (make element gi: "A"
				    attributes: (list
						 (list "ACCESSKEY" "u")
						 (list "HREF"
						       (href-to up)))
				    (make empty-element gi: "IMG"
					  attributes: (list
						       (list "SRC" "up.png")
						       (list "WIDTH" "24")
						       (list "HEIGHT" "24")
						       (list "BORDER" "0")
						       (list "ALT" "Up")))))
			(empty-sosofo))
		    (if (nav-home? elemnode)
			(make element gi: "TD"
			      (make element gi: "A"
				    attributes: (list
						 (list "ACCESSKEY" "h")
						 (list "HREF"
						       (href-to home)))
				    (make empty-element gi: "IMG"
					  attributes: (list
						       (list "SRC" "home.png")
						       (list "WIDTH" "24")
						       (list "HEIGHT" "24")
						       (list "BORDER" "0")
						       (list "ALT" "Home")))))
			(empty-sosofo))
		    title-sosofo
		    (if (not (node-list-empty? next))
			(make element gi: "TD"
			      (make element gi: "A"
				    attributes: (list
						 (list "ACCESSKEY" "n")
						 (list "HREF"
						       (href-to next)))
				    (make empty-element gi: "IMG"
					  attributes: (list
						       (list "SRC" "right.png")
						       (list "WIDTH" "24")
						       (list "HEIGHT" "24")
						       (list "BORDER" "0")
						       (list "ALT" "Next")))))
			(empty-sosofo)))))
	 
    (if show-banner?
	(make element gi: "TABLE"
	      attributes: (list
			   (list "WIDTH" %gentext-nav-tblwidth%)
			   (list "CLASS" "navigation")
			   (list "SUMMARY" "Navigation header")
			   (list "CELLPADDING" "2")
			   (list "CELLSPACING" "2"))
	      banner-sosofo)
	(empty-sosofo))))

;; This overrides default-footer-nav-tbl (copied from 1.20, dbnavig.dsl).
;; It matches the header above.
(define (default-footer-nav-tbl elemnode prev next prevsib nextsib)
  (let* ((show-footer? (or (not (node-list-empty? prev))
			  (not (node-list-empty? next))))
	 (footer-sosofo
	     (make element gi: "TR"
		   attributes: (list
				(list "VALIGN" "middle"))
		   (make element gi: "TD"
			 attributes: (list
				      (list "ALIGN" "left"))
			 (if (not (node-list-empty? prev))
			     (make element gi: "A"
				   attributes: (list
						(list "ACCESSKEY" "p")
						(list "HREF" (href-to prev)))
				   (make element gi: "B"
					 (make entity-ref name: "lt")
					 (make entity-ref name: "lt")
					 (make entity-ref name: "lt")
					 (make entity-ref name: "nbsp")
					 (element-title-sosofo prev)))
			     (empty-sosofo)))
		   (make element gi: "TD"
			 attributes: (list
				      (list "ALIGN" "right"))
			 (if (not (node-list-empty? next))
			     (make element gi: "A"
				   attributes: (list
						(list "ACCESSKEY" "n")
						(list "HREF" (href-to next)))
				   (make element gi: "B"
					 (element-title-sosofo next)
					 (make entity-ref name: "nbsp")
					 (make entity-ref name: "gt")
					 (make entity-ref name: "gt")
					 (make entity-ref name: "gt")))
			     (empty-sosofo))))))
  
    (if show-footer?
	(make element gi: "TABLE"
	      attributes: (list
			   (list "CLASS" "navigation")
			   (list "WIDTH" %gentext-nav-tblwidth%)
			   (list "SUMMARY" "Navigation footer")
			   (list "CELLPADDING" "2")
			   (list "CELLSPACING" "2"))
	      footer-sosofo)
	(empty-sosofo))))


(define ($section-body$)
  (make sequence
    (make empty-element gi: "BR"
	  attributes: (list (list "CLEAR" "all")))
    (make element gi: "DIV"
	  attributes: (list (list "CLASS" (gi)))
	  ($section-separator$)
	  ($section-title$)
	  (process-children))))

</style-specification-body>
</style-specification>
<external-specification id="docbook" document="dbstyle">
</style-sheet>