Take a string and try to format it into a sane list of strings to be put into the suggestion box.
(
self, docstring: str, width: int, height: int
)
| 821 | return False |
| 822 | |
| 823 | def format_docstring( |
| 824 | self, docstring: str, width: int, height: int |
| 825 | ) -> list[str]: |
| 826 | """Take a string and try to format it into a sane list of strings to be |
| 827 | put into the suggestion box.""" |
| 828 | |
| 829 | lines = docstring.split("\n") |
| 830 | out = [] |
| 831 | i = 0 |
| 832 | for line in lines: |
| 833 | i += 1 |
| 834 | if not line.strip(): |
| 835 | out.append("\n") |
| 836 | for block in textwrap.wrap(line, width): |
| 837 | out.append(" " + block + "\n") |
| 838 | if i >= height: |
| 839 | return out |
| 840 | i += 1 |
| 841 | # Drop the last newline |
| 842 | out[-1] = out[-1].rstrip() |
| 843 | return out |
| 844 | |
| 845 | def next_indentation(self) -> int: |
| 846 | """Return the indentation of the next line based on the current |