Skip to content

Commit

Permalink
Merge pull request #265 from kayjan/playground
Browse files Browse the repository at this point in the history
Playground
  • Loading branch information
kayjan authored Jun 27, 2024
2 parents 91e0d16 + ce80a7e commit a5fcdf3
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 94 deletions.
37 changes: 37 additions & 0 deletions .github/DISCUSSION_TEMPLATE/questions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
labels: [question]
body:

- type: textarea
id: example
attributes:
label: Example Code
description: |
Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case.
render: python
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: |
What is the problem or question?
Write a short description telling me what you are trying to do, and the expected outcomes.
placeholder: |
* I have a dataframe with columns a, b, and c (as shown in code above).
* I want to create a tree that does X, Y, and Z.
* I want to export the tree out in the format <format>.
validations:
required: true

- type: textarea
id: context
attributes:
label: Additional Context
description: Add any additional context information or screenshots you think are useful.
placeholder: |
* Platform: [Windows / MacOS / Ubuntu]
* Python version:
* `bigtree` version:
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ site/
.cache
.benchmarks

*.tar.gz
*.whl
docs/_static/playground-config*.js
docs/_static/playground-config.js
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added:
- Docs: Add description and credits to playground.
- Misc: Add template for asking question in Discussions.
### Changed:
- Docs: Homepage to include links to playground, modify emoji location.
- Docs: Playground modify code and code snippet layout.

## [0.19.1] - 2024-06-26
### Changed:
Expand Down
5 changes: 0 additions & 5 deletions docs/_static/playground-config.js

This file was deleted.

10 changes: 5 additions & 5 deletions docs/_static/playground.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/_static/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
<div class="playground-footer" data-search-exclude>
<hr>
<button id="__playground-edit_{el_id}" class="playground-edit" title="Edit the code snippet">Edit</button>
<button id="__playground-share_{el_id}" class="playground-share" title="Copy URL to current snippet">Share</button>
<button id="__playground-run_{el_id}" class="playground-run hidden" title="Run code (Ctrl + Enter)">Run</button>
<button id="__playground-cancel_{el_id}" class="playground-cancel hidden" title="Cancel edit (Escape)">Cancel</button>
<span class='gamut'>Gamut: {gamut}</span>
<button id="__playground-share_{el_id}" style="display:none" class="playground-share" title="Copy code snippet">Share</button>
<button id="__playground-run_{el_id}" class="playground-run hidden" title="Run code">Run</button>
<button id="__playground-cancel_{el_id}" class="playground-cancel hidden" title="Cancel edit">Cancel</button>
<span class='gamut'>Powered by Pyodide. Gamut: {gamut}.</span>
</div>
</div>"""

Expand Down
26 changes: 16 additions & 10 deletions docs/_static/playground_whl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import requests

# Output files
# Parameters
OUTPUT_JS = "docs/_static/"

DEFAULT_COMMANDS = [""]

PLAYGROUND_WHEELS = [
"https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl",
]
PACKAGES = ["bigtree"]

DEFAULT_COMMANDS = [""]
CONFIG = """\
var colorNotebook = {{
"playgroundWheels": {},
Expand All @@ -26,16 +25,23 @@
os.remove(OUTPUT_JS + "playground-config.js")

# Scrape whl file
response = requests.get("https://pypi.org/pypi/bigtree/json")
PACKAGE_WHEEL = [
url["url"] for url in response.json()["urls"] if url["url"].endswith("whl")
]
print(PACKAGE_WHEEL)
PACKAGE_WHEELS = []
for package in PACKAGES:
response = requests.get(f"https://pypi.org/pypi/{package}/json")
package_wheel = [
url["url"] for url in response.json()["urls"] if url["url"].endswith("whl")
]
if len(package_wheel) > 1:
package_wheel = sorted([url for url in package_wheel if "macos" in url])[
-1:
]
PACKAGE_WHEELS.extend(package_wheel)
print("Fetched whls:", PACKAGE_WHEELS)

# Create the config that specifies which wheels need to be used
config = (
CONFIG.format(
str(PLAYGROUND_WHEELS + PACKAGE_WHEEL), "\n".join(DEFAULT_COMMANDS)
str(PLAYGROUND_WHEELS + PACKAGE_WHEELS), "\n".join(DEFAULT_COMMANDS)
)
.replace("\r", "")
.encode("utf-8")
Expand Down
5 changes: 0 additions & 5 deletions docs/bigtree/binarytree/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/bigtree/dag/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/bigtree/node/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/bigtree/tree/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/bigtree/utils/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/bigtree/workflows/index.md

This file was deleted.

File renamed without changes.
13 changes: 6 additions & 7 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ It is pythonic, making it easy to learn and extendable to many types of workflow
- :material-clock-fast:{ .lg .middle } __Set up in 2 minutes__

---
Install [`bigtree`](#) with `pip` or `conda` and get up
and running in minutes
Install [`bigtree`](#) and get up and running in minutes

[:octicons-arrow-right-24: Getting started](home/install.md)
[:octicons-arrow-right-24: Installation](home/install.md)

- :material-map:{ .lg .middle } __Getting started__

Expand All @@ -39,19 +38,19 @@ It is pythonic, making it easy to learn and extendable to many types of workflow

[:octicons-arrow-right-24: Reference](gettingstarted/demo/tree.md)

- :material-newspaper-variant-outline:{ .lg .middle } __Resources__
- :material-slide:{ .lg .middle } __Playground__

---
Articles relating to trees and [`bigtree`](#)
Get some hands-on with [`bigtree`](#)!

[:octicons-arrow-right-24: View articles](gettingstarted/resources/articles.md)
[:octicons-arrow-right-24: Play](playground/index.md)

- :material-heart-outline:{ .lg .middle } __Support bigtree__

---
Do support if you like this project!

[:octicons-arrow-right-24: Support me](https://www.buymeacoffee.com/kayjan)
[:octicons-arrow-right-24: Support](https://www.buymeacoffee.com/kayjan)

</div>

Expand Down
5 changes: 0 additions & 5 deletions docs/others/index.md

This file was deleted.

12 changes: 4 additions & 8 deletions docs/playground/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ hide:

# 🎡️ Playground

This playground is pre-installed with `bigtree` and the Python standard libraries. Play around with the codes. Have fun!

```py play
from bigtree import dict_to_tree
from bigtree import list_to_tree

path_dict = {
"a": {"age": 90},
"a/b": {"age": 65},
"a/c": {"age": 60},
"a/b/d": {"age": 40},
}
root = dict_to_tree(path_dict)
root = list_to_tree(["a/b", "a/c", "a/b/d", "a/b/e", "a/c/f", "a/b/e/g", "a/b/e/h"])
root.show()
```
24 changes: 8 additions & 16 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,41 @@ nav:
- home/benchmarks.md
- home/changelog.md
- Getting Started:
- Glossary:
- gettingstarted/glossary/glossary.md
- Demonstration:
- gettingstarted/demo/tree.md
- gettingstarted/demo/binarytree.md
- gettingstarted/demo/dag.md
- gettingstarted/demo/workflow.md
- Resources:
- gettingstarted/resources/articles.md
- gettingstarted/resources/glossary.md
- Playground:
- playground/index.md
- Code Documentation:
- Node:
- bigtree/node/index.md
- 🌿 Node:
- bigtree/node/basenode.md
- bigtree/node/node.md
- bigtree/node/binarynode.md
- bigtree/node/dagnode.md
- Binary Tree:
- bigtree/binarytree/index.md
- 🌵 Binary Tree:
- bigtree/binarytree/construct.md
- DAG:
- bigtree/dag/index.md
- 🌴 DAG:
- bigtree/dag/construct.md
- bigtree/dag/export.md
- Tree:
- bigtree/tree/index.md
- 🌲 Tree:
- bigtree/tree/construct.md
- bigtree/tree/export.md
- bigtree/tree/helper.md
- bigtree/tree/modify.md
- bigtree/tree/search.md
- Utils:
- bigtree/utils/index.md
- 🔧 Utils:
- bigtree/utils/iterators.md
- bigtree/utils/plot.md
- Workflows:
- bigtree/workflows/index.md
- 👷 Workflows:
- bigtree/workflows/app_todo.md
- bigtree/workflows/app_calendar.md
- Others:
- Tips and Tricks:
- others/index.md
- 💡 Tips and Tricks:
- others/remove_checks.md
- others/list_dir.md
- others/nodes.md
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@ dependencies = [
"mdx_truly_sane_lists==1.3",
"mkdocstrings[python]==0.24.0",
"mkdocs-glightbox",
"requests",
"termynal==0.11.1",
]

[tool.hatch.envs.mkdocs.scripts]
add-cairo = "ln -s /opt/homebrew/lib/libcairo.2.dylib . "
refresh-js = "python docs/_static/playground_whl.py"
coverage = "docstr-coverage bigtree --skip-file-doc --skip-init --exclude \"(.*/exceptions.py|.*/constants.py)\""
build = "mkdocs build"
serve = "mkdocs serve"
serve = "refresh-js && mkdocs serve"
deploy = "mkdocs gh-deploy"

[[tool.hatch.envs.test.matrix]]
Expand Down

0 comments on commit a5fcdf3

Please sign in to comment.