dev-master
9999999-devYii2 Documentaiton Viewer Module
MIT
The Requires
yii2 documentation module wiki
Wallogit.com
2017 © Pedro Peláez
Yii2 Documentaiton Viewer Module
Advanced documentation viewer for Markdown or TXT files:, (*1)
, (*2)
You can install package with a command:, (*3)
composer require webkadabra/yii2-docs-module, (*4)
Assume the following structure of your applicaiton's folders:, (*5)
/backend /docs /user /orders /fulfillment.md /frontend
Where fulfillment.md is your user documentaiton for (example) "Fulfillment operations".
Anyways, add this module to your backend config first:, (*6)
// ...
'modules' => [
// ...
'docs' => [
'class' => 'webkadabra\yii\modules\docs\Module',
],
// ...
],
// ...
Advanced configuration example (e.g. add breadcrumbs):, (*7)
// ...
'modules' => [
// ...
'docs' => [
'class' => 'webkadabra\yii\modules\docs\Module',
'layout' => '/docs',
'on beforeAction' => function ($event) {
/** @var yii\base\ActionEvent $event */
Yii::$app->view->params['breadcrumbs'][] = [
'label' => Yii::t('app', ucfirst($event->sender->id)),
'url' => ['docs/docs/index'],
];
$exs = explode('/', Yii::$app->request->getQueryParam('page'));
$current = array_pop($exs);
$path = [];
foreach ($exs as $ex) {
$path[] = $ex;
Yii::$app->view->params['breadcrumbs'][] = [
'label' => ucwords(str_replace(['/', '_'], ['/', ' '], $ex)),
'url' => rawurldecode(\common\helpers\Url::toRoute(
[
'docs/docs/index',
'page' => implode('/', $path),
]
)),
];
}
Yii::$app->view->params['breadcrumbs'][] = ucwords(str_replace(
['/', '_'],
['/', ' '],
$current
));
},
],
// ...
],
// ...
Add custom rule in urlManager component:, (*8)
// ...
'components' => [
// ...
'urlManager' => [
'rules' => [
'docs/<page:[\w\d\/_-]*>' => 'docs/docs/index',
],
],
],
Now you have your documentaiton available at http://backend.website.test/docs/user/orders/fulfillment, and going up a tree structure would bring index of documents in that directory, e.g.: http://backend.website.test/docs/user/ will bring list of documents in 'docs/user` directory (recursively)., (*9)
Thanks, pull requests are welcome!, (*10)
Yii2 Documentaiton Viewer Module
MIT
yii2 documentation module wiki