Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Technical name for long descriptive code block before classes, functions, etc

I know that in PHP (like many other languages) people add descriptive comment blocks with stars before each line before classes, functions and files. Do they have any official name?

/**
* 
* Do these types of bullet-ed block comments have any official name?
* 
*/
like image 910
Jeffrey Cordero Avatar asked Feb 13 '26 11:02

Jeffrey Cordero


2 Answers

This comes from Java's context, called JavaDoc, where you give a paragraph of details, including but not limited to, parameters, return values, etc.

In case of Java...

A documentation comment is framed by slash-star-star and star-slash (i.e. /** ... */). The documentation is in the HTML format.

The HTML format is then rendered by the Eclipse or Netbeans, or other similar IDEs as a tip for the particular function.

The JavaDoc is just the name, but it can be used for any languages.

An example of JavaDoc being using for hinting in Eclipse (code assist) is:

In NetBeans, when the documentation is not found in PHP:

In NetBeans, using PHPDocs:


(source: netbeans.org)

And it displays in NetBeans this way:

like image 55
Praveen Kumar Purushothaman Avatar answered Feb 14 '26 23:02

Praveen Kumar Purushothaman


They're called DocBlocks. For PHP, there's an accepted syntax that was implemented by phpDocumentor

In reality a DocBlock is in fact the name for a combination of a, so-called, DocComment and a block of the PHPDoc Domain Specific Language (DSL). A DocComment is the container that contains documentation that can be formatted according to the PHPDoc Standard.

A DocComment starts with a forward slash and two asterisks (/**), which is similar to how you start a multiline comment but with an additional asterisk, and ends with an asterisk and forward slash (*/). DocComments may be a single line in size but may also span multiple lines, in which case each line must start with an asterisk. It is customary, and recommended, to align the asterisks vertically when spanning multiple lines.

like image 34
Machavity Avatar answered Feb 15 '26 01:02

Machavity