Non-fully qualified class names, but relative to parent namespace

0 votes
asked Nov 14 in Wanted features by Yenoh (120 points)
retagged 1 hour ago by Yenoh

First of all, thanks for the great tool which makes life easier.

Below is an example of a desired diagram. But what is needed, is the ability to get same diagram without specifying parent namespace name - omit the part in red color.

@startuml
left to right direction
class SameName
namespace WidgetB {
    class SameName

    namespace WidgetC {
        class SameName
    }
    SameName -- WidgetB.WidgetC.SameName
    
    namespace WidgetD {
        class SameName
    }
    SameName -- WidgetB.WidgetD.SameName
}
SameName -- WidgetB.SameName
@enduml

http://www.plantuml.com/plantuml/png/SoWkIImgAStDuUBAIKqhKIZ9LoZAJCyeKKZ9B4fDBidCp-FYIiv9B2vM24xCJVK3OYwkF21PN92OdAeGdfcIdbhYf53DfG04QEh0OkXgdQ5gCTM3XMj195n8GLSNPeKULBiUYdAiLhXGPeKBmefQBYviwX0-T4ZDIm667G00


Why I'm asking about exactly such feature, is because in my actual situation each 'widget' is a standalone diagram described in a separate file (there are more than one element in each and they can be pretty complex).

At a moment of writing a 'widget' diagram it is not known into which other diagrams it will be included in future (parent namespace is not known), please see the list of diagram files below for the full use case example.

When rendering file 'WidgetA' I'd like to have the same result as on the example diagram above, but due to the need to specify also a parent namespace name when linking elements, it does not work so. Following happens instead:

http://www.plantuml.com/plantuml/png/SoWkIImgAStDuSf9JIjHACbNACfCpoXHICaiIaqkoSpFu-9ApaaiBbO8JinDzGDYBguy85bSa9YSgX2UcPAUMkAaKCsb00Hewi1Yw6gTeMenrOE5Qq4aN4X1LnUcJGz56LQZNSWpsWLXT2qN5wQy4qBU8JKl1HXI0000

(As I understand it, the preprocessor turns the diagrams below into the diagram above.)

WidgetA
@startuml
!include common_stuff
class SameName
$add_existing_widget(WidgetB)
SameName -- WidgetB.SameName
@enduml

WidgetB
@startuml
!include common_stuff
class SameName
$add_existing_widget(WidgetC)
SameName -- WidgetC.SameName
$add_existing_widget(WidgetD)
SameName -- WidgetD.SameName
@enduml

WidgetC
@startuml
class SameName
@enduml

WidgetD
@startuml
class SameName
@enduml

common_stuff
@startuml
left to right direction
!unquoted procedure $add_existing_widget($file_name)
    namespace $file_name {
        !include $file_name
    }
!endprocedure
@enduml

(SameName is used everywhere just to emphasize that same names may appear in different diagrams and that's why I'd need the namespaces in the first place.)

commented 13 hours ago by Yenoh (120 points)

I've also thought of using sub-diagrams as a workaround for my case. But PlantUML does not like nested sub-diagrams.

@startuml
left to right direction
class SameName
frame WidgetB [
    {{
        class SameName

        frame WidgetC [
            {{
                class SameName
            }}
        ]
        SameName -- WidgetC
        
        frame WidgetD [
            {{
                class SameName
            }}
        ]
        SameName -- WidgetD
    }}
]
SameName -- WidgetB
@enduml

Here's the error:

http://www.plantuml.com/plantuml/png/SoWkIImgAStDuSf9JIjHACbNACfCpoXHICaiIaqkoSpFuqhEIImkLWXEp4tr0sAkj28WgH2UcPAUMkAa4Csb00JLrK0A0j1KmyMHjJc3j441cdRing18rzR2kR4m5bobWgukp1Au75OtkD333IvSKCMnN9YIJbmEgNafm9070000

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...