rkrug / plantuml

R package to build UML graphs using plantuml
https://rkrug.github.io/plantuml/index.html
GNU General Public License v3.0
76 stars 8 forks source link

Using PlantUML server #26

Closed rkrug closed 1 year ago

rkrug commented 2 years ago

I have implemented in release v0.4.BETA a function to generate the graph, based on PlantUML code, by using a PlantUML server. The function is called plantuml_URL().

I am thinking about making the use of the server the default method of generation, therefore illuminating the need to install PlantUML and to get it to work properly locally.

This would solve most of the issues raised here.

@royratcliffe and @moodymudskipper - could I have your thoughts on this?

Thanks.

royratcliffe commented 2 years ago

That's a great idea Rainer. I like it. Most use cases would have online access to a remote server. Perhaps though it could look first for the local Jar and connect to the server as fallback. That way the user could opt for speed and low-bandwidth by caching the Jar for offline usage.

rkrug commented 2 years ago

That sounds like a good idea. I will think about it's implementation and post updates here.

By the way: which aspects of the package are you actually using: are you converting R classes in diagrams, or are you using it to make UML graphs from your own PlantUML code?

Despite my initial reasoning of this package, I think that the second option is more useful?

rkrug commented 2 years ago

That way the user could opt for speed and low-bandwidth by caching the Jar for offline usage.

Actually, my impression is that the server approach is faster than the local one.

royratcliffe commented 2 years ago

You could be right in general but I had mobile development in mind: laptop on a train over 3G, for example.

rkrug commented 2 years ago

@royratcliffe I am thinking of changing

The reasoning is that the generated sag could be converted to a higher quality png by using this approach.

Would this be problematic in your workflow? Any comments?

royratcliffe commented 2 years ago

Hi Rainer, I find myself doing this kind of thing:

```{plantuml plantuml.format=ifelse(knitr::is_html_output(), "svg", "eps")}
(*) --> "Initialization"

if "Some Test" then
  -->[true] "Some Activity"
  --> "Another activity"
  -right-> (*)
else
  ->[false] "Something else"
  -->[Ending process] (*)
endif
```

The format depending on whether HTML or non-HTML. So I wonder if that approach would work better by default; that is, the default format adjusts to best fit the output's inclusion within the knitted document.

rkrug commented 2 years ago

OK - sounds interesting and useful. Even though it would be a useful behaviour, it would be not in line with the other plot functions and the output they provide in knitting. Nevertheless, I agree that something like this would make sense. I will look if I can put something into the PlantUML options, so that I can select a format, or "auto" which would decide using the knit target.

moodymudskipper commented 2 years ago

Sorry to answer late and thanks for improving this package

eliminating the need to install PlantUML and to get it to work properly locally.

That sounds awesome if there is no strong impact on performance or disk space. But requiring an Internet connection might be surprising to the user for such a task. What are the obstacles to have the package itself take care of the installation? A hybrid approach might try the server and if there is no Internet fall back on local (if installed)

are you converting R classes in diagrams, or are you using it to make UML graphs from your own PlantUML code? I use plantuml for my {flow} package only, and I build plantuml code then draw. Since the package is not on CRAN I had to use workarounds to use it anyway when possible, any change that make it more robust to install and would lead you to push to CRAN would be fantastic.

Re svg : I m not sure if it impacts my use case but just in case, I use plantuml to create different output formats, one of them is html and I was thinking of editing those html files after the fact to insert hyperlinks in the diagrams, would it affect this possibility?

Thanks for the great work

rkrug commented 2 years ago

OK - I have implemented a new PlantUML.format, auto

When using this format, the plantuml.format is set to svg when the output format is html, and pdf otherwise. This also works for doc as output format. It is pushed in the dev branch.

It would be great if you could try it out.

The main changes are in the background, using rsvg for the conversion and sag as the internal format which is than converted to the format requested.

There is also the new function set_method <- function( method = "auto", check_server = TRUE) which sets the method to server when the server is available, otherwise to local.

Most of the functions still need a proper documentation and the tests are not working yet.

Please try it out and let me know if it works.