Closed PanderMusubi closed 5 years ago
I am looking into this. I plan to add support for templates to solve this and #4 simultaneously.
v0.5 should now support templates. See the readme for an example setting the title and skinparam. Please let me know if that fixes the issue.
The extends results in only the content of the file to be included. The block preamble only results in what is added there. I am missing what normally is added by hpp2plantuml.
As example, please also add
{% block preamble %}
!include default.puml
title The Title
{% endblock %}
In that way, the file to be included is not included literally but via reference.
I don't understand the problem. Here are the steps I use and the corresponding outputs.
virtualenv -p python3 hpp2plantuml/
source hpp2plantuml/bin/activate
For Windows this may look like: hpp2plantuml\Scripts\activate.bat
.
This is to get the example files.
git clone https://github.com/thibaultmarin/hpp2plantuml.git hpp2plantuml-src/
pip install hpp2plantuml
Using the default template, I get the following result (no preamble):
hpp2plantuml -i "hpp2plantuml-src/tests/simple_classes_*.hpp" -o output_1.puml
Result:
@startuml
/' Objects '/
abstract class Class01 {
+{abstract} AbstractPublicMethod(int param) : bool
+PublicMethod(int param) : bool {query}
+{static} StaticPublicMethod(bool param) : bool
#{abstract} _AbstractMethod(int param) : bool
#_ProtectedMethod(int param) : bool
#{static} _StaticProtectedMethod(bool param) : bool
#_protected_var : int
+public_var : int
}
class Class02 {
+AbstractPublicMethod(int param) : bool
-_AbstractMethod(int param) : bool
-_PrivateMethod(int param) : bool
-{static} _StaticPrivateMethod(bool param) : bool
-_private_var : int
}
class Class03 <template<typename T>> {
+Class03()
+~Class03()
-_data : Class01*
-_obj : Class01*
-_typed_obj : T*
-_obj_list : list<Class02>
}
namespace Interface {
class Class04 {
+Class04()
+~Class04()
-_obj : Class01*
-_flag : bool
}
}
namespace Interface {
class Class04_derived {
+Class04_derived()
+~Class04_derived()
-_var : int
}
}
enum Enum01 {
VALUE_0
VALUE_1
VALUE_2
}
/' Inheritance relationships '/
.Class01 <|-- .Class02
namespace Interface {
Class04 <|-- Class04_derived
}
/' Aggregation relationships '/
.Class03 "2" o-- .Class01
.Class03 o-- .Class02
Interface.Class04 o-- .Class01
@enduml
To add a title and skinparam
options, the custom template examples seems to
work for me:
hpp2plantuml -i "hpp2plantuml-src/tests/simple_classes_*.hpp" -o output_2.puml -t hpp2plantuml-src/tests/custom_template.puml
Result:
@startuml
title "This is a title"
skinparam backgroundColor #EEEBDC
skinparam handwritten true
/' Objects '/
abstract class Class01 {
+{abstract} AbstractPublicMethod(int param) : bool
+PublicMethod(int param) : bool {query}
+{static} StaticPublicMethod(bool param) : bool
#{abstract} _AbstractMethod(int param) : bool
#_ProtectedMethod(int param) : bool
#{static} _StaticProtectedMethod(bool param) : bool
#_protected_var : int
+public_var : int
}
class Class02 {
+AbstractPublicMethod(int param) : bool
-_AbstractMethod(int param) : bool
-_PrivateMethod(int param) : bool
-{static} _StaticPrivateMethod(bool param) : bool
-_private_var : int
}
class Class03 <template<typename T>> {
+Class03()
+~Class03()
-_data : Class01*
-_obj : Class01*
-_typed_obj : T*
-_obj_list : list<Class02>
}
namespace Interface {
class Class04 {
+Class04()
+~Class04()
-_obj : Class01*
-_flag : bool
}
}
namespace Interface {
class Class04_derived {
+Class04_derived()
+~Class04_derived()
-_var : int
}
}
enum Enum01 {
VALUE_0
VALUE_1
VALUE_2
}
/' Inheritance relationships '/
.Class01 <|-- .Class02
namespace Interface {
Class04 <|-- Class04_derived
}
/' Aggregation relationships '/
.Class03 "2" o-- .Class01
.Class03 o-- .Class02
Interface.Class04 o-- .Class01
@enduml
If I try to use the template you are proposing, the output does not look good to me:
echo "{% block preamble %}" > custom_include.puml
echo '!'"include default.puml" >> custom_include.puml
echo "title The Title" >> custom_include.puml
echo "{% endblock %}" >> custom_include.puml
hpp2plantuml -i "hpp2plantuml-src/tests/simple_classes_*.hpp" -o output_3.puml -t custom_include.puml
Result:
!include default.puml
title The Title
I think that 4.1 and 4.2 behave as expected. Can you please describe in detail what the problem is (input/output/expected output)?
@PanderMusubi, can this and #4 be closed?
Please, offer an optional argument to add a title.
For example, the option can be called
-t
or--title
and requires a string, possible with escaped spaces or enclosed in two single or two double quotes.The result will be that a line starting with
title
and this string (without escaping of spaces or enclosing quotes) is added to the generated PlantUML file.