@@ -199,7 +199,24 @@ class WindowsColors(enum.Enum):
199199
200200 @staticmethod
201201 def from_rgb (rgb : types .Tuple [int , int , int ]):
202- """Find the closest ConsoleColor to the given RGB color."""
202+ '''
203+ Find the closest WindowsColors to the given RGB color.
204+
205+ >>> WindowsColors.from_rgb((0, 0, 0))
206+ <WindowsColors.BLACK: (0, 0, 0)>
207+
208+ >>> WindowsColors.from_rgb((255, 255, 255))
209+ <WindowsColors.INTENSE_WHITE: (255, 255, 255)>
210+
211+ >>> WindowsColors.from_rgb((0, 255, 0))
212+ <WindowsColors.INTENSE_GREEN: (0, 255, 0)>
213+
214+ >>> WindowsColors.from_rgb((45, 45, 45))
215+ <WindowsColors.BLACK: (0, 0, 0)>
216+
217+ >>> WindowsColors.from_rgb((128, 0, 128))
218+ <WindowsColors.MAGENTA: (128, 0, 128)>
219+ '''
203220
204221 def color_distance (rgb1 , rgb2 ):
205222 return sum ((c1 - c2 ) ** 2 for c1 , c2 in zip (rgb1 , rgb2 ))
@@ -211,6 +228,13 @@ def color_distance(rgb1, rgb2):
211228
212229
213230class WindowsColor :
231+ '''
232+ Windows compatible color class for when ANSI is not supported.
233+ Currently a no-op because it is not possible to buffer these colors.
234+
235+ >>> WindowsColor(WindowsColors.RED)('test')
236+ 'test'
237+ '''
214238 __slots__ = 'color' ,
215239
216240 def __init__ (self , color : Color ):
@@ -543,9 +567,6 @@ class DummyColor:
543567 def __call__ (self , text ):
544568 return text
545569
546- def __getattr__ (self , item ):
547- return self
548-
549570 def __repr__ (self ):
550571 return 'DummyColor()'
551572
0 commit comments