Expand docstring by adding disclaimer and extra text
(doc, cls, name, extra="", skipblocks=0, inconsistencies=None)
| 842 | |
| 843 | |
| 844 | def ignore_warning(doc, cls, name, extra="", skipblocks=0, inconsistencies=None): |
| 845 | """Expand docstring by adding disclaimer and extra text""" |
| 846 | import inspect |
| 847 | |
| 848 | if inspect.isclass(cls): |
| 849 | l1 = f"This docstring was copied from {cls.__module__}.{cls.__name__}.{name}.\n\n" |
| 850 | else: |
| 851 | l1 = f"This docstring was copied from {cls.__name__}.{name}.\n\n" |
| 852 | l2 = "Some inconsistencies with the Dask version may exist." |
| 853 | |
| 854 | i = doc.find("\n\n") |
| 855 | if i != -1: |
| 856 | # Insert our warning |
| 857 | head = doc[: i + 2] |
| 858 | tail = doc[i + 2 :] |
| 859 | while skipblocks > 0: |
| 860 | i = tail.find("\n\n") |
| 861 | head = tail[: i + 2] |
| 862 | tail = tail[i + 2 :] |
| 863 | skipblocks -= 1 |
| 864 | # Indentation of next line |
| 865 | indent = re.match(r"\s*", tail).group(0) |
| 866 | # Insert the warning, indented, with a blank line before and after |
| 867 | if extra: |
| 868 | more = [indent, extra.rstrip("\n") + "\n\n"] |
| 869 | else: |
| 870 | more = [] |
| 871 | if inconsistencies is not None: |
| 872 | l3 = f"Known inconsistencies: \n {inconsistencies}" |
| 873 | bits = [head, indent, l1, l2, "\n\n", l3, "\n\n"] + more + [tail] |
| 874 | else: |
| 875 | bits = [head, indent, l1, indent, l2, "\n\n"] + more + [tail] |
| 876 | doc = "".join(bits) |
| 877 | |
| 878 | return doc |
| 879 | |
| 880 | |
| 881 | def unsupported_arguments(doc, args): |
no test coverage detected
searching dependent graphs…