Skip to content

Bug: Some annotations break API docs

Problem Statement

The API documentation generator is experiencing two primary issues:

  1. The @var annotation in Hazaar\Console\Application.php for class properties is being output as a description (e.g., "@var array<Command>") instead of being parsed as a type declaration.
  2. Errors are being thrown during the parsing and rendering process:
    • Error: Undefined property: Hazaar\Parser\PHP\ParserFunction::$return
    • Error: Array to string conversion

These issues are affecting the correctness of the generated documentation and causing runtime errors.

Steps to Reproduce

  1. Run the API documentation generator on the Hazaar\Console\Application.php file containing class properties annotated with @var and functions with a @return tag.
  2. Observe the generated documentation for the incorrect handling of the @var annotation.
  3. Check the logs or output for the following errors:
    • Error: Undefined property: Hazaar\Parser\PHP\ParserFunction::$return
    • Array to string conversion

Expected Behavior

  • The @var annotation in Hazaar\Console\Application.php should be parsed as a type declaration and appropriately rendered in the documentation.
  • No runtime errors should occur during parsing or rendering.

Actual Behavior

  • The @var annotation in Hazaar\Console\Application.php is incorrectly treated as a property description.
  • Errors are logged during the parsing process:
    • Undefined property: Hazaar\Parser\PHP\ParserFunction::$return
    • Array to string conversion

Benefits and Risks

Benefits

  • Resolving these issues ensures accurate and reliable API documentation generation.
  • Eliminates runtime errors that disrupt the generation process.

Risks

  • Fixing these issues may require changes to the parsing logic, which could impact other aspects of the documentation generator.

Proposed Solution

  1. Update the @var parsing logic to correctly interpret it as a type declaration rather than a description.
  2. Add validation and error handling for the return property in Hazaar\Parser\PHP\ParserFunction to prevent Undefined property errors.
  3. Review and update the handling of data types to resolve the Array to string conversion error.

Priority/Severity

  • High (This will bring a huge increase in performance/productivity/usability/legislative cover)
  • Medium (This will bring a good increase in performance/productivity/usability)
  • Low (anything else e.g., trivial, minor improvements)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information