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

Add a yieldself tag #1491

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add a yieldself tag #1491

wants to merge 2 commits into from

Conversation

castwide
Copy link
Contributor

@castwide castwide commented Apr 9, 2023

Description

Add a @yieldself tag to document the context in which yielded blocks are expected to run. Example:

class Foo; end

class Bar
  def initialize
    @foo = Foo.new
  end

  # @yieldself [Foo]
  def run_in_foo &proc
    @foo.instance_eval &proc
  end
end

Solargraph currently uses this tag to enhance autocompletion. I was planning to write an extension so gems could add it to their yardocs, but it seemed useful enough in documentation to check if it was worth adding to YARD itself.

Completed Tasks

  • I have read the Contributing Guide.
  • The pull request is complete (implemented / written).
  • Git commits have been cleaned up (squash WIP / revert commits).
  • I wrote tests and ran bundle exec rake locally (if code is attached to PR).

@lsegal
Copy link
Owner

lsegal commented Aug 26, 2024

I realize this is a little late, but the naming for this is a little confusing. At first I thought this was specifying that the block (literally) "yields self", which I would have suggested is already supported. Upon further reading, this is actually about the type of self. I could see a few people tripping up on this, especially since the tag description does not make it any more obvious.

I'm not sure what the right solution is, but I think in its current form I'm not too keen on merging. I'd suggest either a better name (no, I don't have a good answer here), or, at the very least, a more descriptive name parameter in the define_tag declaration so that readers understand what the field is.

tl;dr documentation authors might understand what @yieldself is (the docs provide the context), but readers of the generated docs will just see "yield self" and have no idea what that means.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants