Skip to content

Commit 556faea

Browse files
committed
docs: guide: fix build with PYTHONWARNINGS=error after Sphinx update.
1 parent d8d8e61 commit 556faea

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/guide.rst

+26
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
170170

171171
Python ranges are *exclusive* or *half-open*, meaning they do not contain their ``.stop`` element. Because of this, values with shapes cast from a ``range(stop)`` where ``stop`` is a power of 2 are not wide enough to represent ``stop`` itself:
172172

173+
.. doctest::
174+
:hide:
175+
176+
>>> import warnings
177+
>>> _warning_filters_backup = warnings.catch_warnings()
178+
>>> _warning_filters_backup.__enter__() # have to do this horrific hack to make it work with `PYTHONWARNINGS=error` :(
179+
>>> warnings.simplefilter("default", amaranth.hdl._ast.SyntaxWarning)
180+
173181
.. doctest::
174182

175183
>>> fencepost = C(256, range(256))
@@ -180,6 +188,11 @@ Specifying a shape with a range is convenient for counters, indexes, and all oth
180188
>>> fencepost.value
181189
0
182190

191+
.. doctest::
192+
:hide:
193+
194+
>>> _warning_filters_backup.__exit__()
195+
183196
Amaranth detects uses of :class:`Const` and :class:`Signal` that invoke such an off-by-one error, and emits a diagnostic message.
184197

185198
.. note::
@@ -670,6 +683,14 @@ Python expression Amaranth expression (boolean operands)
670683

671684
When applied to Amaranth boolean values, the ``~`` operator computes negation, and when applied to Python boolean values, the ``not`` operator also computes negation. However, the ``~`` operator applied to Python boolean values produces an unexpected result:
672685

686+
.. doctest::
687+
:hide:
688+
689+
>>> import warnings
690+
>>> _warning_filters_backup = warnings.catch_warnings()
691+
>>> _warning_filters_backup.__enter__() # have to do this horrific hack to make it work with `PYTHONWARNINGS=error` :(
692+
>>> warnings.simplefilter("ignore", DeprecationWarning)
693+
673694
.. doctest::
674695

675696
>>> ~False
@@ -688,6 +709,11 @@ Python expression Amaranth expression (boolean operands)
688709
>>> ~use_stb | stb # WRONG! MSB of 2-bit wide OR expression is always 1
689710
(| (const 2'sd-2) (sig stb))
690711

712+
.. doctest::
713+
:hide:
714+
715+
>>> _warning_filters_backup.__exit__()
716+
691717
Amaranth automatically detects some cases of misuse of ``~`` and emits a detailed diagnostic message.
692718

693719
.. TODO: this isn't quite reliable, #380

0 commit comments

Comments
 (0)