mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-05 13:52:38 +02:00
add docs for metagpt/actions/write_docstring.py
This commit is contained in:
parent
bec5778dd0
commit
6c0531347f
3 changed files with 33 additions and 13 deletions
|
|
@ -49,7 +49,7 @@ class OutputParser:
|
|||
|
||||
@classmethod
|
||||
def parse_code(cls, text: str, lang: str = "") -> str:
|
||||
pattern = rf'```{lang}.*?\s+(.*?)```'
|
||||
pattern = rf'```{lang}.*?\s+(.*)```'
|
||||
match = re.search(pattern, text, re.DOTALL)
|
||||
if match:
|
||||
code = match.group(1)
|
||||
|
|
@ -231,7 +231,8 @@ def print_members(module, indent=0):
|
|||
elif inspect.ismethod(obj):
|
||||
print(f'{prefix}Method: {name}')
|
||||
|
||||
|
||||
def parse_recipient(text):
|
||||
pattern = "## Send To:\s*([A-Za-z]+)\s*?" # hard code for now
|
||||
pattern = r"## Send To:\s*([A-Za-z]+)\s*?" # hard code for now
|
||||
recipient = re.search(pattern, text)
|
||||
return recipient.group(1) if recipient else ""
|
||||
|
|
|
|||
|
|
@ -137,16 +137,13 @@ class DocstringTransformer(cst.CSTTransformer):
|
|||
if isinstance(updated_node, cst.Module):
|
||||
body = updated_node.body
|
||||
if original_statement:
|
||||
return updated_node.with_changes(body=(body[0], statement, *body[1:]))
|
||||
return updated_node.with_changes(body=(statement, *body[1:]))
|
||||
else:
|
||||
updated_node = updated_node.with_changes(body=(statement, cst.EmptyLine(), *body))
|
||||
return updated_node
|
||||
|
||||
body = updated_node.body.body
|
||||
if original_statement:
|
||||
return updated_node.with_changes(body=updated_node.body.with_changes(body=(body[0], statement, *body[1:])))
|
||||
else:
|
||||
return updated_node.with_changes(body=updated_node.body.with_changes(body=(statement, *body)))
|
||||
body = updated_node.body.body[1:] if original_statement else updated_node.body.body
|
||||
return updated_node.with_changes(body=updated_node.body.with_changes(body=(statement, *body)))
|
||||
|
||||
|
||||
def merge_docstring(code: str, documented_code: str) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue