-
Notifications
You must be signed in to change notification settings - Fork 438
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
Refactor Darkfish implementation #1300
Draft
st0012
wants to merge
12
commits into
master
Choose a base branch
from
refactor-pages-sidebar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34a27fd
to
18f771a
Compare
Deploying rdoc with
|
Latest commit: |
8373d70
|
Status: | ✅ Deploy successful! |
Preview URL: | https://831c1cc1.rdoc-6cd.pages.dev |
Branch Preview URL: | https://refactor-pages-sidebar.rdoc-6cd.pages.dev |
18f771a
to
6dadc0d
Compare
This was referenced Mar 2, 2025
st0012
added a commit
that referenced
this pull request
Mar 2, 2025
Extracted from #1300 These things are not currently used by anything. Please review by commits.
st0012
added a commit
that referenced
this pull request
Mar 2, 2025
Discovered when working on #1300 Currently we need to call `setup` in individual generation methods, despite having already called it in `RDoc#generate`. This is because `setup` is lazily called when we run `ri`'s server mode. By calling `setup` eagerly in `Servlet#generator_for`, we can avoid the repeated calls to `setup` in individual generation methods. Right now we can NOT move `setup` into `Darkfish#initialize` yet because `ri`'s server can[ initialize `Darkfish` with `nil` store](https://github.com/ruby/rdoc/blob/master/lib/rdoc/servlet.rb#L335).
Under the current implementation, the template variables are captured through the `render_template` method's block. This makes it hard to understand if a variable is intended to be used in the template or not. This commit changes the `render_template` method to require passing a hash of local variables to the template. This makes the variable scope explicit and easier to reason about.
6dadc0d
to
8373d70
Compare
nobu
reviewed
Mar 8, 2025
io_output = out_file && !@dry_run && @file_output | ||
erb_klass = io_output ? RDoc::ERBIO : ERB | ||
|
||
template = template_for template_file, true, erb_klass | ||
|
||
@context = binding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn’t it possible that the template accidentally affects the variables of this method?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Notable changes:
Avoid using block binding to capture template variables
Under the current implementation, the template variables are captured
through the
render_template
method's block. This makes it hard tounderstand if a variable is intended to be used in the template or not.
This commit changes the
render_template
method to require passinga hash of local variables to the template. This makes the variable
scope explicit and easier to reason about.