power_fields: inherit docstrings upon remap
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 17 Sep 2022 09:13:11 +0000 (12:13 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 17 Sep 2022 16:44:16 +0000 (17:44 +0100)
src/openpower/decoder/power_fields.py

index c2dac292c2c4af6e1d050da60d655b91db160714..9e4758b4a675e00ddffcd667e15940efc8c42f0c 100644 (file)
@@ -152,9 +152,11 @@ class FieldMeta(type):
             rlen = f"len({cls.__name__})"
             raise RemapError(f"{llen} != {rlen}")
 
+        ns = {}
+        ns["__doc__"] = cls.__doc__
         items = map(lambda item: scheme.__members__[item], cls)
 
-        return cls.__class__(cls.__name__, (cls,), {}, items=items)
+        return cls.__class__(cls.__name__, (cls,), ns, items=items)
 
     @property
     def span(cls):
@@ -244,6 +246,7 @@ class MappingMeta(type):
         for (name, field) in cls:
             annotations[name] = field.remap(scheme)
         ns["__annotations__"] = annotations
+        ns["__doc__"] = cls.__doc__
 
         return cls.__class__(cls.__name__, (cls,), ns)