hallvard / plantuml

Embed UML diagrams in files and view them in Eclipse
http://plantuml.sourceforge.net/
209 stars 57 forks source link

Editor and syntax highlight #59

Closed paulvi closed 6 years ago

paulvi commented 6 years ago

with https://marketplace.eclipse.org/content/ascii-uml-asciidoc-editor-plantuml-plugin there is Editor available for users from https://github.com/de-jcup/eclipse-asciidoctor-editor by Albert @de-jcup

The next step would be Editor highlight for keywords like

    actor
    boundary
    control
    entity
    database
    autonumber

and many more

First, do you know a way to get a list of all keywords,
Second, where this support should be done?

arnaudroques commented 6 years ago

There is a way to retrieve keywords (see http://plantuml.com/developers ) : java -jar plantuml.jar -language

paulvi commented 6 years ago

Great, http://plantuml.com/developers gives all needed.

Now waiting for @hallvard and @de-jcup to meet

de-jcup commented 6 years ago

Hello @paulvi , @hallvard .

Support by AsciiDoctorPlantUMLEditor

It's not much effort to support the keywords into my simple plantuml editor approach inside asciidoctor editor: AsciiDoctorPlantUMLEditor Examples:https://github.com/de-jcup/eclipse-asciidoctor-editor/blob/master/asciidoctor-editor-other/testscripts/23_diagrams_by_macro.adoc

I just created https://github.com/hallvard/plantuml/issues/60 to support this.

But NO direct support in AsciiDoctorEditor

Supporting it in normal asciidoc files having embeeded plantuml areas like in example:21_diagrams_plantuml_only.adoc would be too much work because it would be necessary to get the current context while highlighting. Otherwise each text with "class" inside the document would be highlighted....

hallvard commented 6 years ago

If I understand correctly, AsciiDoc is a markup syntax (like markdown, textile etc) for which de-jcup has written en Eclipse editor. It supports embedded plantuml diagrams and shows them within the editor in a split screen. Neat!

I'd be happy to support this, but I'm not sure what help you need. The core plantuml library is already available in its own plugin, so you can depend on it. If you need access to packages that currently aren't exported, that can be fixed. If you need custom API for making it easier to implement the editor (e.g. get hold of the keywords) or generate a diagram and show it in your editor, so there is less duplicate code, that could perhaps be possible.

If the asciidoc editor uses the basic TextEditor, the plantuml view should already show the embedded diagrams (the one the cursor is by). Is there any need for improving this support. I can imaging using the plantuml view's support for diagrams with multiple page for showing all diagrams in an adoc file at once (that could be a general feature, BTW).

Any other suggestions?

de-jcup commented 6 years ago

@hallvard You are right asciidoc is a markup language - like "markdown with steroids" and yes the editor does show up inside eclipse.

In a nutshell

I am able to implement some simple syntax highlighting for plantuml files without much effort. I do not think there should be done more.

A short description whats happening in editors (if interesting)

Only asciidoctor html output shown

The preview panel does only render html output which is done by an embedded AsciidoctorJ integration - which (i am not sure) uses the plantuml library already for rendering etc. I do only show up the parts renderered by asciidoctor in html way - thats all. So my editor just reuses real asciidoctor and does not really do fancy UI things.

Plantuml editor creates only a temporary asciidoc file

My little "plantuml editor" does only extend my asciidoctor editor and automatically wrap up original plantuml files to temporary asciidoc file having an embedded plantuml inside So it is rendered as asciidoc html output and plantuml output shows up. Also some special syntax highlighting in text editor part (which can be easily extended). Thats all.

When an asciidoc file which has already an embedded diagram block like in 21_diagrams_plantuml_only.adoc the plantuml output is also rendered already inside the view by asciidoctor - again no magic.

Those were some "low hanging fruits" to support some plantuml parts inside asciidoc editor. Thats okay. But to implement more than this (except syntax highlighting) is not my intention because the editor is about asciidoc.

hallvard commented 6 years ago

It's a bit similar to the plantuml view, the diagram is rendered by plantuml.jar, which is packaged as a separate plugin with exported packages (classes for rendering). Have you considered integrating with the wikitext (https://wiki.eclipse.org/Mylyn/WikiText)? This is an editor supporting pluggable markup languages, including markdown. Each language provides means for translating to HTML, which is shown in a separate preview tab or materialised as files. It's the natural way of providing asciidoc editing support, rather than a distinct editor. A split pane editor has the advantage of always shown the preview, though.

de-jcup commented 6 years ago

@hallvard Thank you for your thoughts. First of all I am no real fan of Mylyn.... Also Mylyn wiki text asciidoc support is ... just not enough for me. I tried it out and it was one of the reasons why I wrote a dedicated plugin...

The integration I have done with asciidoctor plugin is for asciidoctor only and a little bit "heavy weight" but runs "out-of-the-box". Also its a tool for one purpose: to provide writing asciidoc files as much convenient as possible with a fast preview which is nearly the same as on rendered output by build server.

See also https://github.com/de-jcup/eclipse-asciidoctor-editor/issues/52#issuecomment-393231743

hallvard commented 6 years ago

I don't use Mylyn at all, but use the text markup editors. I agree your custom editor is superior, and seeing the preview all the time is better than switching tabs.

hallvard commented 6 years ago

Do you need API from the plantuml plugin for getting the keywords at runtime, or would you prefer doing without, e.g. to avoid a hard dependency on the plugin.

de-jcup commented 6 years ago

I will just add the keywords from the website to avoid any dependencies. But thank you.