Refactored comment parsing to clang comments
This commit is contained in:
@@ -88,10 +88,7 @@ void decorated_element::append(const decorated_element &de)
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> decorated_element::comment() const
|
||||
{
|
||||
return comment_;
|
||||
}
|
||||
std::optional<comment_t> decorated_element::comment() const { return comment_; }
|
||||
|
||||
void decorated_element::set_comment(const std::string &c) { comment_ = c; }
|
||||
void decorated_element::set_comment(const comment_t &c) { comment_ = c; }
|
||||
}
|
||||
|
||||
@@ -20,14 +20,20 @@
|
||||
#include "enums.h"
|
||||
|
||||
#include "decorators/decorators.h"
|
||||
#include "inja/inja.hpp"
|
||||
|
||||
#include <any>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
using comment_t = inja::json;
|
||||
|
||||
class decorated_element {
|
||||
public:
|
||||
bool skip() const;
|
||||
@@ -46,13 +52,13 @@ public:
|
||||
|
||||
void append(const decorated_element &de);
|
||||
|
||||
std::optional<std::string> comment() const;
|
||||
std::optional<comment_t> comment() const;
|
||||
|
||||
void set_comment(const std::string &c);
|
||||
void set_comment(const comment_t &c);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<decorators::decorator>> decorators_;
|
||||
std::optional<std::string> comment_;
|
||||
std::optional<comment_t> comment_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "decorated_element.h"
|
||||
#include "relationship.h"
|
||||
#include "source_location.h"
|
||||
#include "util/util.h"
|
||||
|
||||
#include <inja/inja.hpp>
|
||||
@@ -30,7 +31,7 @@
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class diagram_element : public decorated_element {
|
||||
class diagram_element : public decorated_element, public source_location {
|
||||
public:
|
||||
using id_t = int64_t;
|
||||
|
||||
|
||||
@@ -44,8 +44,9 @@ inja::json element::context() const
|
||||
ctx["alias"] = alias();
|
||||
ctx["full_name"] = full_name(false);
|
||||
ctx["namespace"] = get_namespace().to_string();
|
||||
if (comment().has_value())
|
||||
if (comment().has_value()) {
|
||||
ctx["comment"] = comment().value();
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class element : public diagram_element, public source_location {
|
||||
class element : public diagram_element {
|
||||
public:
|
||||
element(const namespace_ &using_namespace);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ using filesystem_path = common::model::path<fs_path_sep>;
|
||||
class source_file
|
||||
: public common::model::diagram_element,
|
||||
public common::model::stylable_element,
|
||||
public source_location,
|
||||
public common::model::nested_trait<common::model::source_file,
|
||||
filesystem_path> {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user