Used to parse the docstring that contains all the plot options.
(docstring: str)
| 948 | |
| 949 | |
| 950 | def _parse_docstring_sections(docstring: str) -> dict[str, str]: |
| 951 | """Used to parse the docstring that contains all the plot options.""" |
| 952 | docstring = docstring.strip() |
| 953 | if docstring.startswith('"""') and docstring.endswith('"""'): |
| 954 | docstring = docstring[3:-3].strip() |
| 955 | |
| 956 | lines = docstring.splitlines() |
| 957 | section_headers = [] |
| 958 | |
| 959 | for i, line in enumerate(lines): |
| 960 | if ( |
| 961 | i < len(lines) - 1 |
| 962 | and set(lines[i + 1].strip()) == {'-'} |
| 963 | and len(lines[i + 1].strip()) >= 3 |
| 964 | ): |
| 965 | section_headers.append((i, line.strip())) |
| 966 | |
| 967 | sections = {} |
| 968 | for i, section_header in enumerate(section_headers): |
| 969 | start_line = section_headers[i][0] |
| 970 | if i == len(section_headers) - 1: |
| 971 | section_text = '\n'.join(lines[start_line:]) |
| 972 | else: |
| 973 | end_line = section_headers[i + 1][0] |
| 974 | section_text = '\n'.join(lines[start_line:end_line]) |
| 975 | sections[section_header[1]] = section_text.strip() |
| 976 | return sections |
| 977 | |
| 978 | |
| 979 | _METHOD_DOCS = {} |
no outgoing calls
searching dependent graphs…