Added include diagram hyperlink generation
This commit is contained in:
@@ -64,7 +64,8 @@ public:
|
|||||||
void generate_notes(
|
void generate_notes(
|
||||||
std::ostream &ostr, const model::element &element) const;
|
std::ostream &ostr, const model::element &element) const;
|
||||||
|
|
||||||
void generate_link(std::ostream &ostr, const model::element &e) const;
|
template <typename E>
|
||||||
|
void generate_link(std::ostream &ostr, const E &e) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const inja::json &context() const;
|
const inja::json &context() const;
|
||||||
@@ -114,9 +115,9 @@ inja::json generator<C, D>::element_context(const E &e) const
|
|||||||
|
|
||||||
if (!e.file().empty()) {
|
if (!e.file().empty()) {
|
||||||
std::filesystem::path file{e.file()};
|
std::filesystem::path file{e.file()};
|
||||||
std::string relative_path = std::filesystem::relative(file);
|
std::string relative_path = file.string();
|
||||||
|
|
||||||
if (ctx.template contains("git"))
|
if (file.is_absolute() && ctx.template contains("git"))
|
||||||
relative_path =
|
relative_path =
|
||||||
std::filesystem::relative(file, ctx["git"]["toplevel"]);
|
std::filesystem::relative(file, ctx["git"]["toplevel"]);
|
||||||
|
|
||||||
@@ -200,8 +201,8 @@ void generator<C, D>::generate_notes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename C, typename D>
|
template <typename C, typename D>
|
||||||
void generator<C, D>::generate_link(
|
template <typename E>
|
||||||
std::ostream &ostr, const model::element &e) const
|
void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
|
||||||
{
|
{
|
||||||
if (e.file().empty())
|
if (e.file().empty())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -73,6 +73,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
namespace_ ns_;
|
namespace_ ns_;
|
||||||
namespace_ using_namespace_;
|
namespace_ using_namespace_;
|
||||||
// type_safe::optional<source_location> location_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "common/model/diagram_element.h"
|
#include "common/model/diagram_element.h"
|
||||||
#include "common/model/nested_trait.h"
|
#include "common/model/nested_trait.h"
|
||||||
#include "common/model/path.h"
|
#include "common/model/path.h"
|
||||||
|
#include "common/model/source_location.h"
|
||||||
#include "common/model/stylable_element.h"
|
#include "common/model/stylable_element.h"
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@ using filesystem_path = common::model::path<fs_path_sep>;
|
|||||||
class source_file
|
class source_file
|
||||||
: public common::model::diagram_element,
|
: public common::model::diagram_element,
|
||||||
public common::model::stylable_element,
|
public common::model::stylable_element,
|
||||||
|
public source_location,
|
||||||
public common::model::nested_trait<common::model::source_file,
|
public common::model::nested_trait<common::model::source_file,
|
||||||
filesystem_path> {
|
filesystem_path> {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* src/package_diagram/generators/plantuml/package_diagram_generator.cc
|
* src/include_diagram/generators/plantuml/include_diagram_generator.cc
|
||||||
*
|
*
|
||||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -57,14 +57,21 @@ void generator::generate(const source_file &f, std::ostream &ostr) const
|
|||||||
|
|
||||||
if (f.type() == common::model::source_file_t::kDirectory) {
|
if (f.type() == common::model::source_file_t::kDirectory) {
|
||||||
ostr << "folder " << f.name();
|
ostr << "folder " << f.name();
|
||||||
ostr << " as " << f.alias() << " {\n";
|
ostr << " as " << f.alias();
|
||||||
|
ostr << " {\n";
|
||||||
for (const auto &file : f) {
|
for (const auto &file : f) {
|
||||||
generate(dynamic_cast<const source_file &>(*file), ostr);
|
generate(dynamic_cast<const source_file &>(*file), ostr);
|
||||||
}
|
}
|
||||||
ostr << "}" << '\n';
|
ostr << "}" << '\n';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ostr << "file " << f.name() << " as " << f.alias() << '\n';
|
ostr << "file " << f.name() << " as " << f.alias();
|
||||||
|
|
||||||
|
if (m_config.generate_links) {
|
||||||
|
generate_link(ostr, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
ostr << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ void translation_unit_visitor::process_file(const std::string &file,
|
|||||||
|
|
||||||
include_path = include_path.lexically_normal();
|
include_path = include_path.lexically_normal();
|
||||||
|
|
||||||
|
std::string full_file_path = include_path;
|
||||||
auto f_abs = std::make_unique<common::model::source_file>();
|
auto f_abs = std::make_unique<common::model::source_file>();
|
||||||
|
|
||||||
if (include_path.is_absolute())
|
if (include_path.is_absolute())
|
||||||
@@ -138,6 +139,10 @@ void translation_unit_visitor::process_file(const std::string &file,
|
|||||||
|
|
||||||
ctx.get_current_file().value().add_relationship(
|
ctx.get_current_file().value().add_relationship(
|
||||||
common::model::relationship{relationship_type, f->alias()});
|
common::model::relationship{relationship_type, f->alias()});
|
||||||
|
|
||||||
|
auto fp = std::filesystem::absolute(file).lexically_normal();
|
||||||
|
f->set_file(fp.string());
|
||||||
|
f->set_line(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx.diagram().get_element(f->path() | f->name()).has_value()) {
|
if (!ctx.diagram().get_element(f->path() | f->name()).has_value()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user