summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeewis <keewis@posteo.de>2021-08-18 19:24:15 +0200
committerKeewis <keewis@posteo.de>2021-08-18 19:24:15 +0200
commitb5dc48503800ee1b6264e0ff84ad47058c01a13a (patch)
tree82135c5a9fe3e4de89b0a7062b77f70e3024d8d5
parent139ce1655f5e78419308f96003bc2b9331b92b25 (diff)
downloadpint-b5dc48503800ee1b6264e0ff84ad47058c01a13a.tar.gz
convert to a code block
-rw-r--r--pint/formatting.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/pint/formatting.py b/pint/formatting.py
index e9b9c3a..a04205d 100644
--- a/pint/formatting.py
+++ b/pint/formatting.py
@@ -139,15 +139,17 @@ def register_unit_format(name):
Examples
--------
- >>> @pint.register_unit_format("custom")
- ... def format_custom(unit, registry, **options):
- ... result = "<formatted unit>" # do the formatting
- ... return result
- ...
- >>> ureg = pint.UnitRegistry()
- >>> u = ureg.m / ureg.s ** 2
- >>> f"{u:custom}"
- '<formatted unit>'
+ .. code:: python
+
+ @pint.register_unit_format("custom")
+ def format_custom(unit, registry, **options):
+ result = "<formatted unit>" # do the formatting
+ return result
+
+
+ ureg = pint.UnitRegistry()
+ u = ureg.m / ureg.s ** 2
+ f"{u:custom}"
"""
def wrapper(func):