Method: rich.syntax.Syntax.__init__
Calls: 52, Exceptions: 0, Paths: 1Back
Path 1: 52 calls (1.0)
'import io\nimport re\nimport sys\nfrom typing import List\n\nimport pytest\n\nfrom rich.console import Console\nfrom rich.theme import Theme\nfrom ri...
'python' (41) 'text' (4) 'somelang' (2) 'python3' (1) PythonLexer (1) 'default' (1) 'rust' (1) 'blah' (1)
'monokai' (25) ANSISyntaxTheme (20) 'ansi_light' (2) PygmentsSyntaxTheme (2) 'emacs' (1) 'ascii_light' (1) 'foo' (1)
False (52)
True (33) False (19)
1 (52)
None (25) (2, 10) (6) (48, 54) (1) (79, 85) (1) (77, 87) (1) (111, 117) (1) (109, 119) (1) (2, 3) (1) (33, 39) (1) (25, 31) (1)
None (32) {82} (2) {114} (2) {51} (1) {36} (1) {28} (1) {31} (1) {111} (1) {121} (1) {132} (1)
88 (20) None (19) 60 (10) 20 (2) 30 (1)
4 (52)
False (34) True (18)
None (48) 'red' (4)
False (28) True (24)
0 (51) (1, 3) (1)
1def __init__(
2 self,
3 code: str,
4 lexer: Union[Lexer, str],
5 *,
6 theme: Union[str, SyntaxTheme] = DEFAULT_THEME,
7 dedent: bool = False,
8 line_numbers: bool = False,
9 start_line: int = 1,
10 line_range: Optional[Tuple[Optional[int], Optional[int]]] = None,
11 highlight_lines: Optional[Set[int]] = None,
12 code_width: Optional[int] = None,
13 tab_size: int = 4,
14 word_wrap: bool = False,
15 background_color: Optional[str] = None,
16 indent_guides: bool = False,
17 padding: PaddingDimensions = 0,
18 ) -> None:
19 self.code = code
20 self._lexer = lexer
21 self.dedent = dedent
22 self.line_numbers = line_numbers
23 self.start_line = start_line
24 self.line_range = line_range
25 self.highlight_lines = highlight_lines or set()
26 self.code_width = code_width
27 self.tab_size = tab_size
28 self.word_wrap = word_wrap
29 self.background_color = background_color
30 self.background_style = (
31 Style(bgcolor=background_color) if background_color else Style()
32 )
33 self.indent_guides = indent_guides
34 self.padding = padding
35
36 self._theme = self.get_theme(theme)
37 self._stylized_ranges: List[_SyntaxHighlightRange] = []