crystal
crystal copied to clipboard
Add `:since-version:` documentation directive
trafficstars
Feature Request
The basic idea would be to document in what version of the library a class, method, or constant was added. Something like:
# Deserializes the given JSON *key* into a `URI`
#
# NOTE: `require "uri/json"` is required to opt-in to this feature.
#
# :since-version: 1.14.0
def self.from_json_object_key?(key : String) : URI?
parse key
rescue URI::Error
nil
end
This would allow for quickly knowing the compatibility of a given method for different Crystal versions. It does require manually adding the directive though, and will require a lot of work to add these to the stdlib, but I think it could be worth it (at least for anything in the past ~5-10 releases).
This would also require more robust comment directive parsing, which may or may not be an issue. It may be worth exploring a standardized format for directives, and having them parsed once instead of having bespoke regexes in several places.