~gdesklets-desklet-team/gdesklets/0.36

« back to all changes in this revision

Viewing changes to doc/book/tutor-tutor.xml

  • Committer: Robert Pastierovic
  • Date: 2007-10-07 10:08:42 UTC
  • Revision ID: pastierovic@gmail.com-20071007100842-fdvp2vzmqgh1j87k
merged 0.3x branch and basic documentation and some other changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<section id="tutor-tutor"  xmlns:xi="http://www.w3.org/2001/XInclude">
 
2
  <title>Tutorial Meta-Tutorial</title>
 
3
 
 
4
<para>by Martin Grimme</para>
 
5
 
 
6
 
 
7
<section><title>Introduction</title>
 
8
 
 
9
  <para>You can contribute to the tutorials chapter by writing new tutorials.
 
10
    This meta-tutorial shows you how to write compliant tutorials for this
 
11
    book.</para>
 
12
     
 
13
</section>
 
14
 
 
15
 
 
16
 
 
17
<section><title>DocBook</title>
 
18
 
 
19
  <para>DocBook is a widely used standard for writing documentation. It is a
 
20
    semantic markup language based on SGML. Recently, DocBook has been ported
 
21
    to XSLT stylesheets, so that any XSLT processor can process DocBook sources.
 
22
    The XSLT stylesheets we are using for generating HTML pages are those of
 
23
    the <application>yelp</application> project, because they are fast and
 
24
    produce good output.</para>
 
25
 
 
26
  <para>It's not the purpose of this tutorial to teach you DocBook. There are
 
27
    plenty of other tutorials available, which do a much better job at that.
 
28
    Here is a collection of resources to get you started with DocBook:</para>
 
29
 
 
30
  <itemizedlist>
 
31
    <listitem><ulink url="http://www.docbook.org"/> - The home of DocBook. You
 
32
      can find lots of information and documentation there.</listitem>
 
33
    <listitem><ulink url="http://docbook.sourceforge.net"/> - The DocBook Open
 
34
      Repository is the official home of the DocBook stylesheets.</listitem>
 
35
    <listitem><ulink url="http://www.docbook.org/tdg/en/html/docbook.html"/> -
 
36
      DocBook: The Definitive Guide. The name says it all. This is the online
 
37
      version of the most comprehensive DocBook book out there by
 
38
      Norman Walsh and Leonard Muellner.</listitem>
 
39
    <listitem><ulink url="http://developer.gnome.org/projects/gdp/handbook/gdp-handbook/index.html"/> -
 
40
      GNOME Handbook of Writing Software Documentation. This online book is a
 
41
      good source of information for writing software documentation with
 
42
      DocBook.</listitem>
 
43
    <listitem><ulink url="http://www.bartleby.com/141/"/> - The Elements of
 
44
      Style. This book is about good writing style.</listitem>
 
45
  </itemizedlist>
 
46
 
 
47
</section>
 
48
 
 
49
 
 
50
 
 
51
<section><title>Template</title>
 
52
 
 
53
  <para>To make stuff look uniform, please use the provided template for
 
54
    writing tutorials. You can copy and paste it into a new file from below:
 
55
    </para>
 
56
 
 
57
  <literallayout><xi:include href="tutor-TEMPLATE.xml" parse="text"/></literallayout>
 
58
 
 
59
  <para>The filename must start with "<filename>tutor-</filename>" and have the
 
60
    extension "<filename>.xml</filename>". After the hyphen, you include the
 
61
    (abbreviated) name of your tutorial. This name must be unique within the
 
62
    whole book. The same name with the "<literal>tutor-</literal>" prefix goes
 
63
    into the <property>id</property> attribute in the <command>section</command>
 
64
    tag in the first line of the document.</para>
 
65
 
 
66
</section>
 
67
 
 
68
 
 
69
 
 
70
<section><title>Screenshots</title>
 
71
 
 
72
  <para>A picture is worth a thousand words. Screenshots (and diagrams) help you
 
73
    illustrate what you're talking about. Please make good use of them because
 
74
    the reader will appreciate it.</para>
 
75
 
 
76
  <para>Screenshots can be included in DocBook like this:</para>
 
77
 
 
78
  <programlisting><![CDATA[
 
79
<screenshot>
 
80
  <mediaobject>
 
81
    <imageobject>
 
82
      <imagedata fileref="gfx/my-image" format="PNG"/>
 
83
    </imageobject>
 
84
  </mediaobject>
 
85
</screenshot>
 
86
  ]]></programlisting>
 
87
 
 
88
  <para>Please note that the filename does not get the suffix here. The file
 
89
    itself has the <filename>.png</filename> suffix, of course. The included
 
90
    files have to be in the PNG format (GIF used to be non-free and is now
 
91
    deprecated, and JPEG isn't free either).</para>
 
92
 
 
93
  <para>The filename of the screenshot must be unique within the book, too.
 
94
    It is recommended to start all filenames with the (abbreviated) name of
 
95
    your tutorial.</para>
 
96
 
 
97
</section>
 
98
 
 
99
 
 
100
 
 
101
<section><title>Showing XML</title>
 
102
 
 
103
  <para>In a tutorial for <application>gDesklets</application>, it's often
 
104
    necessary to show example code which is XML. Example code can be
 
105
    displayed with the <command>&lt;programlisting&gt;</command> tag:</para>
 
106
 
 
107
  <programlisting><![CDATA[
 
108
<programlisting>
 
109
 
 
110
  ...
 
111
 
 
112
</programlisting>
 
113
  ]]></programlisting>
 
114
 
 
115
  <para>A problem, however, is that the XML code of course uses characters
 
116
    which are reserved by XML, such as "&lt;" and "&gt;". You can get around
 
117
    this limitation by putting the example into a CDATA section:</para>
 
118
 
 
119
  <programlisting><![CDATA[
 
120
<programlisting><![CDATA[
 
121
 
 
122
  ...
 
123
 
 
124
]]>]]&gt;<![CDATA[</programlisting>
 
125
  ]]></programlisting>
 
126
 
 
127
  <para>There remains only one problem: CDATA sections cannot be nested. So,
 
128
    what if your example contains CDATA sections as well?</para>
 
129
 
 
130
  <para>The solution is to split the CDATA section into two CDATA sections
 
131
    at the point where the CDATA section in the example code ends:</para>
 
132
 
 
133
  <programlisting><![CDATA[
 
134
<programlisting><![CDATA[
 
135
 
 
136
  <![CDATA[ ... ]]>]]&gt;<![CDATA[
 
137
 
 
138
]]>]]&gt;<![CDATA[</programlisting>
 
139
  ]]></programlisting>
 
140
 
 
141
  <para>must be written as</para>
 
142
 
 
143
  <programlisting><![CDATA[
 
144
<programlisting><![CDATA[
 
145
 
 
146
  ...
 
147
  <![CDATA[ ... ]]>]]&gt;]]&amp;gt;&lt;![CDATA[<![CDATA[
 
148
  
 
149
]]>]]&gt;<![CDATA[</programlisting>
 
150
  ]]></programlisting>
 
151
 
 
152
  <para>This might look confusing at first, but the simple rule is that every
 
153
    occurrence of "<literal>]]&gt;</literal>" has just to be extended with
 
154
    "<literal>]]&amp;gt;&lt;![CDATA[</literal>".</para>
 
155
 
 
156
</section>
 
157
 
 
158
 
 
159
 
 
160
<section><title>Previewing Your Work</title>
 
161
 
 
162
  <para>To preview the new tutorial file, you have to embed it into a valid
 
163
    DocBook file. The tutorial file is just a section and not a complete
 
164
    DocBook file.</para>
 
165
 
 
166
  <para>The easiest way to embed it into a DocBook file is by getting the
 
167
    DocBook sources of this book from CVS and include your file in the
 
168
    tutorials chapter.</para>
 
169
 
 
170
  <para>You can retrieve the DocBook sources like this:</para>
 
171
 
 
172
  <screen>
 
173
    <prompt>$> </prompt><userinput>export CVSROOT=:pserver:anonymous@anoncvs.gnome.org/cvs/gnome</userinput>
 
174
    <prompt>$> </prompt><userinput>cvs login</userinput>
 
175
    (press <key>Enter</key> when asked for a password)
 
176
    <prompt>$> </prompt><userinput>cvs co gdesklets/doc/book</userinput>
 
177
  </screen>
 
178
 
 
179
  <para>Then you can include your tutorial in the file
 
180
    <filename>tutor.xml</filename> using XInclude like this:</para>
 
181
 
 
182
  <programlisting><![CDATA[
 
183
...
 
184
 
 
185
  <xi:include href="tutor-xml.xml"/>
 
186
  <xi:include href="tutor-hello.xml"/>
 
187
  <xi:include href="tutor-canvas.xml"/>
 
188
  ...
 
189
  <xi:include href="tutor-mytutorial.xml"/>
 
190
 
 
191
...
 
192
  ]]></programlisting>
 
193
 
 
194
  <para>The book can be previewed with the <application>yelp</application> tool
 
195
    of the <application>GNOME</application> desktop:</para>
 
196
 
 
197
  <screen>
 
198
    <prompt>$> </prompt><userinput>yelp ghelp://$PWD/book.xml</userinput>
 
199
  </screen>
 
200
 
 
201
  <para>The script <filename>make-html.sh</filename> can be called to convert
 
202
    the DocBook files to HTML using the <application>yelp</application>
 
203
    stylesheets (<application>yelp</application> must be installed):</para>
 
204
 
 
205
  <screen>
 
206
    <prompt>$> </prompt><userinput>./make-html.sh book.xml output</userinput>
 
207
  </screen>
 
208
 
 
209
  <para>The book can then be found in <filename>output/index.html</filename>.
 
210
    </para>
 
211
</section>
 
212
 
 
213
</section>