From 4e124ef7e7175f6f9dc8fa1c1dfec8700e3e94c6 Mon Sep 17 00:00:00 2001 From: Kay Date: Mon, 4 Nov 2024 22:57:24 +0800 Subject: [PATCH 1/2] docs: more tips and tricks for custom classes --- docs/others/work_with_classes.md | 37 ++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 38 insertions(+) create mode 100644 docs/others/work_with_classes.md diff --git a/docs/others/work_with_classes.md b/docs/others/work_with_classes.md new file mode 100644 index 00000000..1dfc23eb --- /dev/null +++ b/docs/others/work_with_classes.md @@ -0,0 +1,37 @@ +# Working with Classes + +Custom classes can be assigned to Node as `data` attribute, or any other attribute name. + +```python +from bigtree import Node + + +class Folder: + def __init__(self, name: str): + self.name = name + + def __str__(self): + return f"Folder<{self.name}>" + +class File: + def __init__(self, name: str): + self.name = name + + def __str__(self): + return f"File<{self.name}>" + +folder_documents = Node("My Documents", data=Folder("Documents")) +file_photo1 = Node("photo1.jpg", data=File("photo.jpg")) +file_photo2 = Node("photo2.jpg", data=File("photo.jpg")) +folder_documents.children = [file_photo1, file_photo2] + +folder_documents.show() +# My Documents +# ├── photo1.jpg +# └── photo2.jpg + +folder_documents.show(alias="data") +# Folder +# ├── File +# └── File +``` diff --git a/mkdocs.yml b/mkdocs.yml index c6b388b6..8876c3d8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -59,6 +59,7 @@ nav: - others/nodes.md - others/merging_trees.md - others/weighted_trees.md + - others/work_with_classes.md theme: name: material From f1dd40b08ed8c4e51a736dc83c3ef9d31bdf7d2f Mon Sep 17 00:00:00 2001 From: Kay Date: Mon, 4 Nov 2024 23:00:53 +0800 Subject: [PATCH 2/2] bump: v0.22.2 planned --- CHANGELOG.md | 6 +++++- bigtree/__init__.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44713d12..d58d26f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,14 @@ 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] + +## [0.22.2] - 2024-11-11 ### Added: - Tree Export: Print tree to allow alias. - Tree Export: Mermaid diagram to include theme. ### Fixed: - Misc: Doctest for docstrings, docstring to indicate usage prefers `node_name` to `name`. +- Misc: Documentation to include tips and tricks on working with custom classes. - Tree Export: Mermaid diagram title to add newline. - Tree Helper: Get tree diff string replacement bug when the path change is substring of another path. @@ -686,7 +689,8 @@ ignore null attribute columns. - Utility Iterator: Tree traversal methods. - Workflow To Do App: Tree use case with to-do list implementation. -[Unreleased]: https://github.com/kayjan/bigtree/compare/0.22.1...HEAD +[Unreleased]: https://github.com/kayjan/bigtree/compare/0.22.2...HEAD +[0.22.2]: https://github.com/kayjan/bigtree/compare/0.22.1...0.22.2 [0.22.1]: https://github.com/kayjan/bigtree/compare/0.22.0...0.22.1 [0.22.0]: https://github.com/kayjan/bigtree/compare/0.21.3...0.22.0 [0.21.3]: https://github.com/kayjan/bigtree/compare/0.21.2...0.21.3 diff --git a/bigtree/__init__.py b/bigtree/__init__.py index 097125ed..9cc0db0f 100644 --- a/bigtree/__init__.py +++ b/bigtree/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.22.1" +__version__ = "0.22.2" from bigtree.binarytree.construct import list_to_binarytree from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag