Skip to content

EvgenyGavrilov/yii2-rest-doc

 
 

Repository files navigation

#Yii2 Rest documentation builder

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

About

Automatic documentation builder for API based on yii2 rest controllers.

It is working but development version!

Library parses your code and use special phpDoc style comments to generate slate slate source file. So you can automate generation of your yii2 application rest api documentation.

List of data automatically extracted from code:

  • controller name
  • action's list for each controller
  • model fields
  • extra fields (TBD)
  • model rules (TBD)

List of special tags:

  • short and long description of controller
  • query tags

Inheritance is also supported. Use @inherited or @inheritdoc tags.

Rationale

Creating of Yii2 controllers is an easy task, but supporting of documentation in actual state is often boring and tough challenge. Using automatic tool like phpDocumentator or swagger makes life easier but its still require to describe all models fields and rules using tags or comments.

In other hand Yii2 controllers and models keep a lot of information about internal structure like actions,
field names, scenarios for update and insert operations. This package tires to extract this information from rest controllers and models and using this data along with phpdocumentator tags automatically generates index.md for slate or any other documentation file.

Install

  • Add "pahanini/yii2-rest-doc": "*" to required section of your composer.json
  • Add to your console application config
'controllerMap' => [
	'build-rest-doc' => [
		'sourceDirs' => [
			'@frontend\controllers\rest',
		],
		'template' => '//restdoc/restdoc.twig',
		'class' => '\pahanini\restdoc\controllers\BuildController',
		'targetFile' => 'path_to_slate_source',
		'on afterAction' => function() { exec("bundle exec middleman build") }
	],
]

About

Slate index.md generator for yii2 rest controllers.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%