Skip to content

Commit c0228f9

Browse files
committed
Fix inline syntax highlighting in rst docs
1 parent 7975f80 commit c0228f9

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

docs/advanced_guide.rst

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,26 @@ without any '.' or '/' characters.
127127
Hooks
128128
-----
129129
Hooks are an advanced feature that allow arbitrary code to be executed during
130-
the parsing and serialization process. A `Hooks` object is associated with a
131-
processor and contains two functions: `after_parse` and `before_serialize`.
130+
the parsing and serialization process. A ``Hooks`` object is associated with a
131+
processor and contains two functions: ``after_parse`` and ``before_serialize``.
132132

133133
Both of these functions (which can be any callable object) are provided two
134134
parameters and should return a single value. The first parameter provided to
135-
both functions is a `ProcessorStateView` object which contains information
135+
both functions is a ``ProcessorStateView`` object which contains information
136136
about the current state of the processor when the function is invoked.
137137

138-
The `after_parse` function is invoked after a processor has parsed a value
139-
from the XML data. The second parameter provided to the `after_parse` function
140-
is the value parsed by the processor from the XML data. The `after_parse`
138+
The ``after_parse`` function is invoked after a processor has parsed a value
139+
from the XML data. The second parameter provided to the ``after_parse`` function
140+
is the value parsed by the processor from the XML data. The ``after_parse``
141141
function must return a single value which will be used by the processor as its
142-
parse result. The value returned by `after_parse` replaces the value parsed
142+
parse result. The value returned by ``after_parse`` replaces the value parsed
143143
from the XML data as the processor's parse result.
144144

145-
The `before_serialize` function is invoked before a processor serializes a
146-
value to XML. The second parameter provided to the `before_serialize` function
147-
is the value to be serialized by the processor to XML. The `before_serialize`
145+
The ``before_serialize`` function is invoked before a processor serializes a
146+
value to XML. The second parameter provided to the ``before_serialize`` function
147+
is the value to be serialized by the processor to XML. The ``before_serialize``
148148
function must return a single value which the processor will serialize to XML.
149-
The value returned by `before_serialize` replaces the value provided to the
149+
The value returned by ``before_serialize`` replaces the value provided to the
150150
processor to serialize to XML.
151151

152152
There are three intended use cases for hooks (though since hooks can be any
@@ -163,9 +163,9 @@ parsing into a shape more convenient for the application to use and transform
163163
values during serialization back into shapes that better fit the XML structure.
164164

165165
Hooks can be used to achieve this by simply returning the transformed value
166-
from the `after_parse` and `before_serialize` functions. This works because
166+
from the ``after_parse`` and ``before_serialize`` functions. This works because
167167
whatever value a processor was going to use for parsing or serialization is
168-
replaced by the value returned by `after_parse` or `before_serialize`.
168+
replaced by the value returned by ``after_parse`` or ``before_serialize``.
169169

170170
As a basic example, if we want to make sure all strings read from an XML
171171
document are uppercase when used in our application and lowercase when written
@@ -201,7 +201,7 @@ to XML, we could use hooks to perform value transformations.
201201
</data>
202202

203203
When using hooks to perform value transformations, it is a good idea to ensure
204-
that the transformations performed by `after_parse` and `before_serialize` are
204+
that the transformations performed by ``after_parse`` and ``before_serialize`` are
205205
inverse operations of each other so that parsing and serialization work
206206
correctly when using transformed values. This is particularly important when
207207
values are transformed into different types.
@@ -212,9 +212,9 @@ By default, declxml only performs a very basic level of validation by ensuring
212212
that required values are present and that they are of the correct type. Hooks
213213
provide the ability to perform additional, application-specific validation.
214214

215-
When performing validation, we can use the `ProcessorStateView` object provided
216-
as the first parameter to the `after_parse` and `before_serialize` functions.
217-
The `ProcessorStateView` object provides a useful method, `raise_error`, for
215+
When performing validation, we can use the ``ProcessorStateView`` object provided
216+
as the first parameter to the ``after_parse`` and ``before_serialize`` functions.
217+
The ``ProcessorStateView`` object provides a useful method, ``raise_error``, for
218218
reporting errors. This method will raise an application-provided exception
219219
with a custom error message and will include information about the current
220220
state of the processor in the error message.
@@ -263,15 +263,15 @@ we could use hooks to perform the validation.
263263
RuntimeError: Invalid value -90 at data/value
264264

265265
When using hooks for validation, it is important to remember to return the
266-
value from the `before_parse` and `after_serialize` functions since the
266+
value from the ``before_parse`` and ``after_serialize`` functions since the
267267
processor will used the value returned by those functions as its parsing result
268268
and the value to serialize to XML, respectively.
269269

270270
Debugging
271271
"""""""""
272272
Hooks can also be used to debug processors. We can use the
273-
`ProcessorStateView` object provided to the `before_parse` and
274-
`after_serialize` functions to include information about which values are
273+
``ProcessorStateView`` object provided to the ``before_parse`` and
274+
``after_serialize`` functions to include information about which values are
275275
received in which locations in the XML document.
276276

277277
.. sourcecode:: py

docs/guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ function.
441441
<birth-year>1920</birth-year>
442442
</author>
443443

444-
Note that the class provided to the `user_object` factory function must have a
444+
Note that the class provided to the ``user_object`` factory function must have a
445445
zero-argument constructor. It is also possible to pass any other callable
446446
object that takes zero parameters and returns an object instance to which
447447
parsed values will be read into.

0 commit comments

Comments
 (0)