hyvor / laradocs
此包已被废弃且不再维护。未建议替代包。
来自laravel项目的用于快速生成文档的小型库
0.0.1
2022-11-21 14:52 UTC
Requires
- erusev/parsedown-extra: ^0.8.1
Requires (Dev)
- orchestra/testbench: ^6.0
- pestphp/pest: ^1.22
- pestphp/pest-plugin-laravel: ^1.3
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
README
完全可定制的,用于laravel项目快速生成文档的小型库。
安装
使用composer将文档生成器安装到您的laravel项目中。
composer require hyvor/laradocs
使用方法
安装后,您需要使用以下命令发布其资产和配置文件以使其可定制。您可以使用多个数组在配置中定义多个文档。每个数组代表您应用程序特定文档的单独配置。
配置文件中的route
键是Laradocs分配给文档的子域名。没有该子域名路由键,您无法使用应用程序。
theme
键定义了您的主题CSS文件名。默认主题文件是theme.css
。
您的内容文件路径可以在config.php
中的content_directory
处设置为您应用程序的基本路径。默认路径是docs
。
配置中的navigation
键是一个数组,它定义了文档中的导航设计。导航数组中有一个部分数组。section
分隔了导航面板的链接。
在部分内部,有多个导航links
数组,每个链接包含三个键。
id
是必需的,它定义了链接和内容文件的路径。file
是可选的,如果内容文件路径与默认的id
值不同,则指定内容文件路径。label
也是必需的,它建立了页面标题和导航菜单标签。
将资产发布到公共文件夹(*必需)
php artisan vendor:publish --provider="Hyvor\Laradocs\LaradocsServiceProvider" --tag="assets"
资产文件发布是必需的,以便laradocs可以访问它们。
发布配置文件(*必需)
php artisan vendor:publish --provider="Hyvor\Laradocs\LaradocsServiceProvider" --tag="config"
将配置文件发布到您的应用程序目录是必需的。您必须定义其所需字段以使laradocs插件工作。
发布视图文件(可选)
php artisan vendor:publish --provider="Hyvor\Laradocs\LaradocsServiceProvider" --tag="views"
如果您想自定义默认视图结构,则需要将视图发布到应用程序目录。
如何为文档创建自己的主题
laradocs提供了一个选项,让您为文档创建自己的设计。您必须使用配置中的view
值定义视图文件的路径。以下表显示了laradocs后端返回的几个重要动态变量。
变量名称 | 数据类型 | 描述 |
---|---|---|
$content |
mixed | 返回页面的content |
$pageName |
string | 返回页面链接的id 值 |
$label |
string | 返回页面链接的label 值 |
$route |
string | 返回页面的route name |
$nav |
array | 返回文档的navigation 数组 |
在配置文件内部
您可以根据需要更改此文件中的值。
<?php /** * you can have multiple documents as seperate arrays inside return array. **/ return [ [ /** * @required * The subdomain given by Laradocs to the documentation */ 'route' => 'laradocs', /** * @optional * You can define path to your own theme here, laradocs default theme will display if null provided */ 'view' => null, /** * @required * where should we host your content files? path should be set from your application base path. */ 'content_directory' => 'resources/views/docs/laradocs', /** * @required * How is your document navigation should looks like? * It should have section and page links. each page link should have id,lable properties and file property is optional * Id represents link path, label defines title of page while option file field for define custom location for content file of relevant page. * All properties should be string * You can define multiples sections and multiple pages as you want */ 'navigation' => [ 'First Section' => [ [ 'id' => '', //page link url 'file' => 'index', // optional, you can define alternative file path here 'label' => 'Introduction' // page label ], [ 'id' => 'description', 'label' => 'What is laradocs' ], ], 'Second Section' => [ [ 'id' => 'about', 'label' => 'About us' ] ] ] ] ];
许可协议
MIT许可协议(MIT)。请参阅许可文件以获取更多信息。