Skip to content

Remove unused class_dir and file_dir attributes from generators #1304

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

Merged
merged 3 commits into from
Mar 3, 2025

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Mar 2, 2025

These generator methods are either not defined, or return a fixed nil value. Therefore, we can remove them and simplify some downstream logics accordingly.

st0012 added 3 commits March 2, 2025 21:52
In all generators it only returns nil.
Similar to the class_dir attribute, the file_dir attribute never returns
anything but nil.
Since their prefix argument is always nil, we can stop passing it
and simplify the methods accordingly.
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

+1

@st0012 st0012 merged commit 694987b into master Mar 3, 2025
52 checks passed
@st0012 st0012 deleted the remove-unused-class-and-file-dir-attributes branch March 3, 2025 10:51
@jonathanhefner
Copy link
Contributor

Hello! 👋 This is a major breaking change for SDoc. SDoc overrides class_dir and file_dir to prefix URL paths with classes/ and files/, respectively. For example, in the URLs for https://api.rubyonrails.org/classes/ActiveRecord/Base.html and https://api.rubyonrails.org/files/activerecord/lib/active_record/base_rb.html.

It should also be noted that RDoc < 6.13.0 requires these methods when implementing a custom generator. Omitting them will cause RDoc to raise a NoMethodError.

As a workaround, I monkey patched RDoc::ClassModule and RDoc::TopLevel in rails/sdoc@e2d849f, but I think it would be better to revert this change. Would it be possible to do so in RDoc 6.13.1?

@st0012
Copy link
Member Author

st0012 commented Mar 24, 2025

Sorry that I wasn't aware of sdoc's use case of it. Can I propose an additional approach to restore customizing the prefixes than reverting the change tho as the original implementation was really not ideal IMO.

st0012 added a commit that referenced this pull request Mar 24, 2025
In #1304, I removed the ability to set
path prefix through patching Darkfish generator. But it turns out
that it's used in `sdoc`.

See #1304 (comment)

But the original implementation was brittle and confusing. So instead of
just restoring it, I think allowing the customization through options is
a better approach.
st0012 added a commit that referenced this pull request Mar 24, 2025
In #1304, I removed the ability to set
path prefix through patching Darkfish generator. But it turns out
that it's used in `sdoc`.

See #1304 (comment)

But the original implementation was brittle and confusing. So instead of
just restoring it, I think allowing the customization through options is
a better approach.
@st0012
Copy link
Member Author

st0012 commented Mar 24, 2025

I think customizing prefix in options is a better approach: #1330

st0012 added a commit that referenced this pull request Mar 24, 2025
In #1304, I removed the ability to set
path prefix through patching Darkfish generator. But it turns out
that it's used in `sdoc`.

See #1304 (comment)

But the original implementation was brittle and confusing. So instead of
just restoring it, I think allowing the customization through options is
a better approach.
@kou kou mentioned this pull request Mar 25, 2025
@kou
Copy link
Member

kou commented Mar 25, 2025

Oh, it may be better that we have a CI job for SDoc: #1331

st0012 added a commit that referenced this pull request Mar 25, 2025
In #1304, I removed the ability to set
path prefix through patching Darkfish generator. But it turns out
that it's used in `sdoc`.

See #1304 (comment)

But the original implementation was brittle and confusing. So instead of
just restoring it, I think allowing the customization through options is
a better approach.
st0012 added a commit that referenced this pull request Mar 29, 2025
In #1304, I removed the ability to set
path prefix through patching Darkfish generator. But it turns out that
it's used in `sdoc`.

See #1304 (comment)

But the original implementation was brittle and confusing. So instead of
just restoring it, I think allowing the customization through options is
a better approach.
@jeremyevans
Copy link
Contributor

jeremyevans commented May 10, 2025

This change also broke expected file creation in the hanna gem. I'll see if I can get the prefix option described in #1330 to work, but backwards incompatible changes like this should be reserved for major version bumps. RDoc should not assume that Darkfish is the only generator, and just remove features that Darkfish doesn't use.

Edit: Fixed: jeremyevans/hanna@79c453c

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.

4 participants