English 中文(简体)
What is the purpose of these PHPDOC properties?
原标题:

In general, the PHPDOC properties are self-explanatory, but I m having hard time understanding these:

@category - what is this exactly?

@package - could some one provide me examples about the usage of this property?

最佳回答

The package tag is the key organizing tag that you use in your code. When phpDocumentor generates the docs, it collects elements into the packages that you set. In some cases, you might choose to only use one package name (@package MyPackage) for your entire codebase, such that all files, classes, etc, will appear in that package s docs.

However, if you choose to organize things more modularly, you could have all web-facing procedural files in one package (@package Webpages), all database-facing classes in a package (@package DatabaseHandlers), all utility classes in a package (@package Utilites), and on and on.

The key thing to remember about @package is that it s your avenue for organizing the docs... it has nothing to do with how the code executes. Now, obviously you re more likely to want to organize the docs based on how you conceptually organize the pieces of your app in your head, so that in this sense, "package" would feel like it s organizing the code... But in the end, the package tag is all about how you want phpDocumentor to organize the docs.

As for the category tag, I don t believe any output converters utilize that except the one(s) that matter to the PEAR project. Category is used to collect sets of packages into one large bundle. But again, this is only relevant to PEAR, as far as what capabilities are already baked into the output converters. You can ignore this tag if you want to... you cannot ignore the package tag, because it is core to how phpDocumentor organizes the docs.

Now, as to examples of using @package, there are some in the manual, as seengee already mentioned. Long story short, you need a package tag in the file-level docblock of every file (this is where globally-scoped functions and constants would get their "package" from), and in the docblock of every class. If you don t provide package values for these code elements, phpDocumentor is forced to just dump them all into a "default" package.

Last point... if you don t care about organizing your code into various packages, and don t want to edit all your files to add the @package tags, you can instead use the -dn runtime argument to set a default package name [1]. This tells phpDocumentor to use the package name you provide in that argument for all "unpackaged" code elements that it wants a package name for. There is also a -dc argument to set a default category name, but that s far less critical a need as far as phpDocumentor is concerned.

[1] -- http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.howto.pkg.html#using.command-line.defaultpackagename

(I was including more URLs, but stackoverflow won t let me post more than one...)

问题回答

@category

The @category tag is used to organize groups of packages together.

This is directly applicable to the XML:DocBook/peardoc2 Converter, and can be used by other converters. Other Converters packaged with phpDocumentor ignore the category, but this may change in future versions. It is also possible to dynamically specify category using the -dc, --defaultcategoryname command-line switch

http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.category.pkg.html

@package

@package can only be used to document procedural pages or classes.

Packages are used to help you logically group related elements. You write classes to group related functions and data together, and phpDocumentor represents the contents of files (functions, defines, and includes) as "Procedural Pages." A package is used to group classes and procedural pages together in the same manner that a directory groups related files together.

http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.package.pkg.html





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签