Added PlantUML links generation in class diagrams
This commit is contained in:
@@ -32,6 +32,19 @@ config load(const std::string &config_file)
|
||||
doc.force_insert(
|
||||
"__parent_path", config_file_path.parent_path().string());
|
||||
|
||||
// If the current directory is also a git repository,
|
||||
// load some config values which can be included in the
|
||||
// generated diagrams
|
||||
if(util::is_git_repository() && !doc["git"]) {
|
||||
YAML::Node git_config{YAML::NodeType::Map};
|
||||
git_config["branch"] = util::get_git_branch();
|
||||
git_config["revision"] = util::get_git_revision();
|
||||
git_config["commit"] = util::get_git_commit();
|
||||
git_config["toplevel"] = util::get_git_toplevel_dir();
|
||||
|
||||
doc["git"] = git_config;
|
||||
}
|
||||
|
||||
return doc.as<config>();
|
||||
}
|
||||
catch (YAML::BadFile &e) {
|
||||
@@ -92,6 +105,7 @@ void inheritable_diagram_options::inherit(
|
||||
puml.override(parent.puml);
|
||||
generate_method_arguments.override(parent.generate_method_arguments);
|
||||
generate_links.override(parent.generate_links);
|
||||
git.override(parent.git);
|
||||
}
|
||||
|
||||
bool diagram::should_include_entities(const std::string &ent)
|
||||
@@ -277,6 +291,7 @@ using clanguml::config::package_diagram;
|
||||
using clanguml::config::plantuml;
|
||||
using clanguml::config::sequence_diagram;
|
||||
using clanguml::config::source_location;
|
||||
using clanguml::config::git_config;
|
||||
|
||||
inline bool has_key(const YAML::Node &n, const std::string &key)
|
||||
{
|
||||
@@ -447,8 +462,33 @@ template <> struct convert<filter> {
|
||||
template <> struct convert<generate_links_config> {
|
||||
static bool decode(const Node &node, generate_links_config &rhs)
|
||||
{
|
||||
if (node["prefix"])
|
||||
rhs.prefix = node["prefix"].as<decltype(rhs.prefix)>();
|
||||
if (node["link"])
|
||||
rhs.link = node["link"].as<decltype(rhs.link)>();
|
||||
|
||||
if (node["tooltip"])
|
||||
rhs.tooltip = node["tooltip"].as<decltype(rhs.tooltip)>();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// git_config Yaml decoder
|
||||
//
|
||||
template <> struct convert<git_config> {
|
||||
static bool decode(const Node &node, git_config &rhs)
|
||||
{
|
||||
if (node["branch"])
|
||||
rhs.branch = node["branch"].as<decltype(rhs.branch)>();
|
||||
|
||||
if (node["revision"])
|
||||
rhs.revision = node["revision"].as<decltype(rhs.revision)>();
|
||||
|
||||
if (node["commit"])
|
||||
rhs.commit = node["commit"].as<decltype(rhs.commit)>();
|
||||
|
||||
if (node["toplevel"])
|
||||
rhs.toplevel = node["toplevel"].as<decltype(rhs.toplevel)>();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -461,6 +501,8 @@ template <typename T> bool decode_diagram(const Node &node, T &rhs)
|
||||
get_option(node, rhs.include);
|
||||
get_option(node, rhs.exclude);
|
||||
get_option(node, rhs.puml);
|
||||
get_option(node, rhs.git);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -479,7 +521,6 @@ template <> struct convert<class_diagram> {
|
||||
get_option(node, rhs.include_relations_also_as_members);
|
||||
get_option(node, rhs.generate_method_arguments);
|
||||
get_option(node, rhs.generate_packages);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -495,7 +536,6 @@ template <> struct convert<sequence_diagram> {
|
||||
return false;
|
||||
|
||||
get_option(node, rhs.start_from);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -511,7 +551,6 @@ template <> struct convert<package_diagram> {
|
||||
return false;
|
||||
|
||||
get_option(node, rhs.layout);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -564,6 +603,7 @@ template <> struct convert<config> {
|
||||
get_option(node, rhs.generate_method_arguments);
|
||||
get_option(node, rhs.generate_packages);
|
||||
get_option(node, rhs.generate_links);
|
||||
get_option(node, rhs.git);
|
||||
|
||||
auto diagrams = node["diagrams"];
|
||||
|
||||
|
||||
@@ -75,7 +75,15 @@ struct layout_hint {
|
||||
using layout_hints = std::map<std::string, std::vector<layout_hint>>;
|
||||
|
||||
struct generate_links_config {
|
||||
std::string prefix;
|
||||
std::string link;
|
||||
std::string tooltip;
|
||||
};
|
||||
|
||||
struct git_config {
|
||||
std::string branch;
|
||||
std::string revision;
|
||||
std::string commit;
|
||||
std::string toplevel;
|
||||
};
|
||||
|
||||
std::string to_string(const diagram_type t);
|
||||
@@ -93,6 +101,7 @@ struct inheritable_diagram_options {
|
||||
"generate_method_arguments", method_arguments::full};
|
||||
option<bool> generate_packages{"generate_packages", false};
|
||||
option<generate_links_config> generate_links{"generate_links"};
|
||||
option<git_config> git{"git"};
|
||||
|
||||
void inherit(const inheritable_diagram_options &parent);
|
||||
};
|
||||
@@ -123,7 +132,6 @@ struct diagram : public inheritable_diagram_options {
|
||||
bool should_include(const common::model::namespace_ &path) const;
|
||||
|
||||
std::string name;
|
||||
private:
|
||||
};
|
||||
|
||||
struct source_location {
|
||||
|
||||
Reference in New Issue
Block a user