lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.95k stars 398 forks source link

webrick optional #1435

Closed mathieujobin closed 2 years ago

mathieujobin commented 2 years ago

yard is the only gem left that requires webrick in my application. and I was wondering if it was possible to make it optional ?

Thanks

Steps to reproduce

use yard

Actual Output

webrick is required

Expected Output

webrick is not, fallback to puma

Environment details:

lsegal commented 2 years ago

WEBrick is the fallback, i.e., puma or other rack based adapters will always be used if they exist prior to webrick.

The challenge is that YARD needs at least one guaranteed-to-be-present HTTP server library on your system to function properly, specifically webrick is needed for underlying mime type parsing in yard server. Unfortunately RubyGems is not smart enough to allow for either-or style dependencies, so there is no way for YARD to require "either puma or webrick" and we must make a decision to guarantee that YARD works out of the box without any specific HTTP dependencies.

This was not a problem in Ruby 2.x when webrick was part of the distribution. You can blame Ruby for removing this default from the library in 3.0+. See #1387 for details.

mathieujobin commented 2 years ago

That is a good point. But not without a solution.

Webrick could be set as a dev dependency for tests to pass and all.

And when puma isn't available and it falls back to webrick which is also missing. Then it would simply raise an error.

mathieujobin commented 2 years ago

I see the other issue made you do the exact opposite.

Forcing people to add it to their gemfile when desired would not have been too bad in my opinion

MSP-Greg commented 2 years ago

webrick is needed for underlying mime type parsing in yard server

I don't use YARD server that often, so I'm not familiar with the code, but...

YARD::Server::Commands::StaticFileHelpers is including WEBrick::HTTPUtils, maybe for its DefaultMimeTypes hash constant and mime_type method. That functionality is also in Rack::Mime.

Since WEBrick isn't in the std-lib anymore, maybe switch to the Rack version? Could be done at runtime? Not.Sure.