aboutsummaryrefslogtreecommitdiff
path: root/doc/user/engine.skb
blob: 183f26d44217aede31ece06ff3cefc2056b378ac (plain)
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
;;; engine.skb  --  Description of Skribilo engines.
;;;
;;; Copyright 2003, 2004  Manuel Serrano
;;; Copyright 2006  Ludovic Court�s  <ludovic.courtes@laas.fr>
;;;
;;;
;;; This program 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 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program 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 this program; if not, write to the Free Software
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;;; USA.


(cond-expand 
   (guile
    (define *engine-src*  "skribilo/engine.scm")
    (define *types-src*   #f))
   (bigloo 
    (define *engine-src*  "../src/bigloo/engine.scm")
    (define *types-src*   "../src/bigloo/types.scm"))
   (stklos
    (define *engine-src*  "../src/stklos/engine.stk")
    (define *types-src*   "../src/stklos/types.stk")))

;*---------------------------------------------------------------------*/
;*    Engine                                                           */
;*---------------------------------------------------------------------*/
(chapter :title "Engines" 

   (p [When Skribilo produces a document in a given format, it uses a
specialized engine. For instance, when a Web page is made from a
Skribilo document, an HTML engine is used. The engine classes provided
by Skribe are given below:])

   (resolve (lambda (n e env)
	       (let* ((current-chapter (ast-chapter n))
		      (body  (map (lambda (x) (if (pair? x) (car x) x))
				  (markup-body current-chapter)))
		      (sects (filter (lambda (x) (is-markup? x 'section))
				     body)))
		  (itemize 
		     (map (lambda (x)
			     (let ((title (markup-option x :title)))
				(item (ref :text title :section title))))
			  sects)))))

   (p [Skribilo differentiates an ,(emph [engine class]) from an ,(emph
[engine]).  An engine class defines the overall behavior of a type of
engine (e.g., HTML, Lout, LaTeX, etc.).  This includes, for instance,
information about how to produce particular symbols and how to produce
various markups in the particular format represented by the engine class
(e.g., a ,(code [code]) markup can be rendered using the ,(code
[<code>]) tag in HTML).  Conversely, an engine is an ,(emph [instance])
of an engine class.  Therefore, the behavior of an engine is mostly
defined by its class, but engines can have their own settings (e.g.,
their own ,(ref :text (emph [customs]) :ident "engine-customs")) that
can defer from the default settings specified by their class.])
   (p [Skribe users will notice that this is slightly different from
Skribe's notion of an engine which encompasses both notions (or, in
other words, Skribe only allow the instantiation of one engine for each
engine class).  A compatibility layer is available in the ,(code
"(skribilo utils compat)") module.])

   (section :title "Functions Dealing With Engines"
      
      (subsection :title "Creating Engine Classes"
	 (p [The function ,(code "make-engine-class") creates a brand
new engine class.])
	 
	 (doc-markup 'make-engine-class
	    '((ident [The name (a symbol) of the new engine class.])
	      (:version [The version number.])
	      (:format [The output format (a string) of this engine class.])
	      (:filter [A string filter (a function).])
	      (:delegate [A delegate engine class.])
	      (:symbol-table [The engine class symbol table.])
	      (:custom [The engine class custom list and default values.])
	      (:info [Miscellaneous information.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)

	 (p [Once an engine class has been created or ,(ref :text
[retrieved] :ident "engine-lookup"), it can be instantiated using ,(code
"make-engine"):])
	 
	 (doc-markup 'make-engine
	    '((engine-class [The engine class that is to be
instantiated.]))
	    :common-args '()
	    :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)

	 (p [Each engine has its own values for its customs (initially
the default values that were specified in the ,(code ":custom")
parameter passed when creating its class).  Thus, it is possible to have
several engines of a same class that peacefully coexist, even with
different customs.])

	 (p [The function ,(code "copy-engine") duplicates an existing engine.])
	 (doc-markup 'copy-engine
	    '((e [The engine to be duplicated.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*))
	      
      (subsection :title "Retrieving Engines"
	          :ident "engine-lookup"
	 
	 (p [It is customary to fetch an engine class from Skribilo's
directory (e.g., the ,(ref :text [HTML engine] :ident "html-engine"),
the ,(ref :text [LaTeX engine] :ident "latex-engine")) using ,(code
"lookup-engine-class") (for instance, this is what the ,(code
"--target") option of the ,(code "skribilo") program does).])
	 
	 (doc-markup 'lookup-engine-class
	    '((id [The name (a symbol) of the engine class that is looked
for.])
	      (:version [The version number.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)

	 (p [This function is roughly equivalent to Skribe's ,(code
"find-engine"), with the noticeable difference that ,(code
"find-engine") returns an engine rather than an engine class.]))
      
      (subsection :title "Engine accessors"
	 (p [The predicate ,(code "engine?") returns ,(code "#t") if its
argument is an engine. Otherwise, it returns ,(code "#f"). In other words,
,(code "engine?") returns ,(code "#t") for objects created by 
,(code "make-engine"), ,(code "copy-engine"), and ,(code "find-engine").])
	 (doc-markup 'engine?
	    '((obj [The checked object.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)
	 
	 (p [The following functions return information about engines.])
	 
	 (doc-markup 'engine-ident
	    '((obj [The engine.]))
	    :common-args '()
	    :others '(engine-format engine-filter engine-symbol-table)
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*))
      
      (subsection :title "Engine Customs"
	          :ident "engine-customs"
	 
	 (p [Engine customs are locations where dynamic informations relative
to engines can be stored. Engine custom can be seen a global variables that
are specific to engines. The function ,(code "engine-custom") returns the
value of a custom or ,(code "#f") if that custom is not defined. The
function ,(code "engine-custom-set!") defines or sets a new value for
a custom.])

	 (doc-markup 'engine-custom
	    `((e ,[The engine (as returned by 
,(ref :mark "make-engine" :text (code "make-engine"))).])
	      (id [The name of the custom.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)
	 
	 (doc-markup 'engine-custom-set!
	    `((e ,[The engine (as returned by 
,(ref :mark "make-engine" :text (code "make-engine"))).])
	      (id [The name of the custom.])
	      (val [The new value of the custom.]))
	    :common-args '()
            :skribe-source? #f
	    :source *engine-src*
	    :idx *function-index*)))

   ;; existing engines
   (include "htmle.skb")
   (include "latexe.skb")
   (include "xmle.skb"))