Refactored comment parsing to clang comments

This commit is contained in:
Bartek Kryza
2022-09-18 23:57:02 +02:00
parent e45458de62
commit 920388d84a
31 changed files with 749 additions and 144 deletions

View File

@@ -100,6 +100,7 @@ void inheritable_diagram_options::inherit(
git.override(parent.git);
base_directory.override(parent.base_directory);
relative_to.override(parent.relative_to);
comment_parser.override(parent.comment_parser);
}
std::string inheritable_diagram_options::simplify_template_type(
@@ -284,6 +285,21 @@ void get_option<method_arguments>(
}
}
template <>
void get_option<clanguml::config::comment_parser_t>(const Node &node,
clanguml::config::option<clanguml::config::comment_parser_t> &option)
{
if (node[option.name]) {
const auto &val = node[option.name].as<std::string>();
if (val == "plain")
option.set(clanguml::config::comment_parser_t::plain);
else if (val == "clang")
option.set(clanguml::config::comment_parser_t::clang);
else
throw std::runtime_error("Invalid comment_parser value: " + val);
}
}
std::shared_ptr<clanguml::config::diagram> parse_diagram_config(const Node &d)
{
const auto diagram_type = d["type"].as<std::string>();
@@ -532,6 +548,8 @@ template <typename T> bool decode_diagram(const Node &node, T &rhs)
get_option(node, rhs.puml);
get_option(node, rhs.git);
get_option(node, rhs.generate_links);
get_option(node, rhs.type_aliases);
get_option(node, rhs.comment_parser);
return true;
}
@@ -552,6 +570,7 @@ template <> struct convert<class_diagram> {
get_option(node, rhs.generate_packages);
get_option(node, rhs.relationship_hints);
get_option(node, rhs.type_aliases);
// get_option(node, rhs.comment_parser);
rhs.initialize_relationship_hints();
rhs.initialize_type_aliases();

View File

@@ -37,6 +37,8 @@ namespace config {
enum class method_arguments { full, abbreviated, none };
enum class comment_parser_t { plain, clang };
struct plantuml {
std::vector<std::string> before;
std::vector<std::string> after;
@@ -138,6 +140,8 @@ struct inheritable_diagram_options {
option<bool> generate_system_headers{"generate_system_headers", false};
option<relationship_hints_t> relationship_hints{"relationship_hints"};
option<type_aliases_t> type_aliases{"type_aliases"};
option<comment_parser_t> comment_parser{
"comment_parser", comment_parser_t::plain};
void inherit(const inheritable_diagram_options &parent);