Make YARD documentation idempotent #1426
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Resolves #1345
Problem:
YARD.parse
stores parsed documentation into a registry that's persisted. So depending on the parsing order of the gems documentation may change. If a previous gem has documentation for a constant/method definition it'll be included in the current gem's documentation too. However, in another run if that previous gem is parsed too late its documentation won't be available.Implementation
In this PR we reset the YARD registry everytime we parse a gem's documentation to ensure only the documentation from that gem is included in the output. This means parsing order has no effect in the RBIs created and that documentation generation is idempotent.
As a result of this change duplicated RBI entries will not contain as much documentation as before. For example, when a gem defines a method on the global namespace tapioca would define
class Object
on the gem RBI. If a previously processed gem had documentation forObject
it'd get imported into that gem, example. In some cases like the example the documentation didn't even make sense. It's coming from Rails.We initially tried to keep the documentation for each gem by parsing the documentation of all gems before any RBI generation. However, this increases the runtime since parsing isn't done in parallel anymore.
Tests
Included