Skip to content

Commit 0f40007

Browse files
kazutakahiratavarun-r-mallya
authored andcommitted
[llvm] Proofread YamlIO.rst (#165193)
1 parent 79b9250 commit 0f40007

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

llvm/docs/YamlIO.rst

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ YAML is a human-readable data serialization language. The full YAML language
1212
spec can be read at `yaml.org
1313
<http://www.yaml.org/spec/1.2/spec.html#Introduction>`_. The simplest form of
1414
YAML is just "scalars", "mappings", and "sequences". A scalar is any number
15-
or string. The pound/hash symbol (#) begins a comment line. A mapping is
15+
or string. The pound/hash symbol (``#``) begins a comment line. A mapping is
1616
a set of key-value pairs where the key ends with a colon. For example:
1717

1818
.. code-block:: yaml
@@ -21,7 +21,7 @@ a set of key-value pairs where the key ends with a colon. For example:
2121
name: Tom
2222
hat-size: 7
2323
24-
A sequence is a list of items where each item starts with a leading dash ('-').
24+
A sequence is a list of items where each item starts with a leading dash (``-``).
2525
For example:
2626

2727
.. code-block:: yaml
@@ -221,7 +221,7 @@ Similar errors are produced for other input not conforming to the schema.
221221
Scalars
222222
=======
223223

224-
YAML scalars are just strings (i.e. not a sequence or mapping). The YAML I/O
224+
YAML scalars are just strings (i.e., not a sequence or mapping). The YAML I/O
225225
library provides support for translating between YAML scalars and specific
226226
C++ types.
227227

@@ -230,19 +230,19 @@ Built-in types
230230
--------------
231231
The following types have built-in support in YAML I/O:
232232

233-
* bool
234-
* float
235-
* double
236-
* StringRef
237-
* std::string
238-
* int64_t
239-
* int32_t
240-
* int16_t
241-
* int8_t
242-
* uint64_t
243-
* uint32_t
244-
* uint16_t
245-
* uint8_t
233+
* ``bool``
234+
* ``float``
235+
* ``double``
236+
* ``StringRef``
237+
* ``std::string``
238+
* ``int64_t``
239+
* ``int32_t``
240+
* ``int16_t``
241+
* ``int8_t``
242+
* ``uint64_t``
243+
* ``uint32_t``
244+
* ``uint16_t``
245+
* ``uint8_t``
246246

247247
That is, you can use those types in fields of ``MappingTraits`` or as the element type
248248
in a sequence. When reading, YAML I/O will validate that the string found
@@ -264,7 +264,7 @@ operators to and from the base type. For example:
264264
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MyFooFlags)
265265
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MyBarFlags)
266266

267-
This generates two classes MyFooFlags and MyBarFlags which you can use in your
267+
This generates two classes ``MyFooFlags`` and ``MyBarFlags`` which you can use in your
268268
native data structures instead of ``uint32_t``. They are implicitly
269269
converted to and from ``uint32_t``. The point of creating these unique types
270270
is that you can now specify traits on them to get different YAML conversions.
@@ -275,12 +275,12 @@ An example use of a unique type is that YAML I/O provides fixed-sized unsigned
275275
integers that are written with YAML I/O as hexadecimal instead of the decimal
276276
format used by the built-in integer types:
277277

278-
* Hex64
279-
* Hex32
280-
* Hex16
281-
* Hex8
278+
* ``Hex64``
279+
* ``Hex32``
280+
* ``Hex16``
281+
* ``Hex8``
282282

283-
You can use ``llvm::yaml::Hex32`` instead of ``uint32_t`` and the only difference will
283+
You can use ``llvm::yaml::Hex32`` instead of ``uint32_t``. The only difference will
284284
be that when YAML I/O writes out that type it will be formatted in hexadecimal.
285285

286286

@@ -356,8 +356,8 @@ had the following bit flags defined:
356356

357357
LLVM_YAML_STRONG_TYPEDEF(uint32_t, MyFlags)
358358

359-
To support reading and writing of MyFlags, you specialize ``ScalarBitSetTraits<>``
360-
on MyFlags and provide the bit values and their names.
359+
To support reading and writing of ``MyFlags``, you specialize ``ScalarBitSetTraits<>``
360+
on ``MyFlags`` and provide the bit values and their names.
361361

362362
.. code-block:: c++
363363

@@ -441,7 +441,7 @@ Custom Scalar
441441
Sometimes, for readability, a scalar needs to be formatted in a custom way. For
442442
instance, your internal data structure may use an integer for time (seconds since
443443
some epoch), but in YAML it would be much nicer to express that integer in
444-
some time format (e.g. 4-May-2012 10:30pm). YAML I/O has a way to support
444+
some time format (e.g., ``4-May-2012 10:30pm``). YAML I/O has a way to support
445445
custom formatting and parsing of scalar types by specializing ``ScalarTraits<>`` on
446446
your data type. When writing, YAML I/O will provide the native type and
447447
your specialization must create a temporary ``llvm::StringRef``. When reading,
@@ -523,8 +523,8 @@ An example of a custom type with an appropriate specialization of
523523
Mappings
524524
========
525525

526-
To be translated to or from a YAML mapping for your type T you must specialize
527-
``llvm::yaml::MappingTraits`` on T and implement the "void mapping(IO &io, T&)"
526+
To be translated to or from a YAML mapping for your type ``T``, you must specialize
527+
``llvm::yaml::MappingTraits`` on ``T`` and implement the ``void mapping(IO &io, T&)``
528528
method. If your native data structures use pointers to a class everywhere,
529529
you can specialize on the class pointer. Examples:
530530

@@ -685,13 +685,13 @@ normalized instance is stack allocated. In these cases, the utility template
685685
``MappingNormalizationHeap<>`` can be used instead. It just like
686686
``MappingNormalization<>`` except that it heap allocates the normalized object
687687
when reading YAML. It never destroys the normalized object. The ``denormalize()``
688-
method can this return "this".
688+
method can this return ``this``.
689689

690690

691691
Default values
692692
--------------
693693
Within a ``mapping()`` method, calls to ``io.mapRequired()`` mean that that key is
694-
required to exist when parsing YAML documents, otherwise YAML I/O will issue an
694+
required to exist when parsing YAML documents; otherwise, YAML I/O will issue an
695695
error.
696696

697697
On the other hand, keys registered with ``io.mapOptional()`` are allowed to not
@@ -708,7 +708,7 @@ does not have that key.
708708
There is one important difference between those two ways (default constructor
709709
and third parameter to ``mapOptional()``). When YAML I/O generates a YAML document,
710710
if the ``mapOptional()`` third parameter is used, if the actual value being written
711-
is the same as (using ==) the default value, then that key/value is not written.
711+
is the same as (using ``==``) the default value, then that key/value is not written.
712712

713713

714714
Order of Keys
@@ -772,7 +772,7 @@ not. This is similar to something having no syntax errors, but still having
772772
semantic errors. To support semantic-level checking, YAML I/O allows
773773
an optional ``validate()`` method in a MappingTraits template specialization.
774774

775-
When parsing YAML, the ``validate()`` method is call *after* all key/values in
775+
When parsing YAML, the ``validate()`` method is called *after* all key/values in
776776
the map have been processed. Any error message returned by the ``validate()``
777777
method during input will be printed just like a syntax error would be printed.
778778
When writing YAML, the ``validate()`` method is called *before* the YAML
@@ -833,8 +833,8 @@ configuration.
833833
Sequence
834834
========
835835

836-
To be translated to or from a YAML sequence for your type T you must specialize
837-
``llvm::yaml::SequenceTraits`` on T and implement two methods:
836+
To be translated to or from a YAML sequence for your type ``T``, you must specialize
837+
``llvm::yaml::SequenceTraits`` on ``T`` and implement two methods:
838838
``size_t size(IO &io, T&)`` and
839839
``T::value_type& element(IO &io, T&, size_t indx)``. For example:
840840

@@ -857,7 +857,7 @@ a reference to that new allocated space.
857857
Flow Sequence
858858
-------------
859859
A YAML "flow sequence" is a sequence that when written to YAML it uses the
860-
inline notation (e.g [ foo, bar ] ). To specify that a sequence type should
860+
inline notation (e.g., ``[ foo, bar ]`` ). To specify that a sequence type should
861861
be written in YAML as a flow sequence, your SequenceTraits specialization should
862862
add ``static constexpr bool flow = true;``. For instance:
863863

@@ -872,9 +872,9 @@ add ``static constexpr bool flow = true;``. For instance:
872872
static constexpr bool flow = true;
873873
};
874874

875-
With the above, if you used MyList as the data type in your native data
875+
With the above, if you used ``MyList`` as the data type in your native data
876876
structures, then when converted to YAML, a flow sequence of integers
877-
will be used (e.g. [ 10, -3, 4 ]).
877+
will be used (e.g., ``[ 10, -3, 4 ]``).
878878

879879
Flow sequences are subject to line wrapping according to the Output object
880880
configuration.
@@ -900,8 +900,8 @@ Document List
900900
=============
901901

902902
YAML allows you to define multiple "documents" in a single YAML file. Each
903-
new document starts with a left aligned "---" token. The end of all documents
904-
is denoted with a left aligned "..." token. Many users of YAML will never
903+
new document starts with a left aligned ``---`` token. The end of all documents
904+
is denoted with a left aligned ``...`` token. Many users of YAML will never
905905
have need for multiple documents. The top level node in their YAML schema
906906
will be a mapping or sequence. For those cases, the following is not needed.
907907
But for cases where you do want multiple documents, you can specify a
@@ -955,7 +955,7 @@ to write your native data as YAML. One thing to recall is that a YAML file
955955
can contain multiple "documents". If the top level data structure you are
956956
streaming as YAML is a mapping, scalar, or sequence, then ``Output`` assumes you
957957
are generating one document and wraps the mapping output
958-
with "``---``" and trailing "``...``".
958+
with ``---`` and trailing ``...``.
959959

960960
The ``WrapColumn`` parameter will cause the flow mappings and sequences to
961961
line-wrap when they go over the supplied column. Pass 0 to completely
@@ -981,8 +981,8 @@ The above could produce output like:
981981
982982
On the other hand, if the top level data structure you are streaming as YAML
983983
has a ``DocumentListTraits`` specialization, then Output walks through each element
984-
of your DocumentList and generates a "---" before the start of each element
985-
and ends with a "...".
984+
of your DocumentList and generates a ``---`` before the start of each element
985+
and ends with a ``...``.
986986

987987
.. code-block:: c++
988988

@@ -1022,7 +1022,7 @@ pointer:
10221022
Once you have an ``Input`` object, you can use the C++ stream operator to read
10231023
the document(s). If you expect there might be multiple YAML documents in
10241024
one file, you'll need to specialize ``DocumentListTraits`` on a list of your
1025-
document type and stream in that document list type. Otherwise you can
1025+
document type and stream in that document list type. Otherwise, you can
10261026
just stream in the document type. Also, you can check if there was
10271027
any syntax errors in the YAML by calling the ``error()`` method on the ``Input``
10281028
object. For example:

0 commit comments

Comments
 (0)