Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions gradio/cli/commands/components/_docs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import typing
from subprocess import PIPE, Popen

_RETURN_PATTERN = re.compile(
r"\bReturn(?:s)?\b:[ \t\n]*(.*?)(?=\n|$)", flags=re.DOTALL | re.IGNORECASE
)


def find_first_non_return_key(some_dict):
"""Finds the first key in a dictionary that is not "return"."""
Expand Down Expand Up @@ -98,9 +102,7 @@ def get_parameter_docstring(docstring: str, parameter_name: str):

def get_return_docstring(docstring: str):
"""Gets the docstring for a return value."""
pattern = r"\bReturn(?:s){0,1}\b:[ \t\n]*(.*?)(?=\n|$)"

match = re.search(pattern, docstring, flags=re.DOTALL | re.IGNORECASE)
match = _RETURN_PATTERN.search(docstring)
if match:
return match.group(1).strip()

Expand Down