Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform camelCase into snake_case for docs #1644

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/contour/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,23 @@ struct DocumentationWriter: Writer
template <typename... T>
std::string process(std::string_view doc, std::string_view name, T... val)
{
return format("### `{}`\n"
"{}\n",
name,
format(replaceCommentPlaceholder(std::string { doc }), val...));
return format(
"### `{}`\n"
"{}\n",
[](std::string_view name) -> std::string {
// camelCase into snake_case
auto result = std::string { name };
for (auto i = 0u; i < result.size(); ++i)
{
if (std::isupper(result[i]))
{
result.insert(i, 1, '_');
result[i + 1] = static_cast<char>(std::tolower(result[i + 1]));
}
}
return result;
}(name),
format(replaceCommentPlaceholder(std::string { doc }), val...));
}

template <typename T, documentation::StringLiteral ConfigDoc, documentation::StringLiteral WebDoc>
Expand Down
Loading