| 46 | } |
| 47 | |
| 48 | int main(int argc, const char* argv[]) |
| 49 | { |
| 50 | auto config = findConfig(argv[1]); |
| 51 | |
| 52 | fmt::print("{}\n====\n", argv[1]); |
| 53 | fmt::print("## {}\n", config.comment()); |
| 54 | fmt::print( |
| 55 | "<!-- This file is automatically generated. Do not edit. -->\n\n"); |
| 56 | |
| 57 | const auto& documentation = config.documentation(); |
| 58 | auto it = documentation.begin(); |
| 59 | if (it != documentation.end()) |
| 60 | { |
| 61 | fmt::print("{}\n", *it++); |
| 62 | |
| 63 | if (!config.is_extension()) |
| 64 | { |
| 65 | fmt::print("## Options\n\n"); |
| 66 | |
| 67 | const OptionGroupProto* formatGroup = nullptr; |
| 68 | if (!config.option().empty() || !config.option_group().empty()) |
| 69 | { |
| 70 | for (const auto& option_group : config.option_group()) |
| 71 | { |
| 72 | auto groupName = option_group.comment(); |
| 73 | if (groupName == "$formats") |
| 74 | { |
| 75 | groupName = "Format variants"; |
| 76 | formatGroup = &option_group; |
| 77 | } |
| 78 | |
| 79 | fmt::print(" - {}:\n", groupName); |
| 80 | for (const auto& option : option_group.option()) |
| 81 | fmt::print(" - `{}`: {}\n", |
| 82 | option.name(), |
| 83 | option.comment()); |
| 84 | } |
| 85 | |
| 86 | for (const auto& option : config.option()) |
| 87 | fmt::print( |
| 88 | " - `{}`: {}\n", option.name(), option.comment()); |
| 89 | } |
| 90 | else |
| 91 | fmt::print("(no options)\n"); |
| 92 | fmt::print("\n"); |
| 93 | |
| 94 | fmt::print("## Examples\n\n"); |
| 95 | |
| 96 | std::vector<std::string> examples; |
| 97 | if (formatGroup) |
| 98 | { |
| 99 | for (const auto& option : formatGroup->option()) |
| 100 | addExample(examples, false, argv[1], config, &option); |
| 101 | } |
| 102 | else |
| 103 | addExample(examples, false, argv[1], config, nullptr); |
| 104 | |
| 105 | if (!examples.empty()) |