Changed 'start_from' to simply 'from' in sequence diagrams

This commit is contained in:
Bartek Kryza
2023-08-31 23:26:53 +02:00
parent 51e0275db3
commit e830195fb7
40 changed files with 136 additions and 78 deletions

View File

@@ -541,7 +541,8 @@ struct sequence_diagram : public diagram {
common::model::diagram_t type() const override;
option<std::vector<source_location>> start_from{"start_from"};
option<std::vector<source_location>> from{
option_with_alt_names_tag{}, "from", {"start_from"}};
option<std::vector<std::vector<source_location>>> from_to{"from_to"};
option<std::vector<source_location>> to{"to"};
};

View File

@@ -32,6 +32,8 @@ enum class option_inherit_mode {
kAppend /*!< Append to list options */
};
struct option_with_alt_names_tag { };
/**
* @brief Generic configuration option type
*
@@ -62,6 +64,15 @@ template <typename T> struct option {
, inheritance_mode{im}
{
}
option(option_with_alt_names_tag /*unused*/, std::string name_,
std::vector<std::string> alternate_names_,
option_inherit_mode im = option_inherit_mode::kOverride)
: name{std::move(name_)}
, alternate_names{std::move(alternate_names_)}
, value{}
, inheritance_mode{im}
{
}
/**
* @brief Set the option value
@@ -107,6 +118,9 @@ template <typename T> struct option {
/*! Option name, it is also the YAML key in the configuration file */
std::string name;
/*! Alternate option names */
std::vector<std::string> alternate_names;
/*! Option value */
T value;

View File

@@ -194,7 +194,8 @@ types:
generate_return_types: !optional bool
generate_condition_statements: !optional bool
participants_order: !optional [string]
start_from: !optional [source_location_t]
start_from: !optional [source_location_t] # deprecated -> 'from'
from: !optional [source_location_t]
from_to: !optional [[source_location_t]]
to: !optional [source_location_t]
package_diagram_t:

View File

@@ -65,6 +65,12 @@ void get_option(const Node &node, clanguml::config::option<T> &option)
{
if (node[option.name])
option.set(node[option.name].template as<T>());
for (const auto &alt_name : option.alternate_names)
if (node[alt_name]) {
option.set(node[alt_name].template as<T>());
break;
}
}
template <>
@@ -573,7 +579,7 @@ template <> struct convert<sequence_diagram> {
if (!decode_diagram(node, rhs))
return false;
get_option(node, rhs.start_from);
get_option(node, rhs.from);
get_option(node, rhs.from_to);
get_option(node, rhs.to);
get_option(node, rhs.combine_free_functions_into_file_participants);

View File

@@ -347,7 +347,7 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const sequence_diagram &c)
{
out << YAML::BeginMap;
out << YAML::Key << "type" << YAML::Value << c.type();
out << c.start_from;
out << c.from;
out << c.from_to;
out << c.to;
out << dynamic_cast<const inheritable_diagram_options &>(c);