~ubuntu-branches/ubuntu/trusty/gnome-doc-utils/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/mallard/es/mal_inline_code.page

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-02-23 15:55:38 UTC
  • mfrom: (1.1.29 upstream)
  • Revision ID: james.westby@ubuntu.com-20100223155538-odq0bbr5tl0p2lpv
Tags: 0.19.5-0ubuntu1
* New upstream release:
  - Updated the Mallard RNG schema (Shaun McCance)
  - Bold userinput inside programlisting (Shaun McCance)
  - Updated translations
* debian/control.in:
  - bump Standards-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="utf-8"?>
2
 
<page xmlns="http://projectmallard.org/1.0/" type="topic" id="mal_inline_code">
3
 
 
4
 
<info>
5
 
  <link type="guide" xref="mal_inline#elements"/>
6
 
 
7
 
  <revision version="0.1" date="2008-12-12" status="review"/>
8
 
 
9
 
  <credit type="author">
10
 
    <name>Shaun McCance</name>
11
 
    <email>shaunm@gnome.org</email>
12
 
    <years>2008-2009</years>
13
 
  </credit>
14
 
 
15
 
  <include xmlns="http://www.w3.org/2001/XInclude" href="legal.xml"/>
16
 
 
17
 
  <desc>Mark up code from a programming, markup, or other machine-readable format.</desc>
18
 
</info>
19
 
 
20
 
<title>Code Snippets</title>
21
 
 
22
 
<synopsis><code mime="application/relax-ng-compact-syntax">
23
 
mal_inline_code = element code {
24
 
  <link xref="mal_attr_link">mal_attr_link</link> ?,
25
 
  attribute style { xsd:NMTOKENS } ?,
26
 
  attribute mime { text } ?,
27
 
  attribute * - (mal:* | local:*) { text } *,
28
 
 
29
 
  <link xref="mal_inline">mal_inline</link>
30
 
}
31
 
</code></synopsis>
32
 
 
33
 
<p>Use the <code>code</code> element to mark up a portion of text from a
34
 
computer language.  This includes programming languages, markup languages,
35
 
and the contents of any type of file with a structured syntax.  For commands
36
 
which are run in an interactive shell, however, you should use the
37
 
<code xref="mal_inline_cmd">cmd</code> element, even though they may
38
 
include snippets of shell programming.</p>
39
 
 
40
 
<p>You can use the <code>code</code> element to mark up any portion of
41
 
code, including comments or textual content that doesn't strictly follow
42
 
any syntax.</p>
43
 
 
44
 
<p>Use the <code xref="mal_inline_var">var</code> element inside a
45
 
<code>code</code> element to indicate text that should be replaced
46
 
by the user.</p>
47
 
 
48
 
 
49
 
<!-- BEGIN notes -->
50
 
<section id="notes">
51
 
  <title>Notas</title>
52
 
  <list>
53
 
    <item><p>The <code>code</code> element can contain a mixture of text and
54
 
    any <link xref="mal_inline">general inline elements</link>.</p></item>
55
 
 
56
 
    <item><p>The <code>code</code> element can occur in any
57
 
    general inline context, including inside most
58
 
    <link xref="mal_inline">inline elements</link>, some
59
 
    <link xref="mal_block#basic">basic block elements</link>, and certain
60
 
    <link xref="mal_info">informational elements</link>.</p></item>
61
 
 
62
 
    <item><p>The <code>code</code> element can link to other pages or documents.
63
 
    See <link xref="mal_attr_link"/> for more information.</p></item>
64
 
 
65
 
    <item><p>The <code>style</code> attribute takes a space-separated list of
66
 
    style hints.  Processing tools should adjust their behavior according to
67
 
    those style hints they understand.</p></item>
68
 
 
69
 
    <item><p>The <code>mime</code> attribute takes a valid MIME type.  Processing
70
 
    tools may adjust their behavior for particular MIME types.</p></item>
71
 
 
72
 
    <item><p>The <code>code</code> element can have attributes from external
73
 
    namespaces.  See <link xref="mal_external"/> for more information
74
 
    on external-namespace attributes.</p></item>
75
 
 
76
 
    <item><p>The <code>code</code> element may also be used in a block context.
77
 
    See <link xref="mal_block_code"/> for more information.</p></item>
78
 
  </list>
79
 
</section>
80
 
<!-- END notes -->
81
 
 
82
 
 
83
 
<!-- BEGIN examples -->
84
 
<section id="examples">
85
 
  <title>Ejemplos</title>
86
 
 
87
 
  <p>Use <code>code</code> to mark up the name of a function, struct, or other
88
 
  constuct in a programming language:</p>
89
 
 
90
 
  <example>
91
 
    <code><![CDATA[
92
 
Use <code>gtk_container_add</code> to add a child widget to a
93
 
<code>GtkButton</code>.
94
 
]]></code>
95
 
    <p>Use <code>gtk_container_add</code> to add a child widget to a <code>GtkButton</code>.</p>
96
 
  </example>
97
 
 
98
 
  <p>Use <code>code</code> with <code xref="mal_inline_var">var</code> to mark
99
 
  up code with a placeholder for an argument the user should supply:</p>
100
 
 
101
 
  <example>
102
 
    <code><![CDATA[
103
 
To create a new button with a label, use
104
 
<code>gtk_button_new_with_label(<var>label</var>)</code>,
105
 
replacing <var>label</var> with the text of the label.
106
 
]]></code>
107
 
    <p>To create a new button with a label, use
108
 
    <code>gtk_button_new_with_label(<var>label</var>)</code>,
109
 
    replacing <var>label</var> with the text of the label.</p>
110
 
  </example>
111
 
 
112
 
  <p>Link to a web page directly with a <code>code</code> element:</p>
113
 
 
114
 
  <example>
115
 
    <code><![CDATA[
116
 
Use <code>code</code> with <code xref="mal_inline_var">var</code> to mark
117
 
up code with a placeholder for an argument the user should supply.
118
 
]]></code>
119
 
    <p>Use <code>code</code> with <code xref="mal_inline_var">var</code> to mark
120
 
    up code with a placeholder for an argument the user should supply.</p>
121
 
  </example>
122
 
</section>
123
 
<!-- END examples -->
124
 
 
125
 
 
126
 
<!-- BEGIN processing -->
127
 
<section id="processing">
128
 
  <title>Processing Expectations</title>
129
 
  <p>Code snippets are displayed in a fixed-width font.  This mimics
130
 
  the look of a typical environment where code is typed.  More importantly,
131
 
  fixed-width fonts tend to have more distinction between visually similar
132
 
  characters.  This is particularly important in code, since letters often
133
 
  appear without the context of a known word that helps make them discernable
134
 
  in normal prose.</p>
135
 
 
136
 
  <p>For particularly long code snippets, display tools may use a background
137
 
  color or border to make the beginning and end clear, although authors should
138
 
  prefer <link xref="mal_block_code">code blocks</link> for long code snippets.</p>
139
 
</section>
140
 
<!-- END processing -->
141
 
 
142
 
 
143
 
<!-- BEGIN comparison -->
144
 
<section id="comparison">
145
 
  <title>Comparison to Other Formats</title>
146
 
  <p>The <code>code</code> element is similar to the
147
 
  <code href="http://www.docbook.org/tdg/en/html/code.html">code</code> element
148
 
  in DocBook.  Since Mallard does not attempt to model programming languages,
149
 
  <code>code</code> may be used in place of numerous DocBook elements, including
150
 
  <code href="http://www.docbook.org/tdg/en/html/classname.html">classname</code>,
151
 
  <code href="http://www.docbook.org/tdg/en/html/constant.html">constant</code>,
152
 
  <code href="http://www.docbook.org/tdg/en/html/function.html">function</code>,
153
 
  <code href="http://www.docbook.org/tdg/en/html/interfacename.html">interfacename</code>,
154
 
  <code href="http://www.docbook.org/tdg/en/html/methodname.html">methodname</code>,
155
 
  <code href="http://www.docbook.org/tdg/en/html/parameter.html">parameter</code>,
156
 
  <code href="http://www.docbook.org/tdg/en/html/structfield.html">structfield</code>,
157
 
  <code href="http://www.docbook.org/tdg/en/html/structname.html">structname</code>, and
158
 
  <code href="http://www.docbook.org/tdg/en/html/varname.html">varname</code>.
159
 
  Additionally, since Mallard does not provide separate elements for marking
160
 
  portions of markup languages, the <code>code</code> element should be used
161
 
  in place of the DocBook elements
162
 
  <code href="http://www.docbook.org/tdg/en/html/markup.html">markup</code> and
163
 
  <code href="http://www.docbook.org/tdg/en/html/sgmltag.html">sgmltag</code>.</p>
164
 
</section>
165
 
<!-- END comparison -->
166
 
 
167
 
</page>