A
A
Alexandr_Vaschenko2016-05-17 13:11:43
PHP
Alexandr_Vaschenko, 2016-05-17 13:11:43

Trouble generating doxygen documentation for PHP script?

Tried using doxygen for php. Overall impressions are positive, everything is simple, beautiful, convenient. But a few nuances emerged. Perhaps my shortcomings are related to the doxygen configuration, or perhaps bugs in doxygen itself. This is exactly the question I want an answer to.
Essence:
There is a test script, and doxygen under, sorry, windows (I also checked it on linux, the result is similar).
PHP:

<?php
  /*! 
   * @file
   * 
   * Скрипт для тестирования Doxygen версии 1.8.11
   * 
   * @date 2016-05-17
   */

  const DSN_SQLITE = 'sqlite:test_sqlite.db'; //!< DSN для SQLite
  
  try {
    $lite_db = new PDO(DSN_SQLITE);
  } catch (PDOExeption $e) {
    echo '!!! Connection to the sqlite failed: '.$e->getMessage();
  }
  
  /*!
   * @brief Тестовая функция 1.
   * 
   * Функция для тестирования вывода ненужной информации в документацию.
   * 
   * @param $arg1 Целочисленное значение.
   * @return Переданное значение увеличенное в 5 раз.
   */
   function tst_func1($arg1) {
     return $arg1 * 5;
   }
   
   $tst1 = tst_func1(5);
   
   if($tst1 == 25) {
     echo "Value tst1 = $tst1\n";
   }
   /*!
    * @brief Тестовая функция 2.
    * 
    * Вторая функция для тестирования вывода другой ненужной информации в документацию.
    * 
    * @param $arg2 Целочисленное значение.
    * @return Пнреданное значение увеличенное на 5.
    */
   function tst_func2($arg2) {
     return $arg2 + 5;
   }
  
?>

Only the basic settings of the doxygen project have been changed, such as the documentation output language, diagrams and the LaTeX format have been disabled. Enabled "C or PHP" optimization (but it didn't help). The rest of the settings are default.
What I really don't like about the screenshot:
f26ad265d3f94c5cb86ef4a76278c084.png
It's not clear why code fragments with blocks after them were added. By the way, if you remove the block brackets after the if condition (leave the condition with a single-line instruction), then the comment for tst_func2 will be completely ignored and there will be no information about this function in the documentation. It's also not clear why the exception syntax, try in particular, is treated as a variable.
Tell me, good people, did I not screw something up or is it still an imperfection of doxygen?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Novikov, 2016-05-17
@BOOMER_74

PHP has its own documentation standard ( PSR-5 ), supported by many utilities (PHPStorm, etc.). To generate documentation, you can use phpDocumentor or phpDox (I liked phpDox, there are some problems with phpDocumentor).

3
300onetwo, 2021-01-22
@300onetwo

In general, in the code itself, surround the if else checks with cond and endcond tags. 600aacc8edb0e438038633.png
Doxygen will ignore the content and only add variables and methods to the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question