Fixed link generation in include diagrams for include directives
This commit is contained in:
@@ -64,7 +64,7 @@ void translation_unit_visitor::process_include_directive(
|
||||
|
||||
auto include_path = std::filesystem::path(include_directive.full_path());
|
||||
|
||||
// Make sure the include_path is absolute with respect to the
|
||||
// Make sure the file_path is absolute with respect to the
|
||||
// filesystem, and in normal form
|
||||
if (include_path.is_relative()) {
|
||||
include_path = ctx.config().base_directory() / include_path;
|
||||
@@ -103,9 +103,10 @@ void translation_unit_visitor::process_include_directive(
|
||||
ctx.get_current_file().value().add_relationship(
|
||||
relationship{relationship_type, include_file.alias()});
|
||||
|
||||
include_file.set_file(std::filesystem::absolute(include_path)
|
||||
.lexically_normal()
|
||||
.string());
|
||||
include_file.set_file(
|
||||
std::filesystem::absolute(include_directive.full_path())
|
||||
.lexically_normal()
|
||||
.string());
|
||||
include_file.set_line(0);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -48,6 +48,20 @@ TEST_CASE("t40002", "[test-case][package]")
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("lib1.cc"), _A("lib1.h")));
|
||||
REQUIRE_THAT(puml, IsAssociation(_A("lib2.cc"), _A("lib2.h")));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
HasLink(_A("lib1.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib1/lib1.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib1.h"));
|
||||
|
||||
REQUIRE_THAT(puml,
|
||||
HasLink(_A("lib2.h"),
|
||||
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
|
||||
"t40002/include/lib2/lib2.h#L0",
|
||||
clanguml::util::get_git_commit()),
|
||||
"lib2.h"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
}
|
||||
|
||||
@@ -373,6 +373,14 @@ ContainsMatcher HasNote(std::string const &cls, std::string const &position,
|
||||
fmt::format("note {} of {}", position, cls), caseSensitivity));
|
||||
}
|
||||
|
||||
ContainsMatcher HasLink(std::string const &alias, std::string const &link,
|
||||
std::string const &tooltip,
|
||||
CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes)
|
||||
{
|
||||
return ContainsMatcher(CasedString(
|
||||
fmt::format("{} [[{}{{{}}}]]", alias, link, tooltip), caseSensitivity));
|
||||
}
|
||||
|
||||
template <typename... Ts>
|
||||
ContainsMatcher IsMethod(std::string const &name,
|
||||
std::string const &type = "void",
|
||||
|
||||
Reference in New Issue
Block a user