Skip to content

Commit

Permalink
Add add_to_gifs method to docs compiler.
Browse files Browse the repository at this point in the history
Minor fixes to compiler.py file.

Signed-off-by: Aliwoto <aminnimaj@gmail.com>
  • Loading branch information
ALiwoto committed Dec 27, 2024
1 parent b3c4123 commit 04f0d8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_type_hint(type: str) -> str:
return f"Optional[{type}] = None" if is_flag else type
else:
ns, name = type.split(".") if "." in type else ("", type)
type = f'"raw.base.' + ".".join([ns, name]).strip(".") + '"'
type = '"raw.base.' + ".".join([ns, name]).strip(".") + '"'

return f'{type}{" = None" if is_flag else ""}'

Expand Down Expand Up @@ -394,7 +394,6 @@ def start(format: bool = False):
for i, arg in enumerate(sorted_args):
arg_name, arg_type = arg
is_optional = FLAGS_RE.match(arg_type)
flag_number = is_optional.group(1) if is_optional else -1
arg_type = arg_type.split("?")[-1]

arg_docs = combinator_docs.get(c.qualname, None)
Expand All @@ -408,7 +407,7 @@ def start(format: bool = False):
"{} ({}{}):\n {}\n".format(
arg_name,
get_docstring_arg_type(arg_type),
", *optional*".format(flag_number) if is_optional else "",
", *optional*".format() if is_optional else "",
arg_docs
)
)
Expand All @@ -429,11 +428,11 @@ def start(format: bool = False):
if function_docs:
docstring += function_docs["desc"] + "\n"
else:
docstring += f"Telegram API function."
docstring += "Telegram API function."

docstring += f"\n\n Details:\n - Layer: ``{layer}``\n - ID: ``{c.id[2:].upper()}``\n\n"
docstring += f" Parameters:\n " + \
(f"\n ".join(docstring_args) if docstring_args else "No parameters required.\n")
docstring += " Parameters:\n " + \
("\n ".join(docstring_args) if docstring_args else "No parameters required.\n")

if c.section == "functions":
docstring += "\n Returns:\n " + get_docstring_arg_type(c.qualtype)
Expand Down
5 changes: 5 additions & 0 deletions compiler/docs/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def get_title_list(s: str) -> list:
delete_chat_history
send_paid_media
send_paid_reaction
add_to_gifs
""",
chats="""
Chats
Expand Down Expand Up @@ -442,6 +443,10 @@ def get_title_list(s: str) -> list:
set_account_ttl
set_privacy
get_privacy
""",
animation="""
Animation
Animation.add_to_gifs
"""
)

Expand Down

0 comments on commit 04f0d8d

Please sign in to comment.