Skip to content

OS0DEVELOPER/codehint-plusplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeHint++

🧠 A header-only C++ library that automatically adds human-readable comments to your C++ code by analyzing line-by-line logic. Perfect for:

  • Beginners who want help understanding code
  • Teachers generating teaching materials
  • Devs adding quick explanations to legacy code

πŸ”§ Features

  • πŸ“„ Auto-comments basic C++ logic: variables, loops, conditionals, returns
  • βš™οΈ Header-only: just include CodeHint.hpp
  • πŸ§ͺ Simple demo app provided
  • 🧰 Works with any C++17+ project

πŸ“¦ Folder Structure

CodeHintPP/ β”œβ”€β”€ CodeHintLib/ β”‚ └── include/ β”‚ └── CodeHint.hpp # The header-only comment generator β”œβ”€β”€ CodeHintDemo/ β”‚ β”œβ”€β”€ demo.cpp # Sample program using the library β”‚ └── mycode.cpp # Sample input code to be commented β”œβ”€β”€ build/ # Will be created after build β”œβ”€β”€ LICENSE └── README.md

yaml Copy Edit


πŸ› οΈ Installation

πŸ”§ Prerequisites:

  • CMake
  • C++17 compiler (MSVC, g++, or clang++)

πŸ”¨ Build Instructions:

git clone https://github.com/OS0DEVELOPER/CodeHintPP.git
cd CodeHintPP
mkdir build && cd build
cmake ..
cmake --build .
πŸš€ How to Run
Copy your .cpp file into the folder where the executable is:

bash
Copy
Edit
copy CodeHintDemo\mycode.cpp build\CodeHintDemo\Debug\
Run the tool:

bash
Copy
Edit
cd build\CodeHintDemo\Debug
CodeHintDemo.exe
Output:

You’ll get a file named mycode_commented.cpp with inline comments added automatically.

πŸ’‘ Example Output
πŸ”Ή Original: mycode.cpp
cpp
Copy
Edit
int add(int a, int b) {
    int sum = a + b;
    std::cout << sum << std::endl;
    return sum;
}
πŸ”Ή Generated: mycode_commented.cpp
cpp
Copy
Edit
int add(int a, int b) {
    int sum = a + b;
    // Declare and initialize integer

    std::cout << sum << std::endl;
    // Print to console

    return sum;
    // Return the result
}
🧠 How It Works
The CodeHint::commentFunction(std::istream&, std::ostream&) function reads your .cpp file line-by-line.

It uses pattern matching to detect:

Variable declarations

Print statements

Return values

Control structures (in future versions)

And then writes comments directly above each line.

Future versions will support more patterns and even AI-powered explanation generation.

πŸͺͺ License
MIT License
Feel free to use, modify, or contribute. See the LICENSE file.

🀝 Contributing
Fork this repository

Make your changes

Submit a pull request

Ideas welcome for:

Better comment generation logic

A drag-and-drop GUI version

More language support (Python, Java, etc.)

πŸ‘¨β€πŸ’» Author
Om Tirkhunde
πŸ”— GitHub Profile https://github.com/OS0DEVELOPER

About

🧠 A header-only C++ library that adds human-readable comments to your C++ code line by line

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published