PHP - phpDocumentor - ドキュメント自動生成

 クラウディア
1. 概要
2. 試してみるその1
3. 試してみるその2
4. 試してみるその3

1. 概要

 参考サイトによれば phpDocumentor をインストールしていれば、ドキュメントの自動生成ができるようなのです。

2. 試してみるその1


> cd /作業ディレクトリ/
> vendor/bin/phpdoc run
Collecting files .. OK
Initializing parser .. OK
Parsing files

  [Exception]
  No parsable files were found, did you specify any using the -f or -d parameter?

project:run [-t|--target [TARGET]] [--cache-folder [CACHE-FOLDER]] [-f|--filename [FILENAME]] [-d|--directory [DIRECTORY]] [--encoding [ENCODING]] [-e|--extensions [EXTENSIONS]] [-i|--ignore [IGNORE]] [--ignore-tags [IGNORE-TAGS]] [--hidden] [--ignore-symlinks] [-m|--markers [MARKERS]] [--title [TITLE]] [--force] [--validate] [--visibility [VISIBILITY]] [--defaultpackagename [DEFAULTPACKAGENAME]] [--sourcecode] [-p|--progressbar] [--template [TEMPLATE]] [--parseprivate] [--log [LOG]]

 なるほど。  参考サイトと照らし合わせると。  -f でファイルの指定。-d でディレクトリの指定。  -t で出力先を指定するらしい。

3. 試してみるその2

 もともと「PHP Universal Feed Generator」のドキュメントが読みたかったので

> cd /作業ディレクトリ/
> vendor/bin/phpdoc run -d vendor/openpsa
Collecting files .. OK
Initializing parser .. OK
Parsing files
Parsing /home/kitayama/lang/php/rss/vendor/openpsa/universalfeedcreator/lib/Creator/AtomCreator03.php

・・・	略	・・・

Parsing /home/kitayama/lang/php/rss/vendor/openpsa/universalfeedcreator/lib/Creator/AtomCreator10.php
Parsing /home/kitayama/lang/php/rss/vendor/openpsa/universalfeedcreator/test/UniversalFeedCreatorTest.php
Parsing /home/kitayama/lang/php/rss/vendor/openpsa/universalfeedcreator/test/rootfile.php
Storing cache in "/home/kitayama/lang/php/rss/output/build" .. OK
Load cache                                                         ..    0.009s
Preparing template "clean"                                         ..    0.040s
Preparing 17 transformations                                       ..    0.000s
Build "elements" index                                             ..    0.000s
Replace textual FQCNs with object aliases                          ..    0.004s
Resolve @link and @see tags in descriptions                        ..    0.001s
Enriches inline example tags with their sources                    ..    0.000s
Build "packages" index                                             ..    0.007s
Build "namespaces" index and add namespaces to "elements"          ..    0.000s
Collect all markers embedded in tags                               ..    0.000s
Transform analyzed project into artifacts                          ..
Applying 17 transformations
  Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"
  Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig"
  Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"
  Execute transformation using writer "FileIo"

・・・	略	・・・

  Execute transformation using writer "FileIo"
  Execute transformation using writer "twig"

・・・	略	・・・

  Execute transformation using writer "twig"
  Execute transformation using writer "Graph"
Unable to find the `dot` command of the GraphViz package. Is GraphViz correctly installed and present in your path?   1.636s
Analyze results and write report to log                            ..    0.000s
 どうもこれは dot コマンドとして GraphViz が必要と言っている?  前節へ戻って、GraphViz をインストールしなおします。  と。  phpdocumentor/graphviz はインストール済ということがわかりました。  結局のところ、graphviz の本体

/usr/local/bin/dot
 が、必要と言うことですな。  ふふ、インストール済のマシンがあるので。

4. 試してみるその3

 graphviz をインストール済のマシンがあるのでやってみます。  前項はいささか量が多かったのでファイル指定で・・・。

> cd /作業ディレクトリ/
> vendor/bin/phpdoc run -f vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php
Fatal error: Uncaught Error: Call to undefined function JMS\Serializer\simplexml_load_string() in /home/hogehoge/lang/php/rss/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php:63
Stack trace:
#0 /home/hogehoge/lang/php/rss/vendor/jms/serializer/src/JMS/Serializer/Serializer.php(111): JMS\Serializer\XmlDeserializationVisitor->prepare('<?xml version="...')
#1 [internal function]: JMS\Serializer\Serializer->JMS\Serializer\{closure}(Object(JMS\Serializer\XmlDeserializationVisitor))
#2 /home/hogehoge/lang/php/rss/vendor/phpoption/phpoption/src/PhpOption/Some.php(89): call_user_func(Object(Closure), Object(JMS\Serializer\XmlDeserializationVisitor))
#3 /home/hogehoge/lang/php/rss/vendor/jms/serializer/src/JMS/Serializer/Serializer.php(115): PhpOption\Some->map(Object(Closure))
#4 /home/hogehoge/lang/php/rss/vendor/phpdocumentor/phpdocumentor/src/phpDocumentor/Configuration/Loader.php(112): JMS\Serializer\Serializer->deserialize('<?xml version="...', 'phpDocumentor\\C...', 'xml')
#5 /usr/h in /home/hogehoge/lang/php/rss/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php on line 63
 xml のところでこけちょるな。  今度のマシンは php-xml... がインストールされていない・・・。  pkg で以下のものをインストールしてやり直してみます。

> pkg search php72-xml
php72-xml-7.2.10               The xml shared extension for php
php72-xmlreader-7.2.10         The xmlreader shared extension for php
php72-xmlrpc-7.2.10            The xmlrpc shared extension for php
php72-xmlwriter-7.2.10         The xmlwriter shared extension for php
 でもう一回同じ目に合って・・・。よく読んでおけばよかった。

Fatal error: Uncaught Error: Call to undefined function JMS\Serializer\simplexml_load_string() in /home/hogehoge/lang/php/rss/vendor/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php:63

> pkg search php72-simp
php72-simplexml-7.2.10         The simplexml shared extension for php
 php72-simplexml をインストールして再度・・・

> vendor/bin/phpdoc run -f vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php
Collecting files .. OK
Initializing parser .. OK
Parsing files
Parsing /home/hogehoge/lang/php/rss/vendor/openpsa/universalfeedcreator/lib/Element/FeedImage.php
Storing cache in "/home/hogehoge/lang/php/rss/output/build" .. OK
Load cache                                                         ..    0.001s

・・・	略	・・・

Collect all markers embedded in tags                               ..    0.000s
Transform analyzed project into artifacts                          ..
Applying 17 transformations
  Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"
  Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig"
  Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"
  Execute transformation using writer "FileIo"

・・・	略	・・・

  Execute transformation using writer "FileIo"
  Execute transformation using writer "twig"

・・・	略	・・・

  Execute transformation using writer "twig"
  Execute transformation using writer "Graph"
   0.243s
Analyze results and write report to log                            ..    0.000s
 をを、うまくいったのかしら。  デフォルトで カレントディレクトリ/output に作成されるようで

> > ls output/
.  ..  .htaccess  build  classes  css  files  font  graphs  images  index.html  js  namespaces  reports
 で、この index.html を見りゃその中がわかるわけです。
ハイスピードプラン【usus ウズウズ】