当前位置:K88软件开发文章中心网站服务器框架Yii 2.0 → 文章内容

TBD 生成 API 文档(Generating API Documentation)

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-26 15:29:45

由  创建, 最后一次修改 2016-02-24 API documentation generator for Yii 2This extension provides an API documentation generator for the?Yii framework 2.0.For license information check the?LICENSE-file.InstallationThe preferred way to install this extension is through?composer.Either runphp composer.phar require --prefer-dist yiisoft/yii2-apidocor add"yiisoft/yii2-apidoc": "~2.0.0"to the require section of your composer.json.UsageThis extension offers two commands:api?to generate class API documentation.guide?to render nice HTML pages from markdown files such as the yii guide.Simple usage for stand alone class documentation:vendor/bin/apidoc api source/directory ./outputSimple usage for stand alone guide documentation:vendor/bin/apidoc guide source/docs ./outputYou can combine them to generate class API and guide documentation in one place:# generate API docsvendor/bin/apidoc api source/directory ./output# generate the guide (order is important to allow the guide to link to the apidoc)vendor/bin/apidoc guide source/docs ./outputBy default the?bootstrap?template will be used. You can choose a different template with the?--template=name?parameter. Currently there is only the?bootstrap?template available.You may also add the?yii\apidoc\commands\ApiController?and?GuideController?to your console application command map and run them inside of your applications console app.Advanced usageThe following script can be used to generate API documentation and guide in different directories and also multiple guides in different languages (like it is done on yiiframework.com):#!/bin/sh# set these paths to match your environmentYII_PATH=~/dev/yiisoft/yii2APIDOC_PATH=~/dev/yiisoft/yii2/extensions/apidocOUTPUT=yii2docscd $APIDOC_PATH./apidoc api $YII_PATH/framework/,$YII_PATH/extensions $OUTPUT/api --guide=../guide-en --guidePrefix= --interactive=0./apidoc guide $YII_PATH/docs/guide $OUTPUT/guide-en --apiDocs=../api --guidePrefix= --interactive=0./apidoc guide $YII_PATH/docs/guide-ru $OUTPUT/guide-ru --apiDocs=../api --guidePrefix= --interactive=0# repeat the last line for more languagesCreating a PDF of the guideYou need?pdflatex?and GNU?make?for this.vendor/bin/apidoc guide source/docs ./output --template=pdfcd ./outputmake pdfIf all runs without errors the PDF will be?guide.pdf?in the?output?dir.Special Markdown SyntaxWe have a special Syntax for linking to classes in the API documentation. See the?code style guide?for details.Creating your own templatesTDBUsing the model layerTDB

TBD 生成 API 文档(Generating API Documentation)