Refactored comment parsing to clang comments
This commit is contained in:
@@ -5,6 +5,7 @@ diagrams:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00002/t00002.cc
|
||||
comment_parser: clang
|
||||
using_namespace:
|
||||
- clanguml::t00002
|
||||
include:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace clanguml {
|
||||
namespace t00002 {
|
||||
|
||||
/// This is class A
|
||||
/// \brief This is class A
|
||||
class A {
|
||||
public:
|
||||
/// Abstract foo_a
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
virtual void foo_c() = 0;
|
||||
};
|
||||
|
||||
/// This is class B
|
||||
/// \brief This is class B
|
||||
class B : public A {
|
||||
public:
|
||||
virtual void foo_a() override { }
|
||||
|
||||
@@ -5,6 +5,7 @@ diagrams:
|
||||
type: class
|
||||
glob:
|
||||
- ../../tests/t00050/t00050.cc
|
||||
comment_parser: clang
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t00050
|
||||
@@ -12,32 +13,49 @@ diagrams:
|
||||
plantuml:
|
||||
after:
|
||||
- >
|
||||
note left of {{ alias("A") }}
|
||||
{{ comment("clanguml::t00050::A") }}
|
||||
note left of {{ alias("A") }}
|
||||
{{ comment("clanguml::t00050::A").formatted }}
|
||||
end note
|
||||
|
||||
- >
|
||||
note right of {{ element("clanguml::t00050::A").alias }}
|
||||
{{ element("A").comment }}
|
||||
{% set e=element("clanguml::t00050::A") %} {{ e.comment.formatted }}
|
||||
end note
|
||||
- >
|
||||
note left of {{ alias("C") }} #AABBCC
|
||||
{{ trim(comment("clanguml::t00050::C").text) }}
|
||||
end note
|
||||
|
||||
- >
|
||||
{% for element in diagram.elements %}
|
||||
{% if element.type == "class" and existsIn(element, "comment") %}
|
||||
|
||||
note top of {{ element.alias }}
|
||||
{{ element.comment }}
|
||||
{# Render brief comments and todos, if any were written for an element #}
|
||||
{% for e in diagram.elements %}
|
||||
{% if existsIn(e, "comment") and existsIn(e.comment, "brief") %}
|
||||
|
||||
note top of {{ e.alias }} {% if e.type == "class" %} #22AA22 {% else %} #2222AA {% endif %}
|
||||
{% set c=e.comment %} {{ c.brief.0 }}
|
||||
end note
|
||||
|
||||
{% endif %}
|
||||
{% if existsIn(e, "comment") and existsIn(e.comment, "todo") %}
|
||||
{% set c=e.comment %}
|
||||
{% for t in c.todo %}
|
||||
note top of {{ e.alias }} #882222
|
||||
**TODO**
|
||||
{{ t }}
|
||||
end note
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{# Render template paramete if any #}
|
||||
{% if existsIn(e, "comment") and existsIn(e.comment, "tparam") %}
|
||||
{% set c=e.comment %}
|
||||
|
||||
note top of {{ e.alias }} #AAAAFF
|
||||
**Template parameters**
|
||||
{% for tp in c.tparam %}
|
||||
//{{ tp.name }}// {{ trim(tp.description) }}
|
||||
{% endfor %}
|
||||
end note
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
- >
|
||||
{% for element in diagram.elements %}
|
||||
{% if element.type == "enum" and existsIn(element, "comment") %}
|
||||
|
||||
note bottom of {{ element.alias }}
|
||||
{{ element.comment }}
|
||||
end note
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -11,15 +11,23 @@ class A {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Lorem ipsum
|
||||
*
|
||||
* Lorem ipsum dolor sit amet consectetur adipiscing elit, urna consequat felis
|
||||
* vehicula class ultricies mollis dictumst, aenean non a in donec nulla.
|
||||
* Phasellus ante pellentesque erat cum risus consequat imperdiet aliquam,
|
||||
* integer placerat et turpis mi eros nec lobortis taciti, vehicula nisl litora
|
||||
* tellus ligula porttitor metus.
|
||||
*
|
||||
* \todo 1. Write meaningful comment
|
||||
* \todo 2. Write tests
|
||||
* \todo 3. Implement
|
||||
*/
|
||||
class B {
|
||||
};
|
||||
|
||||
/// \brief Long comment example
|
||||
///
|
||||
/// Lorem ipsum dolor sit amet consectetur adipiscing elit, urna consequat felis
|
||||
/// vehicula class ultricies mollis dictumst, aenean non a in donec nulla.
|
||||
/// Phasellus ante pellentesque erat cum risus consequat imperdiet aliquam,
|
||||
@@ -56,6 +64,8 @@ namespace utils {
|
||||
/// Phasellus ante pellentesque erat cum risus consequat imperdiet aliquam,
|
||||
/// integer placerat et turpis mi eros nec lobortis taciti, vehicula nisl litora
|
||||
/// tellus ligula porttitor metus.
|
||||
///
|
||||
/// \todo Implement...
|
||||
class D {
|
||||
};
|
||||
|
||||
@@ -64,6 +74,20 @@ class D {
|
||||
/// Mollis pretium lorem primis
|
||||
enum class E { E1, E2, E3 };
|
||||
|
||||
/// \brief Simple array wrapper.
|
||||
///
|
||||
/// This class is just for testing tparam parsing, it serves no other
|
||||
/// purpose.
|
||||
///
|
||||
/// \tparam T Type of array elements.
|
||||
/// \tparam V Type of regular element.
|
||||
/// \tparam N Size of T array.
|
||||
///
|
||||
template <typename T, typename V, int N> class F {
|
||||
T t[N];
|
||||
V v;
|
||||
};
|
||||
|
||||
class NoComment {
|
||||
};
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ TEST_CASE("t00050", "[test-case][class]")
|
||||
REQUIRE_THAT(puml, IsEnum(_A("E")));
|
||||
|
||||
REQUIRE_THAT(puml, HasNote(_A("A"), "left"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("A"), "top"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("A"), "right"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("B"), "top"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("C"), "top"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("utils::D"), "top"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("E"), "bottom"));
|
||||
REQUIRE_THAT(puml, !HasNote(_A("E"), "bottom"));
|
||||
REQUIRE_THAT(puml, !HasNote(_A("NoComment"), "top"));
|
||||
REQUIRE_THAT(puml, HasNote(_A("F<T,V,int N>"), "top"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory() + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
@@ -25,7 +25,7 @@ void inject_diagram_options(std::shared_ptr<clanguml::config::diagram> diagram)
|
||||
// Inject links config to all test cases
|
||||
clanguml::config::generate_links_config links_config{
|
||||
R"(https://github.com/bkryza/clang-uml/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }})",
|
||||
R"({% if "comment" in element %}{{ abbrv(trim(replace(element.comment, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %})"};
|
||||
R"({% if existsIn(element, "comment") and existsIn(element.comment, "brief") %}{{ abbrv(trim(replace(element.comment.brief.0, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %})"};
|
||||
|
||||
diagram->generate_links.set(links_config);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ TEST_CASE("Test config simple", "[unit-test]")
|
||||
"element.source.file }}#L{{ element.source.line }}");
|
||||
CHECK(diagram.generate_links().tooltip == "{{ element.comment }}");
|
||||
|
||||
CHECK(
|
||||
diagram.comment_parser() == clanguml::config::comment_parser_t::clang);
|
||||
|
||||
CHECK(contains(diagram.include().access, access_t::kPublic));
|
||||
CHECK(contains(diagram.include().access, access_t::kProtected));
|
||||
CHECK(contains(diagram.include().access, access_t::kPrivate));
|
||||
|
||||
@@ -7,6 +7,7 @@ diagrams:
|
||||
glob:
|
||||
- src/**/*.cc
|
||||
- src/**/*.h
|
||||
comment_parser: clang
|
||||
using_namespace: clanguml
|
||||
generate_method_arguments: full
|
||||
generate_packages: true
|
||||
|
||||
Reference in New Issue
Block a user