Skip to content

Commit 803a195

Browse files
authored
Merge pull request #177 from kayjan/mkdocs
Mkdocs
2 parents 8bb2264 + 2714c0d commit 803a195

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+5000
-2398
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ jobs:
2525
needs: setup
2626
steps:
2727
- uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
2830
- name: Set up Python
2931
uses: actions/setup-python@v4
3032
- name: Install dependencies
3133
run: |
32-
pip install -r docs_sphinx/requirements.txt
33-
- name: Sphinx build
34-
run: |
35-
sphinx-build docs_sphinx/source docs_sphinx/build
34+
pip install -r docs/requirements.txt
35+
git config user.name 'github-actions[bot]' && git config user.email 'github-actions[bot]@users.noreply.github.com'
3636
- name: Deploy to GH Pages
37-
uses: peaceiris/actions-gh-pages@v3
38-
with:
39-
publish_branch: gh-pages
40-
github_token: ${{ secrets.GITHUB_TOKEN }}
41-
publish_dir: docs_sphinx/build/
42-
force_orphan: true
37+
run: mkdocs gh-deploy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist/
88
*.DS_Store
99
assets/docstr
1010
site/
11+
.cache

.readthedocs.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ build:
1212
python: "3.8"
1313

1414
# Build documentation in the docs/ directory with Sphinx
15-
sphinx:
16-
configuration: docs_sphinx/source/conf.py
15+
mkdocs:
16+
configuration: mkdocs.yml
17+
fail_on_warning: false
1718

1819
# Optionally declare the Python requirements required to build your docs
1920
python:
2021
install:
21-
- requirements: docs_sphinx/requirements.txt
22+
- requirements: docs/requirements.txt

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1-
# Changelog
1+
# 🍂 Changelog
22
All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
88

9+
## [0.16.0] - 2023-01-28
10+
### Added
11+
- Misc: Documentation using mkdocs.
12+
### Changed
13+
- Misc: Markdown edit for README, CHANGELOG.
14+
- Misc: Docstring to indicate Examples, to indicate exceptions for BaseNode and DAGNode, simplify code for tree modification.
15+
### Fixed
16+
- Misc: Docstring bullet point alignment, images compatibility with markdown.
17+
918
## [0.15.7] - 2023-01-26
1019
### Added
1120
- Misc: Sphinx documentation to support mermaid markdown images, reflect CHANGELOG section, add more emojis.
@@ -473,7 +482,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
473482
- Utility Iterator: Tree traversal methods.
474483
- Workflow To Do App: Tree use case with to-do list implementation.
475484

476-
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.15.7...HEAD
485+
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.16.0...HEAD
486+
[0.16.0]: https://github.com/kayjan/bigtree/compare/0.15.7...0.16.0
477487
[0.15.7]: https://github.com/kayjan/bigtree/compare/0.15.6...0.15.7
478488
[0.15.6]: https://github.com/kayjan/bigtree/compare/0.15.5...0.15.6
479489
[0.15.5]: https://github.com/kayjan/bigtree/compare/0.15.4...0.15.5

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Related Links:
2222
- [The Reingold Tilford Algorithm Explained, with Walkthrough](https://towardsdatascience.com/reingold-tilford-algorithm-explained-with-walkthrough-be5810e8ed93?sk=2db8e10398cee76c486c4b06b0b33322)
2323
- <div><p>If you want to support bigtree, <a href="https://www.buymeacoffee.com/kayjan"><img src="https://img.shields.io/badge/Buy_Me_A_Coffee-FFDD00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black" alt="Buy Me a Coffee" style="vertical-align:middle"></a></p></div>
2424

25-
----
25+
-----
2626

2727
## Components
2828
There are 3 segments to Big Tree consisting of Tree, Binary Tree, and Directed Acyclic Graph (DAG) implementation.
@@ -87,7 +87,7 @@ Binary Node inherits from Node, so the components in Tree implementation are als
8787
3. [**➰ Traversing Binary Tree**](https://bigtree.readthedocs.io/en/latest/bigtree/utils/iterators.html)
8888
1. In-Order Traversal
8989

90-
--------
90+
-----
9191

9292
For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components.
9393

@@ -103,46 +103,46 @@ For **Directed Acyclic Graph (DAG)** implementation, there are 4 main components
103103
1. Export to *list*, *dictionary*, or *pandas DataFrame*
104104
2. Export DAG to *dot* (can save to .dot, .png, .svg, .jpeg files)
105105

106-
----
106+
-----
107107

108108
## Installation
109109

110-
There are two ways to install `bigtree`, with pip (from PyPI) or conda (from conda-forge).
110+
There are two ways to install `bigtree`, with pip (recommended) or conda.
111111

112-
### a) Installation with pip (recommended)
112+
### a) Installation with pip
113113

114114
To install `bigtree`, run the following line in command prompt:
115115

116-
```shell
116+
```console
117117
$ pip install bigtree
118118
```
119119

120120
If tree needs to use pandas methods, it requires additional dependencies.
121121
Run the following line in command prompt:
122122

123-
```shell
123+
```console
124124
$ pip install 'bigtree[pandas]'
125125
```
126126

127127
If tree needs to be exported to image, it requires additional dependencies.
128128
Run the following lines in command prompt:
129129

130-
```shell
130+
```console
131131
$ pip install 'bigtree[image]'
132132
$ brew install gprof2dot # for MacOS
133133
$ conda install graphviz # for Windows
134134
```
135135

136136
Alternatively, install all optional dependencies with the following line in command prompt:
137137

138-
```shell
138+
```console
139139
$ pip install 'bigtree[all]'
140140
```
141141

142142
### b) Installation with conda
143143

144144
To install `bigtree` with conda, run the following line in command prompt:
145145

146-
```shell
146+
```console
147147
$ conda install -c conda-forge bigtree
148148
```

bigtree/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.15.7"
1+
__version__ = "0.16.0"
22

33
from bigtree.binarytree.construct import list_to_binarytree
44
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag
@@ -75,4 +75,4 @@
7575
from bigtree.workflows.app_calendar import Calendar
7676
from bigtree.workflows.app_todo import AppToDo
7777

78-
sphinx_versions = ["latest", "0.15.7", "0.14.8"]
78+
sphinx_versions = ["latest", "0.16.0", "0.15.7", "0.14.8"]

bigtree/binarytree/construct.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ def list_to_binarytree(
1010
) -> BinaryNode:
1111
"""Construct tree from a list of numbers (int or float) in heapq format.
1212
13-
>>> from bigtree import list_to_binarytree, tree_to_dot
14-
>>> nums_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
15-
>>> root = list_to_binarytree(nums_list)
16-
>>> root.show()
17-
1
18-
├── 2
19-
│ ├── 4
20-
│ │ ├── 8
21-
│ │ └── 9
22-
│ └── 5
23-
│ └── 10
24-
└── 3
25-
├── 6
26-
└── 7
27-
>>> graph = tree_to_dot(root, node_colour="gold")
28-
>>> graph.write_png("assets/construct_binarytree.png")
29-
30-
.. image:: https://github.com/kayjan/bigtree/raw/master/assets/construct_binarytree.png
13+
Examples:
14+
>>> from bigtree import list_to_binarytree, tree_to_dot
15+
>>> nums_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
16+
>>> root = list_to_binarytree(nums_list)
17+
>>> root.show()
18+
1
19+
├── 2
20+
│ ├── 4
21+
│ │ ├── 8
22+
│ │ └── 9
23+
│ └── 5
24+
│ └── 10
25+
└── 3
26+
├── 6
27+
└── 7
28+
>>> graph = tree_to_dot(root, node_colour="gold")
29+
>>> graph.write_png("assets/construct_binarytree.png")
30+
31+
![Sample Binary Tree](https://github.com/kayjan/bigtree/raw/master/assets/construct_binarytree.png)
3132
3233
Args:
3334
heapq_list (List[int]): list containing integer node names, ordered in heapq fashion

bigtree/dag/construct.py

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def list_to_dag(
2121
"""Construct DAG from list of tuples containing parent-child names.
2222
Note that node names must be unique.
2323
24-
>>> from bigtree import list_to_dag, dag_iterator
25-
>>> relations_list = [("a", "c"), ("a", "d"), ("b", "c"), ("c", "d"), ("d", "e")]
26-
>>> dag = list_to_dag(relations_list)
27-
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
28-
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
24+
Examples:
25+
>>> from bigtree import list_to_dag, dag_iterator
26+
>>> relations_list = [("a", "c"), ("a", "d"), ("b", "c"), ("c", "d"), ("d", "e")]
27+
>>> dag = list_to_dag(relations_list)
28+
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
29+
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
2930
3031
Args:
3132
relations (List[Tuple[str, str]]): list containing tuple of parent-child names
@@ -52,17 +53,18 @@ def dict_to_dag(
5253
name, and attribute value.
5354
Note that node names must be unique.
5455
55-
>>> from bigtree import dict_to_dag, dag_iterator
56-
>>> relation_dict = {
57-
... "a": {"step": 1},
58-
... "b": {"step": 1},
59-
... "c": {"parents": ["a", "b"], "step": 2},
60-
... "d": {"parents": ["a", "c"], "step": 2},
61-
... "e": {"parents": ["d"], "step": 3},
62-
... }
63-
>>> dag = dict_to_dag(relation_dict, parent_key="parents")
64-
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
65-
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
56+
Examples:
57+
>>> from bigtree import dict_to_dag, dag_iterator
58+
>>> relation_dict = {
59+
... "a": {"step": 1},
60+
... "b": {"step": 1},
61+
... "c": {"parents": ["a", "b"], "step": 2},
62+
... "d": {"parents": ["a", "c"], "step": 2},
63+
... "e": {"parents": ["d"], "step": 3},
64+
... }
65+
>>> dag = dict_to_dag(relation_dict, parent_key="parents")
66+
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
67+
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
6668
6769
Args:
6870
relation_attrs (Dict[str, Any]): dictionary containing node, node parents, and node attribute information,
@@ -103,27 +105,28 @@ def dataframe_to_dag(
103105
"""Construct DAG from pandas DataFrame.
104106
Note that node names must be unique.
105107
106-
`child_col` and `parent_col` specify columns for child name and parent name to construct DAG.
107-
`attribute_cols` specify columns for node attribute for child name
108-
If columns are not specified, `child_col` takes first column, `parent_col` takes second column, and all other
109-
columns are `attribute_cols`.
110-
111-
>>> import pandas as pd
112-
>>> from bigtree import dataframe_to_dag, dag_iterator
113-
>>> relation_data = pd.DataFrame([
114-
... ["a", None, 1],
115-
... ["b", None, 1],
116-
... ["c", "a", 2],
117-
... ["c", "b", 2],
118-
... ["d", "a", 2],
119-
... ["d", "c", 2],
120-
... ["e", "d", 3],
121-
... ],
122-
... columns=["child", "parent", "step"]
123-
... )
124-
>>> dag = dataframe_to_dag(relation_data)
125-
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
126-
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
108+
- `child_col` and `parent_col` specify columns for child name and parent name to construct DAG.
109+
- `attribute_cols` specify columns for node attribute for child name.
110+
- If columns are not specified, `child_col` takes first column, `parent_col` takes second column, and all other
111+
columns are `attribute_cols`.
112+
113+
Examples:
114+
>>> import pandas as pd
115+
>>> from bigtree import dataframe_to_dag, dag_iterator
116+
>>> relation_data = pd.DataFrame([
117+
... ["a", None, 1],
118+
... ["b", None, 1],
119+
... ["c", "a", 2],
120+
... ["c", "b", 2],
121+
... ["d", "a", 2],
122+
... ["d", "c", 2],
123+
... ["e", "d", 3],
124+
... ],
125+
... columns=["child", "parent", "step"]
126+
... )
127+
>>> dag = dataframe_to_dag(relation_data)
128+
>>> [(parent.node_name, child.node_name) for parent, child in dag_iterator(dag)]
129+
[('a', 'd'), ('c', 'd'), ('d', 'e'), ('a', 'c'), ('b', 'c')]
127130
128131
Args:
129132
data (pd.DataFrame): data containing path and node attribute information

0 commit comments

Comments
 (0)