# Expander
## Overview
The Expander project is designed to expand "macros" given a file or directory using a specified language. It provides a mechanism to define and call macros, streamlining repetitive tasks and simplifying complex code interactions across different programming languages.
## Features
- **Multi-language Support:** Define and expand macros in various programming languages.
- **Macro Definition:** Easily create macros with a specified language, name, and arguments.
- **Macro Call:** Invoke macros within your code seamlessly.
- **Directory and File Handling:** Expand macros within an entire directory or a specific file.
- **Efficient Processing:** Utilizes Python subprocess and tempfile modules to handle macro expansion efficiently.
## Installation Instructions
1. **Clone the repository:**
```sh
git clone https://github.com/username/expander.git
cd expander
-
Setup your environment: Ensure you have Python installed. You can check by running:
python --version
-
Install dependencies: The project does not specify external dependencies beyond the Python standard library, so no additional installation steps are needed.
In your code (e.g., a Python or Ruby file), define a macro using the following syntax:
??defm:hello:python(arg1, arg2){{
print "puts 'Hello, %s!!!' \n%s" % (arg1, arg2)
}}
Use the defined macro within your code as follows:
??hello??'Joe'??'puts "Why, dude?"'??
To expand macros within a file or directory, use the command line to run the expander script:
python expander.py path/to/your_file_or_directory
This is the main script for the project. It includes the logic for reading files or directories, parsing macros, expanding them using the specified language, and outputting the results. Key parts of the script include:
- Imports: Standard libraries for file handling, regular expressions, temporary files, and subprocess management.
- Macro Definition Parsing: Regular expressions are used to identify and parse macro definitions and calls.
- Macro Expansion: Processed using Python's
subprocess
module to execute code snippets in the specified language.
This script features constants and utility functions to facilitate macro expansion across different programming environments.
We welcome contributions to the Expander project. Here’s how you can contribute:
-
Fork the repository: Click the "Fork" button at the top right corner of the repository page.
-
Clone your fork:
git clone https://github.com/your_username/expander.git cd expander
-
Create a branch:
git checkout -b feature/your_feature
-
Make your changes and commit them:
git add . git commit -m "Add your feature"
-
Push to your fork:
git push origin feature/your_feature
-
Submit a pull request: Go to the original repository and open a pull request describing your changes.
This project is licensed under the MIT License. See the LICENSE file for more details.