Add doctest example for OptionT
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.
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.
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
OptionTclass 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
OptionTalready 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.