Get the documentation for a list of API functions. Args: funcs (list[callable]): A list of functions to document. show_example (bool): Whether to show examples in the documentation. Returns: str: The formatted API documentation.
(self, funcs: list[callable], show_example: bool = True)
| 52 | self.function_regex = re.compile(r"^[a-z]+_[a-z_]+\(.+\)") |
| 53 | |
| 54 | def get_apis_docs(self, funcs: list[callable], show_example: bool = True) -> str: |
| 55 | """ |
| 56 | Get the documentation for a list of API functions. |
| 57 | |
| 58 | Args: |
| 59 | funcs (list[callable]): A list of functions to document. |
| 60 | show_example (bool): Whether to show examples in the documentation. |
| 61 | |
| 62 | Returns: |
| 63 | str: The formatted API documentation. |
| 64 | """ |
| 65 | api_doc = [] |
| 66 | for func in funcs: |
| 67 | sig = inspect.signature(func) |
| 68 | params = [] |
| 69 | for name, param in sig.parameters.items(): |
| 70 | if name == "slide": |
| 71 | continue |
| 72 | param_str = name |
| 73 | if param.annotation != inspect.Parameter.empty: |
| 74 | param_str += f": {param.annotation.__name__}" |
| 75 | if param.default != inspect.Parameter.empty: |
| 76 | param_str += f" = {repr(param.default)}" |
| 77 | params.append(param_str) |
| 78 | signature = f"def {func.__name__}({', '.join(params)})" |
| 79 | if not show_example: |
| 80 | api_doc.append(signature) |
| 81 | continue |
| 82 | doc = inspect.getdoc(func) |
| 83 | if doc is not None: |
| 84 | signature += f"\n\t{doc}" |
| 85 | api_doc.append(signature) |
| 86 | return "\n\n".join(api_doc) |
| 87 | |
| 88 | def execute_actions( |
| 89 | self, actions: str, edit_slide: SlidePage, found_code: bool = False |