Skip to content

Commit d77809a

Browse files
committed
docs: Add playground to docs
1 parent 567d817 commit d77809a

File tree

8 files changed

+58
-61
lines changed

8 files changed

+58
-61
lines changed

docs/_static/playground-config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var colorNotebook = {
2-
"playgroundWheels": ['pygments-2.17.2-py3-none-any.whl', 'bigtree-0.19.0-py3-none-any.whl'],
3-
"notebookWheels": [],
4-
"defaultPlayground": "print('hello world')"
5-
}
1+
var colorNotebook = {
2+
"playgroundWheels": ['pygments-2.17.2-py3-none-any.whl', 'bigtree-0.19.0-py3-none-any.whl'],
3+
"notebookWheels": [],
4+
"defaultPlayground": ""
5+
}

docs/_static/playground.js

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

docs/_static/playground.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Execute Python code in code blocks (Adapted from ColorAide).
33
44
This can be executed in either a Pyodide environment of a normal Python environment.
5-
3rd party libraries (that are not available directly from Pyodide) are only loaded
6-
when needed so that Pyodide will have a chance to load them if necessary.
7-
85
Transform Python code by executing it, transforming to a Python console output,
96
and finding and outputting color previews.
107
"""
@@ -20,8 +17,6 @@
2017
from pygments.formatters import find_formatter_class
2118
from pygments.lexers import get_lexer_by_name
2219

23-
from bigtree import * # noqa
24-
2520
PY310 = (3, 10) <= sys.version_info
2621
PY311 = (3, 11) <= sys.version_info
2722

@@ -63,7 +58,7 @@
6358
</div>
6459
<div class="playground-footer" data-search-exclude>
6560
<hr>
66-
<button id="__playground-edit_{el_id}" class="playground-edit" title="Edit the current snippet">Edit</button>
61+
<button id="__playground-edit_{el_id}" class="playground-edit" title="Edit the code snippet">Edit</button>
6762
<button id="__playground-share_{el_id}" class="playground-share" title="Copy URL to current snippet">Share</button>
6863
<button id="__playground-run_{el_id}" class="playground-run hidden" title="Run code (Ctrl + Enter)">Run</button>
6964
<button id="__playground-cancel_{el_id}" class="playground-cancel hidden" title="Cancel edit (Escape)">Cancel</button>

docs/_static/playground_whl.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,28 @@
88
import urllib.request
99

1010
# Output files
11-
OUTPUT_WHL = "docs/playground/"
11+
OUTPUT_WHL = "docs/_static/"
1212
OUTPUT_JS = "docs/_static/"
1313

1414
# Build message output
15-
BUILD_WHL_MESSAGE = f"{OUTPUT_WHL}(.*whl)"
16-
BUILD_WHL_COMMAND = [sys.executable, "-m", "hatch", "build", OUTPUT_WHL]
15+
# BUILD_WHL_MESSAGE = f"{OUTPUT_WHL}(.*whl)"
16+
# BUILD_WHL_COMMAND = [sys.executable, "-m", "hatch", "build", OUTPUT_WHL]
17+
BUILD_WHL_MESSAGE = r"Successfully built ([-_0-9.a-zA-Z]+?\.whl)"
18+
BUILD_WHL_COMMAND = [sys.executable, "-m", "build", "--wheel", "-o", OUTPUT_WHL]
1719

18-
DEFAULT_COMMANDS = ["print('hello world')"]
20+
DEFAULT_COMMANDS = [""]
21+
22+
PLAYGROUND_WHEELS = [
23+
"https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl"
24+
]
25+
26+
CONFIG = """\
27+
var colorNotebook = {{
28+
"playgroundWheels": {},
29+
"notebookWheels": [],
30+
"defaultPlayground": "{}"
31+
}}
32+
"""
1933

2034

2135
def build_package():
@@ -39,7 +53,9 @@ def build_package():
3953
env=os.environ.copy(),
4054
)
4155
out, _ = process.communicate()
42-
m = re.compile(BUILD_WHL_MESSAGE).search(out.decode("utf-8"))
56+
build_message = out.decode("utf-8")
57+
m = re.compile(BUILD_WHL_MESSAGE).search(build_message)
58+
print(build_message)
4359

4460
return process.returncode, m.group(1) if m else ""
4561

@@ -67,18 +83,6 @@ def download_wheel(url, dest):
6783

6884
if __name__ == "__main__":
6985

70-
PLAYGROUND_WHEELS = [
71-
"https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl"
72-
]
73-
74-
CONFIG = """\
75-
var colorNotebook = {{
76-
"playgroundWheels": {},
77-
"notebookWheels": [],
78-
"defaultPlayground": "{}"
79-
}}
80-
"""
81-
8286
PLAYGROUND = {}
8387
for url in PLAYGROUND_WHEELS:
8488
PLAYGROUND[os.path.join(OUTPUT_WHL, url.split("/")[-1])] = url

docs/playground/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Playground
3+
hide:
4+
- navigation
5+
- toc
6+
---
7+
8+
# 🎡️ Playground
9+
10+
```py play
11+
# from bigtree import dict_to_tree
12+
13+
path_dict = {
14+
"a": {"age": 90},
15+
"a/b": {"age": 65},
16+
"a/c": {"age": 60},
17+
"a/b/d": {"age": 40},
18+
}
19+
root = dict_to_tree(path_dict)
20+
root.show()
21+
```

docs/playground/playground.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
black>=24.1.0
2+
build
23
IPython
34
mdx_truly_sane_lists==1.3
45
mkdocs==1.5.3

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ nav:
2929
- Resources:
3030
- gettingstarted/resources/articles.md
3131
- Playground:
32-
- playground/playground.md
32+
- playground/index.md
3333
- Code Documentation:
3434
- Node:
3535
- bigtree/node/index.md

0 commit comments

Comments
 (0)