开发者

Why dots in PHPDoc cut the rest of the description?

开发者 https://www.devze.com 2023-01-29 05:47 出处:网络
I am trying to write a PHPDoc description and as soon as I type a dot (.) it just cuts the rest of the description开发者_开发知识库 in the code assistant. For example,

I am trying to write a PHPDoc description and as soon as I type a dot (.) it just cuts the rest of the description开发者_开发知识库 in the code assistant. For example,

/**
 * A boolean value indicating whether code assitant worked with dots in PHPDoc.
 * As you can see, it did not work!
 * @var bool
 */
public $var = false;

I only see the first line in the code assistant. How would I solve this problem?


I haven't had any luck using the Short Description and Long Description in Eclipse (Helios) - even though it should be supported.

An option if you want to increase the length of your short description is to use the <br> tag. As long as you don't include a period in your short description, you can span it over multiple lines. You can even use other tags to add a bullet list if you like.

/**
 * Function to take a 10 digit phone number and<br>
 * return it in North American standard format of:<br>
 * <ul><li>(123) 456-7890</li></ul>
 * 
 * @param int $phone <ul><li>up to 10 digit int for the phone number</li></ul>
 * @return string <ul><li>formatted phone number</li></ul>
 */

Eclipse Helios supports most (if not all) of the DocBlock format tags listed on this web page.
phpDocumentor Tutorial: DocBlock Description Details

However, not all these tags work in all instances, and there are definitely examples in other sections of this page that do NOT work. But using these techniques can definitely make your phpDoc blocks look better.


It is likely that the code assistant logic expects that docblock descriptions exist in the "one sentence summary description, followed by a longer detailed description", and most likely only shows the summary description in popups. In Eclipse, you can tab into the code assistant popup, and the information in there expands to show everything (via scrollbars).

UPDATE: Testing KingCrunch's exact layout of (short description to a period, blank like, additional description with/without a period, blank line, tags) in Eclipse PDT on Helios shows that the period in the first sentence does indeed prevent the popup from showing any of the description beyond the period. I even moved the secondary portion onto the same line with the first portion, and everything beyond the period still does not appear. Change it to a comma, and everything up to the next period will then appear. Well, unless there's a blank line between the comma'd line and the next line... in that case, the blank line has the same effect as a period would, blocking everything after it. I see no issue with the tags being seen and interpreted, regardless of whether or not the description pieces are visible.

I believe, therefore, that Eclipse is indeed ignoring all description beyond the first period and/or blank line that it encounters. I'm unaware of a way to disable this behavior.


ashnazg is almost right. Usually there is the "short summary". You have no empty line after that, so it assumes, that the whole block (including the tags) belongs to the summary and are cut down after the first full stop (because its a short summary ;))

Newlines after the short summary and before the tags should work.

/**
 * A boolean value indicating whether code assitant worked with dots in PHPDoc.
 *
 * Should work ;)
 *
 * @var bool
 */
public $var = false;


I've found that you can display multiple sentences if you put an HTML-encoded space character ("&nbsp;") after the period. For example:

/**
 * Sentence One.&nbsp;Sentence Two.
 */

However, if you want to include line breaks in your PHPDoc comment to make it easier to read from the source code, it will only allow up to three lines. If you include any more, only the first line will be displayed. This makes complete sense because you will never ever need more than three lines. For example:

/**
 * Line one.&nbsp;
 * Line two.&nbsp; Another line two sentence.&nbsp;
 * Line three.&nbsp;
 * This fourth line being here will prevent lines 2, 3, and 4, from being displayed.
 */

Thanks for posting this question. I've been wondering if I installed PDE wrong or something.

0

精彩评论

暂无评论...
验证码 换一张
取 消