require 'rubygems/commands/yardoc_command'

Gem::CommandManager.instance.register_command :yardoc

Gem.post_install do |installer|
  next unless installer.options[:document].include? 'yardoc'
  next if File.exist? installer.spec.doc_dir('yardoc')
  YARD::Registry.clear
  Gem::Commands::YardocCommand.run_yardoc(installer.spec)
end

Gem.pre_uninstall do |uninstaller|
  FileUtils.rm_rf uninstaller.spec.doc_dir('yardoc')
end

require 'rubygems/commands/yardoc_command'

Gem::CommandManager.instance.register_command :yardoc

Remove gem post_install and pre_uninstall hooks
Remove gem post_install and pre_uninstall hooks

YARD itself supports --document=yri,yard flags from v0.9.1.
See http://www.rubydoc.info/gems/yard/file/CHANGELOG.md#0_9_1_-_July_18th__2016
