CodeStructure is a Python package that analyzes the structure of a Python file and extracts information about its classes, functions, and their associated attributes.
Project description
:building_construction: CodeStructure
CodeStructure is a Python package that analyzes the structure of a Python file and extracts information about its classes, functions, and their associated attributes. It is particularly useful for understanding and documenting complex codebases and writing design docs.
:star: Features
- Extract class and function signatures
- Extract class attributes
- Extract function parameters and their types
- Extract function return types
- Extract decorators and docstrings
- Display the extracted information in a human-readable format
:books: Table of Contents
- :package: Installation
- :book: Usage
- :memo: Example
- :busts_in_silhouette: Contributing
- :page_with_curl: License
:package: Installation
You can install CodeStructure via pip:
pip install codestructure
:book: Usage
To use CodeStructure, simply run the script with the path to the Python file you want to analyze:
codestructure path/to/your/python_file.py
The script will output the analyzed code structure and copy it to the clipboard if the pyperclip
package is installed.
Run the script with the --help
flag to see all available options:
codestructure --help
Which should output:
usage: codestructure [-h] [--no-private] [--no-copy] [--backticks] [--no-rich]
[--line-numbers]
module_file_path
Analyze the code structure of a Python file.
positional arguments:
module_file_path Path to the Python file.
options:
-h, --help show this help message and exit
--no-private Do not print private functions.
--no-copy Do not copy the output to the clipboard.
--backticks Use backticks for code blocks.
--no-rich Do not use rich to print the output.
--line-numbers Print line numbers for the code blocks.
:memo: Example
Given a Python file with the following content:
class MyClass:
my_attr: str
def my_method(self, arg1: int) -> bool:
"""My docstring."""
a = 1 + 1
...
def my_function(arg2: float) -> None:
arg2 = arg2 + 1
...
CodeStructure will output:
class MyClass:
my_attr: str
def my_method(self, arg1: int) -> bool:
"""My docstring."""
def my_function(arg2: float) -> None:
...
:busts_in_silhouette: Contributing
We welcome contributions to CodeStructure! If you find a bug or have a feature request, please create an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.
:page_with_curl: License
CodeStructure is released under the Apache 2.0 License. For more information, please see the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for codestructure-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fc597b9513628910716b738b948f4e130e3aa3e43bce18cb4ae385236feccb8 |
|
MD5 | b6dc37c3fd0c3ff9c876b9dc1bb12d95 |
|
BLAKE2b-256 | c36847f59b20bc45a644861ff491fe606a21b4c75f8bc1074139782aa149300c |