Git Product home page Git Product logo

codeslim's Introduction

CodeSlim

CodeSlim is a library that automatically extracts and refactors code based on required dependencies (Package\Module\File) in a large and nested python project/module/package. It's based on AST(Abstract syntax tree) to optimize your codebase by extracting relevant functions and classes into more modular components, and also simplifying the code structure, making it easier to understand, manage and maintain.

Run the slim file in tests to figue out what CodeSlim can do now.

Introduction

Currently, CodeSlim is under early develepment stage.

The goals of CodeSlim are as following:

  1. Automatically extracting relevant code through some given entries and endpoints, and refactoring the extracted code into certain given structure(file(s), folder(s)).
  2. Simplifying some complex and chained class inherience. Eliminating class inherience relationship.
  3. Fully support user customized strategies(Entry, Endpoint, CodeGen).
  4. Some other insteresting and optional functions, such as inline, function merging...

Core Concepts

Currently, CodeSlim is establish on Entry, Endpoint and CodeGen.

As the name suggests, Entry is the enter point of analysis, all the final extracted code is relevant to entries, such as reference, function call, class inherience and etc.

EndPoint grant CodeSlim the ability to trace or not trace some certain python library files instead of only local files. By default, we only trace local files which are determined by the directory scope of the Entry.

CodeGen is significant to refactor code into target structure.

Analysis of key and difficult points.

The key and difficult points in slim procedure are as following:

  1. Import relationship. (Relative imports/Absolute imports/(Sub)Module inner imports/Import from file/Import from (sub)module/Import all(*))
  2. Function call. (Directly call/Call from Attributes(getitem, getattar)/Chained Call)
  3. Generate proper refactored structure. (Analysis the refactored import relationship)

codeslim's People

Contributors

asthestarsfalll avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.