| #include <filesystem> | |
| #include <fstream> | |
| #include <iostream> | |
| int main(int argc, char* argv[]) { | |
| if (argc < 2) { | |
| std::cout << "No Doxyfile provided." << std::endl; | |
| exit(1); | |
| } | |
| std::string doxyfile_path{argv[1]}; | |
| std::string out_path{doxyfile_path.substr(0, doxyfile_path.find_last_of("/\\") + 1)}; | |
| std::cout << "Doxyfile path: " << doxyfile_path << std::endl; | |
| std::cout << "Output path: " << out_path << std::endl; | |
| // Create an html directory if it doesn't exist | |
| if (!std::filesystem::exists(out_path + "html")) { | |
| std::filesystem::create_directory(out_path + "html"); | |
| } | |
| // Get the Doxygen version from the environment variable | |
| const char* doxygen_version = std::getenv("DEFAULT_DOXYGEN_VERSION"); | |
| if (!doxygen_version) { | |
| doxygen_version = "unknown"; | |
| } | |
| // Generate a simple HTML file as documentation | |
| std::ofstream file(out_path + "html/index.html"); | |
| file << "<!DOCTYPE html>\n" | |
| "<html>\n" | |
| "<head>\n" | |
| " <title>Self-Documenting Code</title>\n" | |
| "</head>\n" | |
| "<body>\n" | |
| " <h1>Self-Documenting Code Example</h1>\n" | |
| " <p>This C++ program generates its own documentation.</p>\n" | |
| " <p>Doxyfile used: " | |
| << doxyfile_path | |
| << "</p>\n" | |
| " <p>Output directory: " | |
| << out_path | |
| << "</p>\n" | |
| " <p>Generated by a custom executable mimicking Doxygen " | |
| << doxygen_version | |
| << ".</p>\n" | |
| "</body>\n" | |
| "</html>\n"; | |
| file.close(); | |
| std::cout << "Self-documenting code generated: html/index.html" << std::endl; | |
| return 0; | |
| } |