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

Include files relative to the framework root #360

Closed
wants to merge 1 commit into from

Conversation

p8
Copy link
Member

@p8 p8 commented Jan 17, 2024

The Rails documentation uses the :include: directive to inline the README of the framework into the main documentation page. As the README's aren't in the root directory from where SDoc is run we need to add the framework path to the include:

# :include: activesupport/README.md

This results in a warning when installing the gems as generating the rdoc for the gem is run from the gem/framework root:

Couldn't find file to include 'activesupport/README.rdoc' from lib/active_support.rb

By Monkeypatching find_include_file to find files at the framework root we can include without the framework path:

# :include: README.md

Fixes: rails/rails#49524

Copy link

netlify bot commented Jan 17, 2024

Deploy Preview for sdoc failed.

Name Link
🔨 Latest commit 8d18c1e
🔍 Latest deploy log https://app.netlify.com/sites/sdoc/deploys/65a7cbf2d72b6e0008eccfed

The Rails documentation uses the `:include:` directive to inline the
README of the framework into the main documentation page.
As the README's aren't in the root directory from where SDoc is run we
need to add the framework path to the include:

    # :include: activesupport/README.md

This results in a warning when installing the gems as generating the
rdoc for the gem is run from the gem/framework root:

    Couldn't find file to include 'activesupport/README.rdoc' from lib/active_support.rb

By Monkeypatching `find_include_file` to find files at the framework
root we can include without the framework path:

    # :include: README.md
@p8 p8 force-pushed the improve-readme-includes branch from 8d18c1e to 49f2014 Compare January 17, 2024 12:48

RDoc::Markup::PreProcess.prepend(Module.new do
def find_include_file(name)
to_search = [File.dirname(File.dirname(@input_file_name))].concat @include_path
Copy link
Member Author

Choose a reason for hiding this comment

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

The following would be nicer but won't work on Ruby 2.7:

Suggested change
to_search = [File.dirname(File.dirname(@input_file_name))].concat @include_path
to_search = [File.dirname(@input_file_name, 2)].concat @include_path

@p8
Copy link
Member Author

p8 commented Jan 18, 2024

Closing in favor of the much cleaner rails/rails#50789
This also makes sure SDoc works as expected for other gems.

@p8 p8 closed this Jan 18, 2024
@p8 p8 deleted the improve-readme-includes branch January 18, 2024 10:00
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.

Warning on README.md files not found during Rails 7.1 gem installation
1 participant