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
File details
Details for the file codestructure-1.0.0.tar.gz
.
File metadata
- Download URL: codestructure-1.0.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c543cbc15cc6f8094e7022a15b8e07690324aabe743e35d11cd4101d1ba85b18 |
|
MD5 | 8f2cdc7b158137ebdd8c19946958413b |
|
BLAKE2b-256 | 57aeed8c7b50f0147c6ec3ddced34ed3319707fb3514a4bbc502dd1b94e42d05 |
File details
Details for the file codestructure-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: codestructure-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fc597b9513628910716b738b948f4e130e3aa3e43bce18cb4ae385236feccb8 |
|
MD5 | b6dc37c3fd0c3ff9c876b9dc1bb12d95 |
|
BLAKE2b-256 | c36847f59b20bc45a644861ff491fe606a21b4c75f8bc1074139782aa149300c |