4

I'm building documentation for a project written in yii2 using yiisoft/yii2-apidoc (#0.2.4). I have built a shell script to publish the docs and it works fine when I am only including the project files and my own cms codebase which is pulled in via composer.

Here's the code

 #!/bin/sh

VENDOR="../vendor"

# remove existing docs
rm -rf ./frontend/web/docs

# create new docs, by drawing in all prroject code and TiCMS code. exclude the docs themselves.
$VENDOR/yiisoft/yii2-apidoc/apidoc api ./,$VENDOR/toruinteractive/ti-cms ./frontend/web/docs --interactive=0  --exclude="./frontend/web/docs"

So this generates docs with all my code listed...

docs generated showing my classes

But the problem comes when I add the yii framework - which I need in order to show methods and parameters that my code inherits. So the new code with the yii2 framwork added is...

#!/bin/sh

VENDOR="../vendor"

# remove existing docs - this is needed as it sometimes doesn't exclude the docs folder and the output then gets cached.
rm -rf ./frontend/web/docs

# create new docs, by drawing in all prroject code and TiCMS code. exclude the docs themselves.
$VENDOR/yiisoft/yii2-apidoc/apidoc api ./,$VENDOR/toruinteractive/ti-cms,$VENDOR/yiisoft/yii2 ./frontend/web/docs --interactive=0  --exclude="./frontend/web/docs"

This generates documents with ONLY the yii2 code listed - all my classes have gone (see screenshot below). I can't see what I've done wrong here, can anyone help?

when you add yii2 into the mix you only see their classes

Sean Toru
  • 349
  • 2
  • 17

1 Answers1

1

You run into the same problem as described in yiisoft/yii2 #7789 and as the Yii developer replied, the apidoc command is for Yii framework doc by now.

If you still want to use it, you have to exclude the directory where the Yii framework locates. Assuming it is ./vendor/yiisoft, then the exclude option would be

--exclude="./frontend/web/docs,./vendor/yiisoft"

By checking BaseController.php and ApiController.php, you can see that the entire vendor and tests directories are ignored only if exclude option is not supplied. Since you have provided the exclude option, the default exclusion are not used.

If you want to know why including the vendor/yiisoft directory would cause the problem, you need to study details in the apidoc extension, specifically the bootstrap template in your case.

Lacek
  • 1,595
  • 2
  • 11
  • 30