Remove unlinked components

0 votes
asked 2 days ago in Question / help by bflorat (120 points)

Short story :

Is there a way to hide (or even better, remove) unlinked components (like the sequence diagram does) :

remove unlinked

?

Long story :

I only use components diagrams. I found very convenient to use a *.puml with all my project static components (subdivided into sub diagrams) and another puml with dynamic vision and relations between the components.  The dynamic.puml file contains tens of small diagrams, each illustrating a feature and part of the architecture flow and importing only the required sub diagrams (using includesub).

It is pretty cool but with ~50  components, some diagrams becomes too large and clumsy and space is wasted.  It would be perfect for me to show only linked components. For now, I use a workaround : 'remove <individual component> '  but it is more and more unpractical with growing number of components.

Thanks for this great tool and take care ...

1 Answer

0 votes
answered 2 days ago by plantuml (215,660 points)
With last beta, we did something slightly different (basically because the core notion was already there for class diagram).

You can now put "tags" (using $) on components, then remove, hide or restore components either individually or by tags.

http://beta.plantuml.net/plantuml.jar

Here few examples that would help you :

@startuml
component foo1 $tag1
component foo2
component foo3 $tag1
hide $tag1
@enduml

@startuml
component foo1 $tag1
component foo2
component foo3 $tag1
remove $tag1
@enduml

Note that you can put several tags to components:

@startuml
component foo1 $tag1 $corecomponent
component foo2
component foo3 $tag1
remove $tag1
restore $corecomponent
@enduml

As I said, it's not exactly your request.Tell us if it's working for you.

If it's not enough, we will study the "remove unlinked" option.

Take care also...
commented 1 day ago by bflorat (120 points)
Thanks for the quick reply.

The tag feature works and helps but still requires a lot of work and is still error-prone in my case.

Would it be possible to implement a "remove unlinked" feature  for components ? is there some kind of bounty to help you ?
commented 1 day ago by plantuml (215,660 points)

Would it be possible to implement a "remove unlinked" feature  for components ?

Sure, we will : please be patient.

is there some kind of bounty to help you ?

Yes : if you live in an affected area, stay at home.

And write to *all* your contact in US : they are going to live a very bad situation.

http://beta.plantuml.net/covid19.html

commented 1 day ago by bflorat (120 points)
Thanks.

I guess you're right but it's not my choice anymore (I'm french). More and more colleagues are now infected. Anyone should stay at home in the few countries or cities not yet confined, trust us...
commented 1 day ago by plantuml (215,660 points)
With last beta http://beta.plantuml.net/plantuml.jar you can now have :

@startuml
component foo1
component foo2
component foo3
foo1 -- foo2

remove !unlinked

@enduml

We've done very few tests (that is... only one :-)

So they might be issues : please post them here when you'll find them.

Thanks!
commented 1 day ago by bflorat (120 points)

That's insane ! thank you so much.

A bit of feedback tough :

1) I think there is an issue when the number of unlinked items is > 3 (strange issue BTW), check this out :

@startuml

component foo1

component foo2

component foo3

component foo4

component foo5

foo1 -- foo2

remove !unlinked

@enduml

-> all unlinked items are visible again...

2) Why the exclamation mark '!unlinked'  ? Usually, it express negation so we could understand literally that it means to remove *linked* items.

3) If components are folded into packages, they are dropped all together except if we restore the package :

don't work :

@startuml

together a {

component foo1

component foo2

component foo3

}

foo1 -- foo2

remove !unlinked

@enduml

fixed :

@startuml

together a {

component foo1

component foo2

component foo3

}

foo1 -- foo2

remove !unlinked

restore a

@enduml

Thanks a lot.

commented 1 day ago by plantuml (215,660 points)

You're right about point 2).

We have to put some special character somewhere, because "remove unlinked" would mean that you would remove a component which name is "unlinked". Exclamation mark is indeed a very bad choice. So we change it to @ in last beta. But we are open to better suggestions !

http://beta.plantuml.net/plantuml.jar

Point 1 and 3 should be ok... but you can go on with your tests :-)

@startuml
package a {
component foo1
component foo2
component foo3
}
component unlinked
component dummy

foo1 -- foo2
unlinked -- dummy

'Here we remove all components that are unlinked
remove @unlinked

'Here we remove the component which name is "unlinked"
remove unlinked

@enduml
commented 1 day ago by bflorat (120 points)
It's just ... perfect. The result is gorgeous.

It's IMO a major improvement for large diagrams.

Many many thanks !
...