From 368f545f7cd3053f70d00cdc37edf1b4c3d9be14 Mon Sep 17 00:00:00 2001 From: loosiegoosey Date: Sun, 19 May 2024 18:06:46 -0700 Subject: [PATCH] Add comprehensive README --- README.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..bee53ed --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +```markdown +# 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 + ``` + +2. **Setup your environment:** + Ensure you have Python installed. You can check by running: + ```sh + python --version + ``` + +3. **Install dependencies:** + The project does not specify external dependencies beyond the Python standard library, so no additional installation steps are needed. + +## Usage Examples + +### Defining a Macro + +In your code (e.g., a Python or Ruby file), define a macro using the following syntax: + +```python +??defm:hello:python(arg1, arg2){{ +print "puts 'Hello, %s!!!' \n%s" % (arg1, arg2) +}} +``` + +### Calling a Macro + +Use the defined macro within your code as follows: + +```ruby +??hello??'Joe'??'puts "Why, dude?"'?? +``` + +### Running the Expander + +To expand macros within a file or directory, use the command line to run the expander script: + +```sh +python expander.py path/to/your_file_or_directory +``` + +## Code Summary + +### expander.py + +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. + +## Contributing Guidelines + +We welcome contributions to the Expander project. Here’s how you can contribute: + +1. **Fork the repository:** + Click the "Fork" button at the top right corner of the repository page. + +2. **Clone your fork:** + ```sh + git clone https://github.com/your_username/expander.git + cd expander + ``` + +3. **Create a branch:** + ```sh + git checkout -b feature/your_feature + ``` + +4. **Make your changes and commit them:** + ```sh + git add . + git commit -m "Add your feature" + ``` + +5. **Push to your fork:** + ```sh + git push origin feature/your_feature + ``` + +6. **Submit a pull request:** + Go to the original repository and open a pull request describing your changes. + +## License + +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. +``` +