Added diagram metadata to PlantUML and JSON generators
This commit is contained in:
@@ -79,5 +79,4 @@ void to_json(nlohmann::json &j, const relationship &c)
|
||||
if (const auto &comment = c.comment(); comment)
|
||||
j["comment"] = comment.value();
|
||||
}
|
||||
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "config/config.h"
|
||||
#include "util/error.h"
|
||||
#include "util/util.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <clang/Basic/Version.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <clang/Tooling/CompilationDatabase.h>
|
||||
#include <clang/Tooling/Tooling.h>
|
||||
@@ -81,6 +83,13 @@ public:
|
||||
*/
|
||||
virtual void generate(std::ostream &ostr) const = 0;
|
||||
|
||||
/**
|
||||
* @brief Generate metadata element with diagram metadata
|
||||
*
|
||||
* @param parent Root JSON object
|
||||
*/
|
||||
void generate_metadata(nlohmann::json &parent) const;
|
||||
|
||||
private:
|
||||
protected:
|
||||
ConfigType &m_config;
|
||||
@@ -95,4 +104,16 @@ std::ostream &operator<<(
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename C, typename D>
|
||||
void generator<C, D>::generate_metadata(nlohmann::json &parent) const
|
||||
{
|
||||
if (m_config.generate_metadata()) {
|
||||
parent["metadata"]["clang_uml_version"] =
|
||||
clanguml::version::CLANG_UML_VERSION;
|
||||
parent["metadata"]["schema_version"] =
|
||||
clanguml::version::CLANG_UML_JSON_GENERATOR_SCHEMA_VERSION;
|
||||
parent["metadata"]["llvm_version"] = clang::getClangFullVersion();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace clanguml::common::generators::json
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "config/config.h"
|
||||
#include "util/error.h"
|
||||
#include "util/util.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <clang/Basic/Version.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <clang/Tooling/CompilationDatabase.h>
|
||||
#include <clang/Tooling/Tooling.h>
|
||||
@@ -110,6 +112,13 @@ public:
|
||||
void generate_notes(
|
||||
std::ostream &ostr, const model::element &element) const;
|
||||
|
||||
/**
|
||||
* @brief Generate comment with diagram metadata
|
||||
*
|
||||
* @param ostr Output stream
|
||||
*/
|
||||
void generate_metadata(std::ostream &ostr) const;
|
||||
|
||||
/**
|
||||
* @brief Generate hyper link to element
|
||||
*
|
||||
@@ -375,6 +384,17 @@ void generator<C, D>::generate_notes(
|
||||
}
|
||||
}
|
||||
|
||||
template <typename C, typename D>
|
||||
void generator<C, D>::generate_metadata(std::ostream &ostr) const
|
||||
{
|
||||
if (m_config.generate_metadata()) {
|
||||
ostr << '\n'
|
||||
<< "'Generated with clang-uml, version "
|
||||
<< clanguml::version::CLANG_UML_VERSION << '\n'
|
||||
<< "'LLVM version " << clang::getClangFullVersion() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename C, typename D>
|
||||
template <typename E>
|
||||
void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
|
||||
|
||||
Reference in New Issue
Block a user