PHP Class Robo\Task\Development\GenerateMarkdownDoc

Takes classes, properties and methods with their docblocks and writes down a markdown file. php taskGenDoc('models.md') ->docClass('Model\User') // take class Model\User ->docClass('Model\Post') // take class Model\Post ->filterMethods(function(\ReflectionMethod $r) { return $r->isPublic() or $r->isProtected(); // process public and protected methods })->processClass(function(\ReflectionClass $r, $text) { return "Class ".$r->getName()."\n\n$text\n\n###Methods\n"; })->run(); By default this task generates a documentation for each public method of a class. It combines method signature with a docblock. Both can be post-processed. php taskGenDoc('models.md') ->docClass('Model\User') ->processClassSignature(false) // false can be passed to not include class signature ->processClassDocBlock(function(\ReflectionClass $r, $text) { return "[This is part of application model]\n" . $text; })->processMethodSignature(function(\ReflectionMethod $r, $text) { return "#### {$r->name}()"; })->processMethodDocBlock(function(\ReflectionMethod $r, $text) { return strpos($r->name, 'save')===0 ? "[Saves to the database]\n" . $text : $text; })->run();
Inheritance: extends Robo\Task\BaseTask, implements Robo\Contract\BuilderAwareInterface, use trait Robo\Common\BuilderAwareTrait
Exibir arquivo Open project: codegyre/robo

Protected Properties

Property Type Description
$append string
$docClass string[]
$filename string
$filterClasses callable
$filterMethods callable
$filterProperties callable
$prepend string
$processClass callable
$processClassDocBlock callable | false
$processClassSignature callable | false
$processMethod callable | false
$processMethodDocBlock callable | false
$processMethodSignature callable | false
$processProperty callable | false
$processPropertyDocBlock callable | false
$processPropertySignature callable | false
$reorder callable
$reorderMethods callable
$reorderProperties callable
$text string
$textForClass string[]

Public Methods

Method Description
__construct ( string $filename )
append ( string $append )
docClass ( string $item )
filename ( string $filename )
filterClasses ( callable $filterClasses )
filterMethods ( callable $filterMethods )
filterProperties ( callable $filterProperties )
indentDoc ( string $doc, integer $indent = 3 ) : string
init ( string $filename ) : static
prepend ( string $prepend )
processClass ( callable $processClass )
processClassDocBlock ( callable | false $processClassDocBlock )
processClassSignature ( callable | false $processClassSignature )
processMethod ( callable | false $processMethod )
processMethodDocBlock ( callable | false $processMethodDocBlock )
processMethodSignature ( callable | false $processMethodSignature )
processProperty ( callable | false $processProperty )
processPropertyDocBlock ( callable | false $processPropertyDocBlock )
processPropertySignature ( callable | false $processPropertySignature )
reorder ( callable $reorder )
reorderMethods ( callable $reorderMethods )
reorderProperties ( callable $reorderProperties )
run ( )
text ( string $text )
textForClass ( string $item )

Protected Methods

Method Description
documentClass ( string $class ) : null | string
documentClassDocBlock ( ReflectionClass $reflectionClass ) : string
documentClassSignature ( ReflectionClass $reflectionClass ) : string
documentMethod ( ReflectionMethod $reflectedMethod ) : string
documentMethodDocBlock ( ReflectionMethod $reflectedMethod ) : string
documentMethodSignature ( ReflectionMethod $reflectedMethod ) : string
documentParam ( ReflectionParameter $param ) : string
documentProperty ( ReflectionProperty $reflectedProperty ) : string
documentPropertyDocBlock ( ReflectionProperty $reflectedProperty ) : string
documentPropertySignature ( ReflectionProperty $reflectedProperty ) : string

Method Details

__construct() public method

public __construct ( string $filename )
$filename string

append() public method

public append ( string $append )
$append string

docClass() public method

public docClass ( string $item )
$item string

documentClass() protected method

protected documentClass ( string $class ) : null | string
$class string
return null | string

documentClassDocBlock() protected method

protected documentClassDocBlock ( ReflectionClass $reflectionClass ) : string
$reflectionClass ReflectionClass
return string

documentClassSignature() protected method

protected documentClassSignature ( ReflectionClass $reflectionClass ) : string
$reflectionClass ReflectionClass
return string

documentMethod() protected method

protected documentMethod ( ReflectionMethod $reflectedMethod ) : string
$reflectedMethod ReflectionMethod
return string

documentMethodDocBlock() protected method

protected documentMethodDocBlock ( ReflectionMethod $reflectedMethod ) : string
$reflectedMethod ReflectionMethod
return string

documentMethodSignature() protected method

protected documentMethodSignature ( ReflectionMethod $reflectedMethod ) : string
$reflectedMethod ReflectionMethod
return string

documentParam() protected method

protected documentParam ( ReflectionParameter $param ) : string
$param ReflectionParameter
return string

documentProperty() protected method

protected documentProperty ( ReflectionProperty $reflectedProperty ) : string
$reflectedProperty ReflectionProperty
return string

documentPropertyDocBlock() protected method

protected documentPropertyDocBlock ( ReflectionProperty $reflectedProperty ) : string
$reflectedProperty ReflectionProperty
return string

documentPropertySignature() protected method

protected documentPropertySignature ( ReflectionProperty $reflectedProperty ) : string
$reflectedProperty ReflectionProperty
return string

filename() public method

public filename ( string $filename )
$filename string

filterClasses() public method

public filterClasses ( callable $filterClasses )
$filterClasses callable

filterMethods() public method

public filterMethods ( callable $filterMethods )
$filterMethods callable

filterProperties() public method

public filterProperties ( callable $filterProperties )
$filterProperties callable

indentDoc() public static method

public static indentDoc ( string $doc, integer $indent = 3 ) : string
$doc string
$indent integer
return string

init() public static method

public static init ( string $filename ) : static
$filename string
return static

prepend() public method

public prepend ( string $prepend )
$prepend string

processClass() public method

public processClass ( callable $processClass )
$processClass callable

processClassDocBlock() public method

public processClassDocBlock ( callable | false $processClassDocBlock )
$processClassDocBlock callable | false

processClassSignature() public method

public processClassSignature ( callable | false $processClassSignature )
$processClassSignature callable | false

processMethod() public method

public processMethod ( callable | false $processMethod )
$processMethod callable | false

processMethodDocBlock() public method

public processMethodDocBlock ( callable | false $processMethodDocBlock )
$processMethodDocBlock callable | false

processMethodSignature() public method

public processMethodSignature ( callable | false $processMethodSignature )
$processMethodSignature callable | false

processProperty() public method

public processProperty ( callable | false $processProperty )
$processProperty callable | false

processPropertyDocBlock() public method

public processPropertyDocBlock ( callable | false $processPropertyDocBlock )
$processPropertyDocBlock callable | false

processPropertySignature() public method

public processPropertySignature ( callable | false $processPropertySignature )
$processPropertySignature callable | false

reorder() public method

public reorder ( callable $reorder )
$reorder callable

reorderMethods() public method

public reorderMethods ( callable $reorderMethods )
$reorderMethods callable

reorderProperties() public method

public reorderProperties ( callable $reorderProperties )
$reorderProperties callable

run() public method

public run ( )

text() public method

public text ( string $text )
$text string

textForClass() public method

public textForClass ( string $item )
$item string

Property Details

$append protected_oe property

protected string $append
return string

$docClass protected_oe property

protected string[] $docClass
return string[]

$filename protected_oe property

protected string $filename
return string

$filterClasses protected_oe property

protected callable $filterClasses
return callable

$filterMethods protected_oe property

protected callable $filterMethods
return callable

$filterProperties protected_oe property

protected callable $filterProperties
return callable

$prepend protected_oe property

protected string $prepend
return string

$processClass protected_oe property

protected callable $processClass
return callable

$processClassDocBlock protected_oe property

protected callable|false $processClassDocBlock
return callable | false

$processClassSignature protected_oe property

protected callable|false $processClassSignature
return callable | false

$processMethod protected_oe property

protected callable|false $processMethod
return callable | false

$processMethodDocBlock protected_oe property

protected callable|false $processMethodDocBlock
return callable | false

$processMethodSignature protected_oe property

protected callable|false $processMethodSignature
return callable | false

$processProperty protected_oe property

protected callable|false $processProperty
return callable | false

$processPropertyDocBlock protected_oe property

protected callable|false $processPropertyDocBlock
return callable | false

$processPropertySignature protected_oe property

protected callable|false $processPropertySignature
return callable | false

$reorder protected_oe property

protected callable $reorder
return callable

$reorderMethods protected_oe property

protected callable $reorderMethods
return callable

$reorderProperties protected_oe property

protected callable $reorderProperties
return callable

$text protected_oe property

protected string $text
return string

$textForClass protected_oe property

protected string[] $textForClass
return string[]