Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make YARD documentation idempotent #1426

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Make YARD documentation idempotent #1426

merged 1 commit into from
Mar 6, 2023

Conversation

KaanOzkan
Copy link
Contributor

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 for Object 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

@KaanOzkan KaanOzkan requested a review from a team as a code owner March 3, 2023 22:58
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor

@egiurleo egiurleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@KaanOzkan KaanOzkan merged commit 7ab180b into main Mar 6, 2023
@KaanOzkan KaanOzkan deleted the ko/idempotent-yard branch March 6, 2023 17:14
@shopify-shipit shopify-shipit bot temporarily deployed to production March 10, 2023 16:06 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YARD documentation is not idempotent with multiple constant reopenings
3 participants