Convert Doc into Python script. Parameters ---------- doc : Doc The doc to convert into Python script indent_spaces : int The number of indent spaces to use in the output print_line_numbers: bool Whether to print line numbers num_context_lines : Optio
(
doc: Doc,
indent_spaces: int = 4,
print_line_numbers: bool = False,
num_context_lines: int | None = None,
path_to_underline: list[AccessPath] | None = None,
)
| 25 | |
| 26 | |
| 27 | def to_python_script( |
| 28 | doc: Doc, |
| 29 | indent_spaces: int = 4, |
| 30 | print_line_numbers: bool = False, |
| 31 | num_context_lines: int | None = None, |
| 32 | path_to_underline: list[AccessPath] | None = None, |
| 33 | ) -> str: |
| 34 | """Convert Doc into Python script. |
| 35 | |
| 36 | Parameters |
| 37 | ---------- |
| 38 | doc : Doc |
| 39 | The doc to convert into Python script |
| 40 | indent_spaces : int |
| 41 | The number of indent spaces to use in the output |
| 42 | print_line_numbers: bool |
| 43 | Whether to print line numbers |
| 44 | num_context_lines : Optional[int] |
| 45 | Number of context lines to print around the underlined text |
| 46 | path_to_underline : Optional[AccessPath] |
| 47 | Object path to be underlined |
| 48 | |
| 49 | Returns |
| 50 | ------- |
| 51 | script : str |
| 52 | The text representation of Doc in Python syntax |
| 53 | """ |
| 54 | cfg = PrinterConfig( |
| 55 | indent_spaces=indent_spaces, |
| 56 | print_line_numbers=print_line_numbers, |
| 57 | num_context_lines=num_context_lines, |
| 58 | path_to_underline=path_to_underline, |
| 59 | ) |
| 60 | return _ffi_api.DocToPythonScript(doc, cfg) # type: ignore # pylint: disable=no-member |
searching dependent graphs…