All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
nilcan be used as an alias forNilClassin more places in YARD types. (Thanks @apiology)- The Solargraph convention
undefinedcan now be used as an "untyped" type. (Thanks @apiology)
- If a constant's value does not parse successfully, type information can still be generated for that constant, and Sord emits a warning. Previously, this would cause a fatal exception.
- The version restriction on the RBS gem has been relaxed, to permit usage of 4.x versions. RBS 3.x can still be used as before. (Thanks @apiology)
- Sord now correctly resolves namespaces when classes have a namespace, e.g.
class X::Y. (Thanks @dorner)
- Messages now show the file and line number that the message originated from. (Thanks @apiology)
- Sord will now recognise
Class<T, E>as an equivalent ofClass<T>, Class<E>, similar to the existing behaviour forArray. (Thanks @tomoasleep)
- Breaking change: Now uses Commander 5.0 to support Ruby 3.3. This increases the minimum required Ruby version to 3.0.
- Breaking change: Parlour version has been bumped significantly, from 5.0 to 9.1. This may be relevant if you're using other Parlour plugins alongside Sord.
- Sord now generates correct RBI when heredoc strings are used in constants. (Thanks @apiology)
- Fixed error when using as a Parlour plugin, but without any custom tags defined. (Thanks @dsisnero)
- Fixed incorrect precedence when union types were nested inside hashes. (Thanks @apiology)
- Sord now adds
::when required, to disambiguate nested namespaces from top-level ones. (Thanks @sinsoku)
- Breaking change: Now targets RBS 3.0
- Add support for a single
@overloadtag, typically used to describe methods defined outside of Ruby. Thanks @ohai!
- Use
File#exist?instead ofFile#exists?, for Ruby 3.2 support. Thanks @matmorel!
- If a derived class does not provide tags for a method, but it is overridden from a base class which does, then the base class' documentation will be used to generate types for the derived method.
- When generating RBS, if a duck type matches one of RBS' built-in interfaces, this type will be
generated instead. (For example,
#to_swill generate the type_ToS.) - Added the
--hide-privateflag, which will omit outputting items with private visibility. - To improve resolution, types for gems are now loaded from the RBS collection.
- If you are using custom YARD tags, Sord can now be made aware of these by passing the
--tagsoption.
- Breaking change: Support for versions of Ruby prior to 2.7 has been dropped.
- When Sord runs YARD automatically, it no longer generates HTML documentation, since this isn't necessary for Sord's analysis. If you were relying on this as part of your workflow, then this could be a breaking change.
- Duck-typed methods ending with
?or!, and operator methods like#[]=, are now correctly recognised as duck types. - Fixed an exception when referring to built-in types with root namespace (
::Array<Foo>) syntax. @yieldparamswithout a parameter name no longer cause an exception, and instead use default names of the pattern:arg0,arg1, ...
- Constants are now assigned types when generating RBS, using
@return. - Class-level
attr_accessors are converted to methods when generating RBS. - Added the
--exclude-untypedflag, which skips generating type signatures for methods withuntypedreturn values.
- If YARD tags are present for a block, but there is no block param (such as when using
yield), the type signature now includes the documented block. This could be a breaking change leading to type errors in existing code where such methods are called.
- Added workaround for YARD syntax error when a default parameter value begins with a unary minus
- Name resolutions from the root (e.g.
::X) now behave correctly; previously they may have selected a class namedXnested within another namespace. This may be a breaking change if any part of your generated type signatures was relying on the old, buggy behaviour.
- Fixed
SortedSetcrash on Ruby 3 - Fixed incorrect
extendorder on YARD 0.9.26
- Sord now uses the Parlour 5 beta's RBS generation to generate RBS files!
- Added
--rbiand--rbsto select an output format to use (if neither given, tries to infer from file extension).
RbiGeneratorhas been renamed toGenerator.TypeConverter#yard_to_sorbetis nowTypeConverter#yard_to_parlour, and returnsParlour::Types::Typeinstances rather than strings.
#return [nil]no longer produces a union of zero types, instead becomingvoidfor method returns oruntypedfor attributes.
3.0.0 pre-releases
- Sord is no longer limited to a known set of generics, and will instead
generate
Parlour::Types::Generictypes for user-defined generics.
- Sord now uses the Parlour 5 beta's RBS generation to generate RBS files!
- Added
--rbiand--rbsto select an output format to use (if neither given, tries to infer from file extension).
RbiGeneratorhas been renamed toGenerator.TypeConverter#yard_to_sorbetis nowTypeConverter#yard_to_parlour, and returnsParlour::Types::Typeinstances rather than strings.
#return [nil]no longer produces a union of zero types, instead becomingvoidfor method returns oruntypedfor attributes.
- Sord now supports generating
attr_accessor,attr_readerandattr_writerand will do so automatically when these are used in your code.- Depending on what you're doing with Sord, this is potentially breaking,
as for example attributes which would previously generate two
fooandfoo=methods in Sord will now just generate anattr_accessor.
- Depending on what you're doing with Sord, this is potentially breaking,
as for example attributes which would previously generate two
#initializeis now always typed as returningvoid, which is potentially breaking if you directly call#initializein code.- The
--use-original-initialize-returnflag restores the old behaviour of using whatever return type is provided, like any other method.
- The
- Added the
--skip-constantsflag to avoid generating RBIs for constants.
- Parlour 2.0.0 is now being used.
- Fixed a bug where blank parameters were sometimes treated like non-blank parameters.
- Fixed parameter order sometimes being incorrect.
- Fixed multiline parameter lists sometimes generating invalid RBIs.
- Multiline comments are now generated correctly.
- Fixed an incorrect README link.
- Comments in RBIs are now converted from YARD into Markdown format, making them
look much better when viewed in an IDE. (To restore the old behaviour of copying
the YARD comments verbatim, use the
--keep-original-commentsflag.)
- Parlour 0.8.0 is now being used.
- References to
selfas a type in YARD docs are now generated asT.self_type, rather than a fixed self type determined by Sord.
- Add the
--replace-constants-with-untypedflag, which generatesT.untypedinstead ofSORD_ERRORconstants. - Added an option to clean the
sord_examplesdirectory when seeding or reseeding. - Added a Rake task to typecheck the
sord_examplesdirectory. - Added a
.parlourfile to the project for generating Sord's RBIs. - Added CI with Travis.
- Code generation has been broken out into the Parlour gem, and Sord is now a Parlour plugin.
- Rainbow is now used for coloured output instead of colorize.
- Duplicate type signatures are no longer generated for inherited methods.
- The Resolver can now resolve more objects.
- If a parameter has
nilas its default, it now has a nilable type. - Generation of constants has been improved.
- Superclass names are now generated as fully-qualified identifiers.
- Fixed
T::HashandT::Arraysyntax being generated incorrectly. - Fix a bug where the
--no-commentsor--no-generateflags were ignored. - Collections of
T.untypednow have signatures generated correctly. - Fix generation of hashes when they are given too few parameters.
- YARD no longer prints irrelevant error messages when running rake.
- Block types can now be generated using
@yieldparamand@yieldreturn. - Long lists of parameters (at least 4) are now broken onto multiple lines. The threshold can be altered with the
--break-paramsoption. - If a constant used is not found, Sord will now attempt to locate it and fully-qualify its name.
- Add the
--replace-errors-with-untypedflag; when present,T.untypedis used instead ofSORD_ERROR_constants. - Add the
--include/exclude-messagesflags, which can be used to suppress certain log message kinds. - Add support for the
Class<...>generic becomingT.class_of(...). (#44) - Add YARD array (
<...>) and hash ({... => ...}) shorthands. (#43) - Sord now has an
examplesset of Rake tasks to test Sord on a large number of repos. - Sord now bundles an RBI for itself.
- Methods without any YARD documentation are now typed as
T.untypedrather thanvoid.
- Duck types in the form of setters (
#foo=) are now interpreted properly. - Fix some cases where indentation was incorrect. (#30, #46)
- Fix
includeandextendcalls being swapped, and give them proper blank lines. - Fix incorrect blank lines inside empty namespaces.
- Fix a crash when a
@paramhas no name given.
- Fix bug where
--no-regenerateflag was ignored.
- A warning message is now shown if the YARD registry has no objects. (#31)
- Integer, Float and Symbol literals are now supported as types. (#26)
- Add support for multi-method YARD duck types. (#38)
- Namespaces are now indented properly. (#41)
- Individual method and namespace counts are now shown, rather than just an overall object count. (#36)
- Paths to log message items are now bold rather than white, so that they can be seen on white terminals. (#28)
- Alias methods are now ignored. (#34)
- Remove Gemfile.lock. (#33)
- YARD is executed when Sord is executed. To disable this behaviour, use
--no-regenerate. (#31)
- Resolved crash when a @return tag gave no type. (#35)
- Namespaces are now nested inside each other in the RBI file, fixing many constant scoping issues. (#25)
- Move unfinished tasks from README to GitHub issues.
- Fix typo of 'duck' as 'ducl' (#24)
- Hash rocket syntax for hash types is now supported. (#18)
- Arrays with multiple element types are handled correctly. (#21)
- Move a dependency from Gemfile to Gemspec for consistency. (#19)
- Fix bug where splat-args (
*a) were always calledargsin signatures. (#20)
- The changelog for this version is the same as 0.4.0, but resolving an issue where some changes were not published correctly to RubyGems.
- Commander is now used for the CLI, which enables a
--helpswitch. - Add a
--no-commentsswitch for disabling comments in the RBI file.
- Sord now exits as early as possible if no filename is specified. (#17)
- Remove & in block parameter names in signatures, fixing a syntax error in RBIs. (#16)
selfnow resolves to a type in signatures.trueandfalseare now converted toT::Booleanin signatures.- If a
T.anycontainsnil, it now instead wraps that part of the signature in aT.nilableinstead. - Add GitHub issue templates.
.vscodeis now git-ignored.- Method definitions now have a semicolon before the end for consistency with Sorbet's RBIs. (#6)
paramsis now omitted from signatures if a method has no parameters. (#4)
- Fix kwargs in signatures by removing the duplicate colon from their identifier. (#12)
- Fix kwargs in definitions by not inserting an equal-to symbol for their defaults. (#11)
- Fix exception on launch due to forgetting to initialise a class variable. (#1)
- Add RSpec tests.
- Add the Logging class with prettier output.
- Generic types can now take more than one type parameter.
- Add documentation for all classes.
- Add a README.
- Add Sorbet directory and typing mode comments (
srb init).
- Sord now requires a command-line argument to save the RBI to.
- First release.