Save functions order in phpdoc

364 views Asked by At

I'm running phpdoc on my project and there's a file (the only meaningful file), in which the order of methods is important for grouping methods. How can I have the same order of functions in the generated documentation as in the source file?

Actually, I'm ready to change doc framework, if it helps.

3

There are 3 answers

2
Daniel W. On

I think it is not possible to declare a specific order.

It is possible to build @packages tho, which is meant for namespaces in PHP (afaik..).

If you have declared a @package, you can define @subpackages to group methods/functions.

<?php
namespace Stackexchange\Stackoverflow;
/**
 * My Answer
 * @package Stackexchange\Stackoverflow
 * @see http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.subpackage.pkg.html
 */

class Answer
{
    /**
     * @subpackage SomeSubGroup
     * @return $this
     */
    public function doSomething {
        return $this;
    }

    /**
     * @subpackage SomeOtherSubGroup
     * @return $this
     */
    public function doSomethingDifferent {
        return $this;
    }
}

Besides the grouping feature, you should try to improve your programing by semantically and logically splitting big classes into smaller, business parts.

1
AudioBubble On

check the below url for steps to document a PHP program,

http://pear.php.net/manual/en/package.php.phpdocumentor.intro.php

1
Marshall Davis On

Unfortunately, it doesn't appear there is a way to tell the documenter what order to list methods in.

However, @see may be useful to you to draw attention to the related functions. That coupled with a note in the full description about the order being needed, or some out of order exceptions may be the best the tool can currently offer.