2023-05-03 11:06:20 +02:00
== Why is this an issue?
2023-05-25 14:18:12 +02:00
Try to imagine using a standard library without documentation.
It would be a nightmare, because documentation is the only way to understand of the contract of the API. Documenting an API increases the productivity of the developers consuming it.
2020-06-30 12:47:33 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,php]
2020-06-30 12:47:33 +02:00
----
<?php // Noncompliant; file comment missing
class MyClass // Noncompliant; undocumented
{
$prop; // Noncompliant
/**
* Variable comment.
*/
$prop2; // Noncompliant; variable comment present, but @var tag missing
protected $name, $description; // Noncompliant
function doSomething($param) // Noncompliant
{
// ...
if ($vogons) {
throw new Exception('Help!.');
}
return 42;
}
}
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,php]
2020-06-30 12:47:33 +02:00
----
<?php
/**
* This is a file comment. There is vertical whitespace
* between it and the next element.
*/
/**
* MyClass does something interesting...
*/
class MyClass
{
/**
* Holds the vault combination
* @var string
*/
$prop;
/**
* Variable comment.
* @var number
*/
$prop2;
/**
* @var string $name
* @var string $description
*/
protected $name, $description;
/**
* Calculates the answer to a question
*
* @param string The question
*
* @throws exception If Vogons encountered
*
* @return integer Returns the answer to life, the universe and everything
*/
function doSomething($param) // Noncompliant
{
// ...
if ($vogons) {
throw new Exception('Help!.');
}
return 42;
}
}
----
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
* Add the missing documentation for this (file|class|function|variable).
* Add the missing "@return" tag for this function.
* Add the missing "@throws" tag for this function.
* Add the missing "@param" tag for "XXX".
* Add the missing "@var" tag for this variable.
=== Parameters
.file
****
----
true
----
Require documentation of files
****
.class
****
----
true
----
Require documentation of classes
****
.function
****
----
true
----
Require documentation of functions
****
.throws_tag
****
----
true
----
Require an "@throws" tag where appropriate
****
.return_tag
****
----
true
----
Require an "@return" tag
****
.param_tag
****
----
true
----
Require an "@param" tag for each function parameter
****
.variables
****
----
true
----
Require documentation of variables
****
.var_tag
****
----
true
----
Require that variable documentation contain an "@var" tag
****
2021-09-20 15:38:42 +02:00
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2023-06-22 10:38:01 +02:00
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]