Skip to content

Commit 2cf2a15

Browse files
Quek Ching YeeQuek Ching Yee
authored andcommitted
docs: allow jupyter notebook
1 parent 0961df6 commit 2cf2a15

File tree

4 files changed

+247
-2
lines changed

4 files changed

+247
-2
lines changed
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# 📋 Workflow Demonstration\n",
8+
"\n",
9+
"There are existing implementations of workflows to showcase how `bigtree` can be used!"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {
15+
"vscode": {
16+
"languageId": "plaintext"
17+
}
18+
},
19+
"source": [
20+
"## To Do Application\n",
21+
"There are functions to:\n",
22+
"\n",
23+
"- Add or remove list to To-Do application\n",
24+
"- Add or remove item to list, default list is the 'General' list\n",
25+
"- Prioritize a list/item by reordering them as first list/item\n",
26+
"- Save and import To-Do application to and from an external JSON file\n",
27+
"- Show To-Do application, which prints tree to console\n"
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": 1,
33+
"metadata": {},
34+
"outputs": [
35+
{
36+
"name": "stdout",
37+
"output_type": "stream",
38+
"text": [
39+
"To Do App\n",
40+
"├── School\n",
41+
"│ └── Homework 1\n",
42+
"├── Groceries\n",
43+
"│ ├── Milk [description=Urgent]\n",
44+
"│ └── Bread [description=Urgent]\n",
45+
"└── General\n",
46+
" └── Cook\n"
47+
]
48+
}
49+
],
50+
"source": [
51+
"from bigtree import AppToDo\n",
52+
"\n",
53+
"app = AppToDo(\"To Do App\")\n",
54+
"app.add_item(item_name=\"Homework 1\", list_name=\"School\")\n",
55+
"app.add_item(item_name=[\"Milk\", \"Bread\"], list_name=\"Groceries\", description=\"Urgent\")\n",
56+
"app.add_item(item_name=\"Cook\")\n",
57+
"app.show()"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": 2,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"app.save(\"list.json\")\n",
67+
"app2 = AppToDo.load(\"list.json\")"
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"## Calendar Application\n",
75+
"\n",
76+
"There are functions to:\n",
77+
"\n",
78+
"- Add or remove event from Calendar\n",
79+
"- Find event by name, or name and date\n",
80+
"- Display calendar, which prints events to console\n",
81+
"- Export calendar to pandas DataFrame"
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": 3,
87+
"metadata": {},
88+
"outputs": [
89+
{
90+
"name": "stdout",
91+
"output_type": "stream",
92+
"text": [
93+
"My Calendar\n",
94+
"2023-01-01 00:00:00 - Dinner (budget: 20)\n",
95+
"2023-01-01 18:00:00 - Gym\n",
96+
"2023-01-02 18:00:00 - Gym\n"
97+
]
98+
}
99+
],
100+
"source": [
101+
"import datetime as dt\n",
102+
"from bigtree import Calendar\n",
103+
"\n",
104+
"calendar = Calendar(\"My Calendar\")\n",
105+
"calendar.add_event(\"Gym\", \"2023-01-01 18:00\")\n",
106+
"calendar.add_event(\"Dinner\", \"2023-01-01\", date_format=\"%Y-%m-%d\", budget=20)\n",
107+
"calendar.add_event(\"Gym\", \"2023-01-02 18:00\")\n",
108+
"calendar.show()"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": 4,
114+
"metadata": {},
115+
"outputs": [
116+
{
117+
"name": "stdout",
118+
"output_type": "stream",
119+
"text": [
120+
"2023-01-01 18:00:00 - Gym\n",
121+
"2023-01-02 18:00:00 - Gym\n"
122+
]
123+
}
124+
],
125+
"source": [
126+
"calendar.find_event(\"Gym\")"
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"execution_count": 5,
132+
"metadata": {},
133+
"outputs": [
134+
{
135+
"name": "stdout",
136+
"output_type": "stream",
137+
"text": [
138+
"My Calendar\n",
139+
"2023-01-01 00:00:00 - Dinner (budget: 20)\n",
140+
"2023-01-02 18:00:00 - Gym\n"
141+
]
142+
}
143+
],
144+
"source": [
145+
"calendar.delete_event(\"Gym\", dt.date(2023, 1, 1))\n",
146+
"calendar.show()"
147+
]
148+
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": 6,
152+
"metadata": {},
153+
"outputs": [
154+
{
155+
"data": {
156+
"text/html": [
157+
"<div>\n",
158+
"<style scoped>\n",
159+
" .dataframe tbody tr th:only-of-type {\n",
160+
" vertical-align: middle;\n",
161+
" }\n",
162+
"\n",
163+
" .dataframe tbody tr th {\n",
164+
" vertical-align: top;\n",
165+
" }\n",
166+
"\n",
167+
" .dataframe thead th {\n",
168+
" text-align: right;\n",
169+
" }\n",
170+
"</style>\n",
171+
"<table border=\"1\" class=\"dataframe\">\n",
172+
" <thead>\n",
173+
" <tr style=\"text-align: right;\">\n",
174+
" <th></th>\n",
175+
" <th>path</th>\n",
176+
" <th>name</th>\n",
177+
" <th>date</th>\n",
178+
" <th>time</th>\n",
179+
" <th>budget</th>\n",
180+
" </tr>\n",
181+
" </thead>\n",
182+
" <tbody>\n",
183+
" <tr>\n",
184+
" <th>0</th>\n",
185+
" <td>/My Calendar/2023/01/01/Dinner</td>\n",
186+
" <td>Dinner</td>\n",
187+
" <td>2023-01-01</td>\n",
188+
" <td>00:00:00</td>\n",
189+
" <td>20.0</td>\n",
190+
" </tr>\n",
191+
" <tr>\n",
192+
" <th>1</th>\n",
193+
" <td>/My Calendar/2023/01/02/Gym</td>\n",
194+
" <td>Gym</td>\n",
195+
" <td>2023-01-02</td>\n",
196+
" <td>18:00:00</td>\n",
197+
" <td>NaN</td>\n",
198+
" </tr>\n",
199+
" </tbody>\n",
200+
"</table>\n",
201+
"</div>"
202+
],
203+
"text/plain": [
204+
" path name date time budget\n",
205+
"0 /My Calendar/2023/01/01/Dinner Dinner 2023-01-01 00:00:00 20.0\n",
206+
"1 /My Calendar/2023/01/02/Gym Gym 2023-01-02 18:00:00 NaN"
207+
]
208+
},
209+
"execution_count": 6,
210+
"metadata": {},
211+
"output_type": "execute_result"
212+
}
213+
],
214+
"source": [
215+
"data_calendar = calendar.to_dataframe()\n",
216+
"data_calendar"
217+
]
218+
}
219+
],
220+
"metadata": {
221+
"kernelspec": {
222+
"display_name": "bigtree",
223+
"language": "python",
224+
"name": "python3"
225+
},
226+
"language_info": {
227+
"codemirror_mode": {
228+
"name": "ipython",
229+
"version": 3
230+
},
231+
"file_extension": ".py",
232+
"mimetype": "text/x-python",
233+
"name": "python",
234+
"nbconvert_exporter": "python",
235+
"pygments_lexer": "ipython3",
236+
"version": "3.10.14"
237+
}
238+
},
239+
"nbformat": 4,
240+
"nbformat_minor": 2
241+
}

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ IPython
33
mdx_truly_sane_lists==1.3
44
mkdocs==1.5.3
55
mkdocs-glightbox==0.3.7
6+
mkdocs-jupyter
67
mkdocs-material[imaging]==9.5.17
78
mkdocstrings[python]>=0.25.0 # griffe.collections error
89
pandas

mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ nav:
2323
- gettingstarted/demo/tree.md
2424
- gettingstarted/demo/binarytree.md
2525
- gettingstarted/demo/dag.md
26-
- gettingstarted/demo/workflow.md
26+
- gettingstarted/demo/workflow.ipynb
2727
- Resources:
2828
- gettingstarted/resources/articles.md
2929
- gettingstarted/resources/glossary.md
@@ -93,6 +93,8 @@ theme:
9393

9494
plugins:
9595
- glightbox # expand images
96+
- mkdocs-jupyter
97+
include_source: True
9698
- search
9799
- social:
98100
cards_layout_options:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ dependencies = [
101101
"docstr-coverage",
102102
"IPython",
103103
"mkdocs==1.5.3",
104+
"mkdocs-glightbox",
105+
"mkdocs-jupyter",
104106
"mkdocs-material[imaging]==9.5.17",
105107
"mdx_truly_sane_lists==1.3",
106108
"mkdocstrings[python]==0.24.0",
107-
"mkdocs-glightbox",
108109
"requests",
109110
"termynal==0.11.1",
110111
]

0 commit comments

Comments
 (0)