Anvil / bash-doxygen

A doxygen filter for bash scripts
Do What The F*ck You Want To Public License
91 stars 24 forks source link

Warning arguments not present #10

Open wget opened 7 years ago

wget commented 7 years ago
test.sh:20: warning: argument 'delimiter' of command @param is not found in the argument list of hello(delimiter)
test.sh:8: warning: argument 'string' of command @param is not found in the argument list of simple_function(string, delimiter)
test.sh:8: warning: argument 'delimiter' of command @param is not found in the argument list of simple_function(string, delimiter)

Since .sh files are based on the C oxygen parser, this error seems logic, but I was wondering if we could prevent it.

Anvil commented 7 years ago

Well, removing the warning is quite easy (see 13dd6712db6147747060e2775a128dca65329f9f). But (there's always a but), I understand we now have to have a type for each parameter, and I aesthetically don't like that idea.

wget commented 7 years ago

Indeed, this is quite awful. I tested with PHP and indeed since the language is dynamically typed, and even if PHP is officially supported by doxygen, I even have warnings with this language :-/.

<?php

/** \file */

/**
 * Hello world
 * \brief this is a simple hello world
 * \param string the string
 * \param delimiter the delimiter
 */
function helloWorld($string, $delimiter) {
    echo "$string, $delimiter"
}

?>
test.php:6: warning: argument 'string' of command @param is not found in the argument list of helloWorld($string, $delimiter)
test.php:6: warning: argument 'delimiter' of command @param is not found in the argument list of helloWorld($string, $delimiter)
test.php:11: warning: The following parameters of helloWorld($string, $delimiter) are not documented:
  parameter '$string'
  parameter '$delimiter'

The solution would be to specify an invisible type in the regex. Therefore, I tried to use the sed whitespace syntax (\s), but is isn't working. Do you have any idea?

Also, I tried to allow documentation on lines with a shift (one or several 4 tabs or none), I added this feature to the regex, but it seems this isn't taken into account. Do you have any idea about this as well?

example:

## @defgroup Colors Define a color as a variable string

## @{
    ## @addtogroup Colors
    ## @var textBlack
    ## @brief Define text in black
    export textBlack=""

[...]

## @}
Anvil commented 7 years ago

The warnings go away if you do @param $string, and @param $delimiter instead.

Anvil commented 7 years ago

Maybe the solution is to generate pseudo-php instead of pseudo-C. I'll dig into that.