This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 226038 - Allow custom annotations/tags in comments to be replaced with custom code leaving the rest of the text
Summary: Allow custom annotations/tags in comments to be replaced with custom code lea...
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: PHPDoc (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-12 22:11 UTC by Eccenux
Modified: 2016-09-22 17:49 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eccenux 2013-02-12 22:11:05 UTC
So this is basically about the same thing as in Bug 225979 :-). Currently If I add a custom annotation or write annotation that is not supported the text after the annotation will be removed and the annotation name will be rendered in bold.

What I propose is - render annotation with code (HTML?) given by user and leave the rest of the text alone. This would allow users to have e.g. "@note" replaced with e.g. "<strong>Note:</strong>" and the text after the tag would simply be left alone.

The option could be named "inline annotation" because in fact this would not start another paragraph unless the paragraph tag would be added by user.

Note that HTML would be nice because one could add HTML replacement with colors for example:
"@note" -> "<strong style='color:blue'>Note:</strong>"
"@warning" -> "<strong style='color:red'>Warning!</strong>"
"@attention" -> "<p style='font-weight:bold'><strong style='color:red'>Attention!</strong>"
Comment 1 Eccenux 2013-02-12 22:31:42 UTC
One important thing - treating annotation as inline would effectively allow users to define multiline annotations.

Here's an example
/**
 * Some brief
 * 
 * Some more info
 * 
 * @param string foobar Param info.
 * @noninline Whatever text.
 * @note Please take extra care to do something.
 * Yes this is part of a note to, but let's not bother.
 * @warning Never do something!  
 */

I assume first you take out brief leaving:
brief = "Some brief";
content = 
"Some more info\n\n"
"@param string foobar Param info.\n"
"@noninline Whatever text.\n"
"@note Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"@warning Never do something!"
;

Then do whatever to parse things like params, return leaving:
content = 
"Some more info\n\n"
"@noninline Whatever text.\n"
"@note Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"@warning Never do something!"
;

Let's assume noninline is defined as custom tag and inline is not marked so I assume whole line get's cut out and some postContentStuff is supplemented:
postContentStuff += "<p><b>noninline</b> Whatever text.<p>";
content = 
"Some more info\n\n"
"@note Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"@warning Never do something!"
;

Now let's assume @note is inline custom annotation defined to be replaced with content = 
"<br/><b>Note!</b>", so content would become:
content = 
"Some more info\n\n"
"<br/><b>Note!</b> Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"@warning Never do something!"
;

Now any non defined annotations should be treated as inline replaced with "<b>${name}</b>" becoming:
content = 
"<br/><b>Note!</b>", so content would become:
content = 
"Some more info\n\n"
"<br/><b>Note!</b> Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"<b>warning</b> Never do something!"
;

Then you can add new lines as needed.
Comment 2 Eccenux 2013-02-12 22:35:45 UTC
Something got messed up with last two steps... They should be as below:

Now let's assume @note is inline custom annotation defined to be replaced with "<br/><b>Note!</b>", so content would become:
content = 
"Some more info\n\n"
"<br/><b>Note!</b> Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"@warning Never do something!"
;

Now any non defined annotations should be treated as inline and replaced with "<b>${name}</b>" becoming:
content = 
"Some more info\n\n"
"<br/><b>Note!</b> Please take extra care to do something.\n"
"Yes this is part of a note to, but let's not bother.\n"
"<b>warning</b> Never do something!"
;

Then you can add new lines as needed.