@@ -92,12 +92,23 @@ def clear_line(mode: int = 2) -> str:
9292 return CSI + str (mode ) + 'K'
9393
9494
95- class Color (str ):
95+ class Colour (str ):
96+ """
97+ An ANSI escape sequence representing a colour.
98+
99+ :param style: Escape sequence representing the style.
100+ :type style: str
101+ :param stack: The stack to place the escape sequence on.
102+ :type stack: str
103+ :param reset: The escape requence the reset the style.
104+ :type reset: str
105+ """
106+
96107 style : str
97108 reset : str
98109 stack : List [str ]
99110
100- def __new__ (cls , style : str , stack : List [str ], reset : str ) -> "Color " :
111+ def __new__ (cls , style : str , stack : List [str ], reset : str ) -> "Colour " :
101112 color = super ().__new__ (cls , style ) # type: ignore
102113 color .style = style
103114 color .stack = stack
@@ -119,17 +130,25 @@ def __call__(self, text) -> str:
119130
120131
121132class AnsiCodes (ABC ):
133+ """
134+ Abstract base class for ANSI Codes.
135+ """
136+
122137 _stack : List [str ]
123138 _reset : str
124139
125140 def __init__ (self ) -> None :
126- # the subclasses declare class attributes which are numbers.
127- # Upon instantiation we define instance attributes, which are the same
128- # as the class attributes but wrapped with the ANSI escape sequence
141+ """
142+ The subclasses declare class attributes which are numbers.
143+
144+ Upon instantiation we define instance attributes, which are the same
145+ as the class attributes but wrapped with the ANSI escape sequence.
146+ """
147+
129148 for name in dir (self ):
130149 if not name .startswith ('_' ):
131150 value = getattr (self , name )
132- setattr (self , name , Color (code_to_chars (value ), self ._stack , self ._reset ))
151+ setattr (self , name , Colour (code_to_chars (value ), self ._stack , self ._reset ))
133152
134153
135154class AnsiCursor :
@@ -202,6 +221,7 @@ class AnsiFore(AnsiCodes):
202221 ANSI Colour Codes for foreground colour.
203222
204223 Valid values are:
224+
205225 * BLACK
206226 * RED
207227 * GREEN
@@ -250,6 +270,7 @@ class AnsiBack(AnsiCodes):
250270 ANSI Colour Codes for background colour.
251271
252272 Valid values are:
273+
253274 * BLACK
254275 * RED
255276 * GREEN
@@ -298,6 +319,7 @@ class AnsiStyle(AnsiCodes):
298319 ANSI Colour Codes for text style.
299320
300321 Valid values are:
322+
301323 * BRIGHT
302324 * DIM
303325 * NORMAL
@@ -323,5 +345,3 @@ class AnsiStyle(AnsiCodes):
323345fore_stack .append (Fore .RESET )
324346back_stack .append (Back .RESET )
325347style_stack .append (Style .NORMAL )
326-
327- Fore .GREEN ("Hello World" )
0 commit comments