mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-27 11:41:32 +00:00
if there's no menu description on reference.json, use the commands of that menu to create a pseudo description
This commit is contained in:
@@ -180,6 +180,9 @@ class MenuText:
|
||||
if description == self.menu_path + name:
|
||||
description = ""
|
||||
|
||||
if len(description) > self.CMD_DESCRIPTION_LENGTH:
|
||||
description = description[: self.CMD_DESCRIPTION_LENGTH - 3] + "..."
|
||||
|
||||
menu = f"{name}{spacing}{description}"
|
||||
tag = "unvl" if disable else "menu"
|
||||
self.menu_text += f"[{tag}]> {menu}[/{tag}]\n"
|
||||
|
||||
@@ -274,13 +274,26 @@ class PlatformController(BaseController):
|
||||
|
||||
def _get_menu_description(self, menu: str) -> str:
|
||||
"""Get menu description."""
|
||||
|
||||
def _get_sub_menu_commands():
|
||||
"""Get sub menu commands."""
|
||||
sub_path = f"{self.PATH[1:].replace('/','_')}{menu}"
|
||||
commands = []
|
||||
for trl in self.translators:
|
||||
if sub_path in trl:
|
||||
commands.append(trl.replace(f"{sub_path}_", ""))
|
||||
return commands
|
||||
|
||||
menu_description = (
|
||||
obb.reference["routers"] # type: ignore
|
||||
.get(f"{self.PATH}{menu}", {})
|
||||
.get("description", "")
|
||||
) or ""
|
||||
if menu_description:
|
||||
return menu_description.split(".")[0].lower()
|
||||
|
||||
return menu_description.split(".")[0].lower()
|
||||
# If no description is found, return the sub menu commands
|
||||
return ", ".join(_get_sub_menu_commands())
|
||||
|
||||
def print_help(self):
|
||||
"""Print help."""
|
||||
|
||||
Reference in New Issue
Block a user