Updated the API documentation.
Updated examples based on the new Loader API. (Dumper API still needs examples)
This commit is contained in:
parent
21001b36b9
commit
765b74ffca
48 changed files with 4555 additions and 1978 deletions
|
@ -52,20 +52,19 @@ information, see <a class="reference external" href="http://pyyaml.org/wiki/PyYA
|
|||
which this article is based on,
|
||||
<a class="reference external" href="http://yaml.org/spec/1.1/#id857168">Chapter 2 of the YAML specification</a>
|
||||
or the <a class="reference external" href="http://en.wikipedia.org/wiki/YAML">Wikipedia page</a>.</p>
|
||||
<p>YAML is a data serialization format designed to be as human readable as
|
||||
possible. YAML is a recursive acronym for “YAML Ain’t Markup Language”.</p>
|
||||
<p>YAML is a data serialization format designed for human readability. YAML is a
|
||||
recursive acronym for “YAML Ain’t Markup Language”.</p>
|
||||
<p>YAML is similar to JSON, and in fact, JSON is a subset of YAML 1.2; but YAML has
|
||||
some more advanced features and is easier to read. However, YAML is also more
|
||||
some more advanced features and is easier to read. However, it is also more
|
||||
difficult to parse (and probably somewhat slower). Data is stored in mappings
|
||||
(associative arrays), sequences (lists) and scalars (single values). Data
|
||||
structure hierarchy either depends on indentation (block context, similar to
|
||||
structure hierarchy depends either on indentation (block context, similar to
|
||||
Python code), or nesting of brackets and braces (flow context, similar to JSON).
|
||||
YAML comments begin with <tt class="docutils literal"><span class="pre">#</span></tt> and continue until the end of line.</p>
|
||||
<div class="section" id="documents">
|
||||
<h2>Documents<a class="headerlink" href="#documents" title="Permalink to this headline">¶</a></h2>
|
||||
<p>A YAML stream consists of one or more documents starting with <tt class="docutils literal"><span class="pre">---</span></tt> and
|
||||
optionally ending with <tt class="docutils literal"><span class="pre">...</span></tt> . If there is only one document, <tt class="docutils literal"><span class="pre">---</span></tt> can be
|
||||
left out.</p>
|
||||
optionally ending with <tt class="docutils literal"><span class="pre">...</span></tt> . <tt class="docutils literal"><span class="pre">---</span></tt> can be left out for the first document.</p>
|
||||
<p>Single document with no explicit start or end:</p>
|
||||
<div class="highlight-yaml"><div class="highlight"><pre><span class="p-Indicator">-</span> <span class="l-Scalar-Plain">Red</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">Green</span>
|
||||
|
@ -96,7 +95,7 @@ left out.</p>
|
|||
<div class="section" id="sequences">
|
||||
<h2>Sequences<a class="headerlink" href="#sequences" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Sequences are arrays of nodes of any type, similar e.g. to Python lists.
|
||||
In block context, each item begins with hyphen+space “- “. In flow context,
|
||||
In block context, each item begins with hyphen+space “- ”. In flow context,
|
||||
sequences have syntax similar to D arrays.</p>
|
||||
<div class="highlight-yaml"><div class="highlight"><pre><span class="c1">#Block context</span>
|
||||
<span class="p-Indicator">-</span> <span class="l-Scalar-Plain">Red</span>
|
||||
|
@ -137,7 +136,7 @@ sequences have syntax similar to D arrays.</p>
|
|||
<h2>Mappings<a class="headerlink" href="#mappings" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Mappings are associative arrays where each key and value can be of any type,
|
||||
similar e.g. to Python dictionaries. In block context, keys and values are
|
||||
separated by colon+space “: “. In flow context, mappings have syntax similar
|
||||
separated by colon+space ”: ”. In flow context, mappings have syntax similar
|
||||
to D associative arrays, but with braces instead of brackets:</p>
|
||||
<div class="highlight-yaml"><div class="highlight"><pre><span class="c1">#Block context</span>
|
||||
<span class="l-Scalar-Plain">CPU</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Athlon</span>
|
||||
|
@ -174,7 +173,7 @@ to D associative arrays, but with braces instead of brackets:</p>
|
|||
<span class="l-Scalar-Plain">OS</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Android</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Complex keys start with question mark+space “? “.</p>
|
||||
<p>Complex keys start with question mark+space ”? ”.</p>
|
||||
<div class="highlight-yaml"><div class="highlight"><pre><span class="c1">#Nested in a sequence</span>
|
||||
<span class="p-Indicator">?</span> <span class="p-Indicator">[</span><span class="nv">CPU</span><span class="p-Indicator">,</span> <span class="nv">GPU</span><span class="p-Indicator">]:</span> <span class="p-Indicator">[</span><span class="nv">Athlon</span><span class="p-Indicator">,</span> <span class="nv">Radeon</span><span class="p-Indicator">]</span>
|
||||
<span class="l-Scalar-Plain">OS</span><span class="p-Indicator">:</span> <span class="l-Scalar-Plain">Debian</span>
|
||||
|
@ -331,8 +330,8 @@ Some of these might change in the future (especially !!map and !!set).</p>
|
|||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2011, Ferdinand Majerech. Based on PyYAML http://www.pyyaml.org by Kirill Simonov.
|
||||
Last updated on Aug 16, 2011.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
|
||||
Last updated on Oct 14, 2011.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue