Returns the docstring of an object, formatted in markdown to resemble pytorch-style docs, e.g. an argument list like: Args: arg1: description is converted to Args: - **arg1**: description - **arg2**: description
(obj)
| 23 | |
| 24 | |
| 25 | def get_docstring(obj) -> str: |
| 26 | """Returns the docstring of an object, formatted in markdown to resemble |
| 27 | pytorch-style docs, e.g. an argument list like: |
| 28 | |
| 29 | Args: |
| 30 | arg1: description |
| 31 | |
| 32 | is converted to |
| 33 | |
| 34 | Args: |
| 35 | - **arg1**: description |
| 36 | - **arg2**: description |
| 37 | |
| 38 | """ |
| 39 | |
| 40 | docstring = inspect.getdoc(obj) |
| 41 | if docstring is None: |
| 42 | print( |
| 43 | f"WARNING: Docstring not found for object '{obj.__name__}'. Please document all user facing components of the Arm Backend properly." |
| 44 | ) |
| 45 | docstring = "" |
| 46 | |
| 47 | lines = docstring.split("\n") |
| 48 | for line in lines: |
| 49 | if ":" in line and line.startswith(" "): |
| 50 | new_line = line.strip() |
| 51 | pos = new_line.index(":") |
| 52 | new_line = f"- **{new_line[:pos]}**" + new_line[pos:] |
| 53 | docstring = docstring.replace(line, new_line) |
| 54 | |
| 55 | return docstring |
| 56 | |
| 57 | |
| 58 | def get_function_docstring(cls, func) -> str: |
no test coverage detected