Skip to content

Python system analysis tool, analyzing the inheritance and reference of class objects/functions, and constructing hierarchical diagrams.

License

Notifications You must be signed in to change notification settings

Ind1x1/ClassMap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClassMap 继承关系图

中文说明 🇨🇳

ClassMap is a Python tool based on astroid, used to analyze class inheritance and code references within Python projects. It can:

  • Display the inheritance hierarchy (both parents and subclasses) of a specified class

  • Generate a visualization of class inheritance relationships

  • Find all reference locations of classes or functions within the project

Install

  1. clone:
git clone git@github.com:Ind1x1/ClassMap.git
cd ClassMap
  1. install:
pip install .

Start to use

Find class/function

# Search in the current directory
classmap find MyClass

# Search in the specified directory
classmap find MyClass -d /path/to/project

What this command does:

  • Displays the location of the class definition (if it exists)

  • Displays the class's inheritance hierarchy (if applicable)

  • Generates an inheritance diagram (if applicable)

  • Lists all places where the class is referenced

Output Example

ClassMap
    │
    └── ./classmap/core.py  ── [LINE:9] 

Bases:
Children:
    └── TestMap


References:
    ├── ./classmap/__init__.py
    ├── ./classmap/cli.py
    └── ./classmap/test_map.py


Chained attribute access Call:
    
    TestMap (self.class_map)
        │
        └── ClassMap
    
    TestMap (self.test)
        │
        └── ClassMap
    
    TestMap (self.init())
        │
        └── ClassMap

Note: Using this tool requires Graphviz to be installed. On macOS, you can install it using Homebrew:

brew install graphviz

Under development

Matching based on class name

May have trouble dealing with the following cases:

    class A:
        def __init__(a):
            self.a = a
    class A:
        def __init__(a):
            if a:
                self.a = a
            efif b:
                self.a = b

Supports recursive search of classes

About

Python system analysis tool, analyzing the inheritance and reference of class objects/functions, and constructing hierarchical diagrams.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages