Skip to content

Commit

Permalink
feat: add draw_module_tree()
Browse files Browse the repository at this point in the history
  • Loading branch information
doomspec committed Oct 13, 2023
1 parent c3e4071 commit a57fa98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ def buggy_foo():
foo(a=b)
```
## Visualize your codebase
You can put the function `draw_module_tree()` in any of your modules to visualize the tree structure of it. Call it in the `__init__.py` of your package is recommended.


## Installation

You can install Moduler by
Expand Down
15 changes: 14 additions & 1 deletion moduler/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
from moduler import Struct
import plotly.graph_objects as go
import inspect
from moduler.core import build_module_tree

def draw_module_tree():
# Get current module by inspecting the stack
frame = inspect.stack()[1]
module = inspect.getmodule(frame[0])
struct = build_module_tree(module)
draw_treemap(struct)


"""
## Draw treemap
"""

def draw_treemap(struct: Struct):
ids, labels, parents, texts = extract_tree_ingredients(struct)
Expand Down Expand Up @@ -97,7 +111,6 @@ def hypenate_texts(texts: str, line_width=40):


if __name__ == '__main__':
from moduler.core import build_module_tree
import moduler
struct = build_module_tree(moduler)
draw_treemap(struct)

0 comments on commit a57fa98

Please sign in to comment.