ahmetbarut / laravel-attributes-documentor
此包的最新版本(v1.0.1)没有可用的许可证信息。
v1.0.1
2022-11-14 06:19 UTC
Requires
- illuminate/support: ^8.73.2 || ^9.0.0
- symfony/finder: ^5.4.11 || ^6.0.1
Requires (Dev)
- orchestra/testbench: 6.* || 7.*
- pestphp/pest: ^1.22
This package is auto-updated.
Last update: 2024-09-14 10:19:55 UTC
README
它通过属性提供文档API。
示例
<?php namespace Tests; use AhmetBarut\Documentor\Attributes\Document; #[Document(description: 'TestClass')] class TestClass { #[Document(description: 'testProperty')] public $testProperty; #[Document(description: "testMethod")] public function testMethod() { return; } }
[
"class" => array:1 [
0 => "TestClass"
]
"methods" => array:1 [
"testMethod" => array:1 [
0 => "testMethod"
]
]
"properties" => array:1 [
"testProperty" => array:1 [
0 => "testProperty"
]
]
]
测试
composer test
安装
您可以通过composer安装此包
composer require ahmetbarut/laravel-attributes-documentor
使用
use AhmetBarut\Documentor\FindAttributeDescription; $documentor = new FindAttributeDescription([ ...paths ]); $documentor->find(); $documentor // only class ->getClassAttributeDescription() // only methods ->getMethodsDescription() // only properties ->getPropertiesDescription() // filter null values ->filter()
写入Markdown
use AhmetBarut\Documentor\FindAttributeDescription; use AhmetBarut\Documentor\Templates\Markdown; $documentor = new FindAttributeDescription([ ...paths ]); $documentor->find(); $data = $documentor->getClassAttributeDescription()->getMethodsDescription()->getPropertiesDescription()->filter(); $markdown = new Markdown(); // default path is docs $markdown->write($data);
使用命令
默认情况下,命令将搜索base_path('docs')目录,并将文件名设置为docs.md。
要更改目录;您可以使用--directory=/path/to/dir更改目录。要更改文件名;--output-file=filename
php artisan documentor:generate