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

Add jupyter notebook for mkdocs #311

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
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
241 changes: 241 additions & 0 deletions docs/gettingstarted/demo/workflow.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 📋 Workflow Demonstration\n",
"\n",
"There are existing implementations of workflows to showcase how `bigtree` can be used!"
]
},
{
"cell_type": "markdown",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
},
"source": [
"## To Do Application\n",
"There are functions to:\n",
"\n",
"- Add or remove list to To-Do application\n",
"- Add or remove item to list, default list is the 'General' list\n",
"- Prioritize a list/item by reordering them as first list/item\n",
"- Save and import To-Do application to and from an external JSON file\n",
"- Show To-Do application, which prints tree to console\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"To Do App\n",
"├── School\n",
"│ └── Homework 1\n",
"├── Groceries\n",
"│ ├── Milk [description=Urgent]\n",
"│ └── Bread [description=Urgent]\n",
"└── General\n",
" └── Cook\n"
]
}
],
"source": [
"from bigtree import AppToDo\n",
"\n",
"app = AppToDo(\"To Do App\")\n",
"app.add_item(item_name=\"Homework 1\", list_name=\"School\")\n",
"app.add_item(item_name=[\"Milk\", \"Bread\"], list_name=\"Groceries\", description=\"Urgent\")\n",
"app.add_item(item_name=\"Cook\")\n",
"app.show()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"app.save(\"list.json\")\n",
"app2 = AppToDo.load(\"list.json\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calendar Application\n",
"\n",
"There are functions to:\n",
"\n",
"- Add or remove event from Calendar\n",
"- Find event by name, or name and date\n",
"- Display calendar, which prints events to console\n",
"- Export calendar to pandas DataFrame"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My Calendar\n",
"2023-01-01 00:00:00 - Dinner (budget: 20)\n",
"2023-01-01 18:00:00 - Gym\n",
"2023-01-02 18:00:00 - Gym\n"
]
}
],
"source": [
"import datetime as dt\n",
"from bigtree import Calendar\n",
"\n",
"calendar = Calendar(\"My Calendar\")\n",
"calendar.add_event(\"Gym\", \"2023-01-01 18:00\")\n",
"calendar.add_event(\"Dinner\", \"2023-01-01\", date_format=\"%Y-%m-%d\", budget=20)\n",
"calendar.add_event(\"Gym\", \"2023-01-02 18:00\")\n",
"calendar.show()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2023-01-01 18:00:00 - Gym\n",
"2023-01-02 18:00:00 - Gym\n"
]
}
],
"source": [
"calendar.find_event(\"Gym\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"My Calendar\n",
"2023-01-01 00:00:00 - Dinner (budget: 20)\n",
"2023-01-02 18:00:00 - Gym\n"
]
}
],
"source": [
"calendar.delete_event(\"Gym\", dt.date(2023, 1, 1))\n",
"calendar.show()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>path</th>\n",
" <th>name</th>\n",
" <th>date</th>\n",
" <th>time</th>\n",
" <th>budget</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>/My Calendar/2023/01/01/Dinner</td>\n",
" <td>Dinner</td>\n",
" <td>2023-01-01</td>\n",
" <td>00:00:00</td>\n",
" <td>20.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>/My Calendar/2023/01/02/Gym</td>\n",
" <td>Gym</td>\n",
" <td>2023-01-02</td>\n",
" <td>18:00:00</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" path name date time budget\n",
"0 /My Calendar/2023/01/01/Dinner Dinner 2023-01-01 00:00:00 20.0\n",
"1 /My Calendar/2023/01/02/Gym Gym 2023-01-02 18:00:00 NaN"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_calendar = calendar.to_dataframe()\n",
"data_calendar"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "bigtree",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ IPython
mdx_truly_sane_lists==1.3
mkdocs==1.5.3
mkdocs-glightbox==0.3.7
mkdocs-jupyter
mkdocs-material[imaging]==9.5.17
mkdocstrings[python]>=0.25.0 # griffe.collections error
pandas
Expand Down
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nav:
- gettingstarted/demo/tree.md
- gettingstarted/demo/binarytree.md
- gettingstarted/demo/dag.md
- gettingstarted/demo/workflow.md
- gettingstarted/demo/workflow.ipynb
- Resources:
- gettingstarted/resources/articles.md
- gettingstarted/resources/glossary.md
Expand Down Expand Up @@ -93,6 +93,8 @@ theme:

plugins:
- glightbox # expand images
- mkdocs-jupyter
include_source: True
- search
- social:
cards_layout_options:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ dependencies = [
"docstr-coverage",
"IPython",
"mkdocs==1.5.3",
"mkdocs-glightbox",
"mkdocs-jupyter",
"mkdocs-material[imaging]==9.5.17",
"mdx_truly_sane_lists==1.3",
"mkdocstrings[python]==0.24.0",
"mkdocs-glightbox",
"requests",
"termynal==0.11.1",
]
Expand Down
Loading