abap-cleaner icon indicating copy to clipboard operation
abap-cleaner copied to clipboard

Feature request: Automatic line-breaks in ABAP Doc

Open ConjuringCoffee opened this issue 2 years ago • 6 comments

Hi Jörg-Michael, I'd like to request a new rule to automatically add line-breaks in ABAP Doc to keep the length of lines to a certain limit, e.g. 120 characters.

As a first step, I think it would be best to move HTML tags to separate lines.

Before:

CLASS lcl_example DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    "! <p class="shorttext synchronized">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore</p>
    METHODS example.
ENDCLASS.

After:

CLASS lcl_example DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    "! <p class="shorttext synchronized">
    "! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
    "! </p>
    METHODS example.
ENDCLASS.

If that is insufficient, then line-breaks should be introduced between words.

Before:

CLASS lcl_example DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    "! <p class="shorttext synchronized">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam</p>
    METHODS example.
ENDCLASS.

After:

CLASS lcl_example DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    "! <p class="shorttext synchronized">
    "! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore 
    "! magna aliqua. Ut enim ad minim veniam
    "! </p>
    METHODS example.
ENDCLASS.

What do you think? 🙂

ConjuringCoffee avatar Nov 07 '23 11:11 ConjuringCoffee

Hi ConjuringCoffee,

good idea! I doubt, however, that your example still fulfils the "60 characters" requirements of a "shorttext" ;-) so there should be an option to keep the real shorttexts on one line to save some vertical space.

At first I wondered if such a rule could destroy intended line breaks in the ABAP Doc …

    "! Lorem ipsum dolor sit amet
    "! 
    "! Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore 
    "! magna aliqua.  

… if it puts everything into a flow text. However, since this is HTML, the result (F2 Documentation) will anyway show a flow text, unless <p>…</p> is properly used:

image

So the cleanup rule would actually help to see that immediately. Or in the above case with an empty line, it could automatically introduce missing <p>…</p> tags.

Kind regards, Jörg-Michael

jmgrassau avatar Nov 09 '23 08:11 jmgrassau

You're right, I shouldn't have made the examples with the shorttext tag. (My example was made in a local class and it looks like there isn't actually a limit for the texts there - I wasn't aware of that! The character limit of 60 only applies to global objects.)

Personally, I put everything in <p> tags, so having the ABAP Cleaner automatically introduce them would be a welcome addition.

ConjuringCoffee avatar Nov 09 '23 10:11 ConjuringCoffee

I actually doubt that there is any place this would be synchronized with from a local class. If only there was a tool with which you could remove this class="shorttext synchronized" attribute in such cases…

jmgrassau avatar Nov 09 '23 10:11 jmgrassau

I actually doubt that there is any place this would be synchronized with from a local class.

There actually is! If you use shorttext synchronized, the text is shown in the outline in ADT. That's why I always use it.

Without:

"! <p>Hello world!</p>
METHODS constructor

image

With:

"! <p class="shorttext synchronized">Hello world!</p>
METHODS constructor

image

ConjuringCoffee avatar Nov 09 '23 10:11 ConjuringCoffee

Ah, excellent, thanks!!

jmgrassau avatar Nov 09 '23 10:11 jmgrassau