Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cool cards #5727

Merged
merged 13 commits into from
Nov 14, 2023
81 changes: 37 additions & 44 deletions website/content/bot/changelog/index.mdx
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
# changelog
---
title: Changelog
---
import NewReferenceCard from "@site/src/components/General/NewReferenceCard";
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

import ReferenceCard from "@site/src/components/General/ReferenceCard";
<HeadTitle title="Changelog | OpenBB Bot Docs" />

<ul className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 -ml-6">

<ReferenceCard
title="v1.0.0"
description="v1.0.0"
url="changelog/v1.0.0"
/>
<ReferenceCard
title="v1.0.1"
description="v1.0.1"
url="changelog/v1.0.1"
<ul className="grid grid-cols-1 gap-4 -ml-6">
<NewReferenceCard
title="Current - v2.0.0"
url="changelog/version2_0_0"
/>
<ReferenceCard
title="v1.0.2"
description="v1.0.2"
url="changelog/v1.0.2"
<NewReferenceCard
title="v1.0.8"
url="changelog/version1_0_8"
/>
<ReferenceCard
title="v1.0.3"
description="v1.0.3"
url="changelog/v1.0.3"
<NewReferenceCard
title="v1.0.7"
url="changelog/version1_0_7"
/>
<ReferenceCard
title="v1.0.4"
description="v1.0.4"
url="changelog/v1.0.4"
<NewReferenceCard
title="v1.0.6"
url="changelog/version1_0_6"
/>
<ReferenceCard
<NewReferenceCard
title="v1.0.5"
description="v1.0.5"
url="changelog/v1.0.5"
url="changelog/version1_0_5"
/>
<ReferenceCard
title="v1.0.6"
description="v1.0.6"
url="changelog/v1.0.6"
<NewReferenceCard
title="v1.0.4"
url="changelog/version1_0_4"
/>
<ReferenceCard
title="v1.0.7"
description="v1.0.7"
url="changelog/v1.0.7"
<NewReferenceCard
title="v1.0.3"
url="changelog/version1_0_3"
/>
<ReferenceCard
title="v1.0.8"
description="v1.0.8"
url="changelog/v1.0.8"
<NewReferenceCard
title="v1.0.2"
url="changelog/version1_0_2"
/>
<ReferenceCard
title="Current - v2.0.0"
description="v2.0.0"
url="changelog/Current - v2.0.0"
<NewReferenceCard
title="v1.0.1"
url="changelog/version1_0_1"
/>
<NewReferenceCard
title="v1.0.0"
url="changelog/version1_0_0"
/>
</ul>
2 changes: 0 additions & 2 deletions website/content/bot/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="FAQs | OpenBB Bot Docs" />

## Generic

<details><summary>How Do I Link My OpenBB Bot Account?</summary>

After you signup for an OpenBB Bot plan you can link your accounts from <a href="https://my.openbb.co/app/bot" class="_hyper-link">here</a>
Expand Down
27 changes: 0 additions & 27 deletions website/content/bot/index.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion website/content/bot/installation/discord.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Setting up Discord bot
title: Discord bot
sidebar_position: 2
description: This page guides you on how to add a bot to your Discord server, through
steps of login, bot authorization, and adjusting bot permissions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Overview
title: Installation
sidebar_position: 1
description: Learn how to use OpenBB Bot in Discord and Telegram. Understand the requirements
for individual and server uses, and explore additional features by linking your
Expand Down
22 changes: 0 additions & 22 deletions website/content/bot/installation/index.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion website/content/bot/installation/telegram.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Setting up Telegram bot
title: Telegram bot
sidebar_position: 3
description: Step-by-step guide to add the OpenBB Bot to a Telegram group. From starting
a chat with the bot to verifying its permissions, follow these steps to have your
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Overview
title: Customization
sidebar_position: 1
description: A guide to OpenBB Bot settings customization, including chart themes,
alerts, autoposting, and more. Learn how to link your account and start personalizing
Expand All @@ -18,10 +18,9 @@ keywords:

import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="Overview - Customizing - Usage | OpenBB Bot Docs" />
<HeadTitle title="Customizing - Usage | OpenBB Bot Docs" />

For the best user experience, you will want to customize the OpenBB Bot settings. Different types of customizations we offer are:

<div className="flex">
<ul>
<li>
Expand Down
22 changes: 0 additions & 22 deletions website/content/bot/usage/customizing/index.mdx

This file was deleted.

32 changes: 18 additions & 14 deletions website/content/bot/usage/index.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# usage
---
title: Usage
---

import ReferenceCard from "@site/src/components/General/ReferenceCard";
import NewReferenceCard from "@site/src/components/General/NewReferenceCard";
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<ul className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 -ml-6">
<HeadTitle title="Usage | OpenBB Bot Docs" />

<ReferenceCard
title="Customizing"
description="individual, overview, server"
url="usage/customizing"
/>
<ReferenceCard
<ul className="grid grid-cols-1 gap-4 -ml-6">
<NewReferenceCard
title="Discord"
description="Learn how to use the OpenBB Discord Bot using slash commands to explore"
url="usage/Discord"
description="Learn how to use the OpenBB Bot on Discord"
url="usage/discord"
/>
<ReferenceCard
<NewReferenceCard
title="Telegram"
description="A complete guide on how to use the OpenBB Telegram Bot for stock and"
url="usage/Telegram"
description="Learn how to use the OpenBB Bot on Telegram"
url="usage/telegram"
/>
<NewReferenceCard
title="Customizing"
description="Customize your OpenBB Bot experience through the OpenBB Hub"
url="usage/customizing"
/>
</ul>
37 changes: 28 additions & 9 deletions website/content/generate_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
from textwrap import shorten
from typing import Dict, List

# Importing the ReferenceCard component for use in the generated index
reference_import = """import ReferenceCard from "@site/src/components/General/ReferenceCard";

<ul className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 -ml-6">
"""
# Setting the encoding and newline character for file writing
wopen_kwargs = {"encoding": "utf-8", "newline": "\n"}


# Function to create command cards for each command in the provided list
def create_cmd_cards(cmd_text: List[Dict[str, str]], url: str) -> str:
_cmd_cards = ""
for cmd in cmd_text:
# Shortening the description to fit within the card
cmd["description"] = shorten(f"{cmd['description']}", 116, placeholder="...")
# Adding the command card to the list
_cmd_cards += f"""<ReferenceCard
title="{cmd["name"]}"
description="{cmd["description"]}"
Expand All @@ -22,7 +27,9 @@ def create_cmd_cards(cmd_text: List[Dict[str, str]], url: str) -> str:
return _cmd_cards


# Function to create a card for each subfolder in the provided folder
def create_nested_subfolder_card(_folder: Path, url: str) -> str:
# Creating a list of all markdown files in the subfolder
nested_card = f"""<ReferenceCard
title="{_folder.name.capitalize()}"
description="{', '.join([sub.stem for sub in _folder.glob('**/*.md*') if sub.is_file() and sub.stem != 'index'])}"
Expand All @@ -31,28 +38,33 @@ def create_nested_subfolder_card(_folder: Path, url: str) -> str:
return nested_card


for bot in [
# Looping through each topfolder to generate the index
for topfolder in [
"terminal",
"platform",
"bot",
"terminal/usage",
"terminal/menus",
]:
for folder in (Path(__file__).parent / bot).iterdir():
rel_path = folder.relative_to(Path(__file__).parent / bot)
# Looping through each folder in the fold directory
for folder in (Path(__file__).parent / topfolder).iterdir():
rel_path = folder.relative_to(Path(__file__).parent / topfolder)
cmd_cards: List[Dict[str, str]] = []

print(rel_path)
print(cmd_cards)

# Looping through each markdown file in the folder
for file in folder.glob("*.md*"):
if file.stem == "index":
continue

# Regex to extract the description from the file
desc_regex = re.compile(r"^---(.*?)---", re.DOTALL | re.MULTILINE)

description = desc_regex.search(file.read_text(encoding="utf-8")).group(1).strip() # type: ignore

# Regex to extract the title and description from the description
pattern = re.compile(r"^(title|description):\s*(.*)$", re.MULTILINE)

# Find all matches in the text
Expand All @@ -66,37 +78,44 @@ def create_nested_subfolder_card(_folder: Path, url: str) -> str:
elif key == "description":
description = value.strip()

# Creating a dictionary for the command
cmd_dict = dict(
name=title,
description=description,
url=f"{bot}/{rel_path}",
url=f"{topfolder}/{rel_path}",
)

# Adding the command to the list of commands
cmd_cards.append(cmd_dict)

if not cmd_cards:
continue

# Writing the index for the subfolder
with open(
Path(__file__).parent / bot / rel_path / "index.mdx", "w", **wopen_kwargs # type: ignore
Path(__file__).parent / topfolder / rel_path / "index.mdx", "w", **wopen_kwargs # type: ignore
) as subindex:
subindex.write(f"# {folder.name}\n\n{reference_import}\n")

# Writing a card for each subfolder in the folder
for subfolder in folder.glob("*"):
if not subfolder.is_dir():
continue

subindex.write(create_nested_subfolder_card(subfolder, f"{rel_path}"))
print(cmd_cards)
# Writing the command cards to the index
subindex.write(create_cmd_cards(cmd_cards, f'{"/".join(rel_path.parts)}'))
subindex.write("</ul>\n")

with open(Path(__file__).parent / bot / "index.mdx", "w", **wopen_kwargs) as index: # type: ignore
index.write(f"# OpenBB {bot.title()} Reference\n\n{reference_import}\n")
# Writing the main index for the topfolder
with open(Path(__file__).parent / topfolder / "index.mdx", "w", **wopen_kwargs) as index: # type: ignore
index.write(f"# OpenBB {topfolder.title()} Reference\n\n{reference_import}\n")

for folder in (Path(__file__).parent / bot).glob("*"):
# Writing a card for each folder in the bot directory
for folder in (Path(__file__).parent / topfolder).glob("*"):
if not folder.is_dir():
continue

index.write(create_nested_subfolder_card(folder, bot))
index.write(create_nested_subfolder_card(folder, topfolder))
index.write("</ul>\n")
Loading
Loading