cats icon indicating copy to clipboard operation
cats copied to clipboard

Add doctest example for OptionT

Open QueenJcloud opened this issue 2 months ago • 2 comments

This PR introduces doctests for the OptionT data type in cats-core. The doctests serve two purposes:

Documentation enhancement – providing clear, usage-based examples for OptionT methods, helping developers understand common patterns and behaviors.

Test coverage improvement: ensuring that examples in the documentation are verified, reducing the likelihood of outdated or incorrect examples.

Changes:

Added doctests for key OptionT methods, including basic construction, mapping, flatMapping, and combinators.

Ensured examples are simple, concise, and runnable as tests.

Benefits:

Improves developer experience by providing verified, practical examples.

Strengthens test suite coverage indirectly by validating examples in documentation.

QueenJcloud avatar Oct 10 '25 21:10 QueenJcloud

Thanks for your work on this PR! Unfortunately, I think doctests have to be added directly to the documentation for methods. In this case, you added examples to documentation for the OptionT class itself (not its individual methods). As far as I can tell, these have not been rendered as doctests, since I do not see the new tests appearing in the CI log.

I think OptionT already has doctests for most (all?) of its methods, but there are plenty of other datatypes in Cats that still need doctests.

armanbilge avatar Oct 16 '25 02:10 armanbilge

Thanks for your work on this PR! Unfortunately, I think doctests have to be added directly to the documentation for methods. In this case, you added examples to documentation for the OptionT class itself (not its individual methods). As far as I can tell, these have not been rendered as doctests, since I do not see the new tests appearing in the CI log.

I think OptionT already has doctests for most (all?) of its methods, but there are plenty of other datatypes in Cats that still need doctests.

Thank you for the feedback! I understand now that doctests should be added to the method-level documentation rather than the class-level ScalaDoc. I’ll review the existing doctests for OptionT and either update this PR to include method-level examples or open a new PR adding doctests to another datatype that still needs them.

QueenJcloud avatar Oct 16 '25 09:10 QueenJcloud