class GemHadar

def yard_task

If YARD is not available, the method returns early without defining any tasks.
cleaning up documentation files, and listing undocumented elements.
creating private documentation, viewing the generated documentation,
It creates multiple subtasks under the :yard namespace, including tasks for

managing YARD documentation.
The yard_task method sets up and registers Rake tasks for generating and
def yard_task
  defined? YARD or return
  yard_doc_task
  desc 'Create yard documentation (including private)'
  task :doc => :yard_doc
  namespace :yard do
    my_yard_dir = Pathname.new(yard_dir)
    task :private => :yard_doc
    task :public => :yard_doc
    desc 'Create yard documentation'
    task :doc => :yard_doc
    desc 'View the yard documentation'
    task :view do
      index_file = my_yard_dir + 'index.html'
      File.exist?(index_file)
      sh "open #{index_file}"
    end
    desc 'Clean the yard documentation'
    task :clean do
      rm_rf my_yard_dir
    end
    desc 'List all undocumented classes/modules/methods'
    task :'list-undoc' do
      sh "yard stats --list-undoc"
    end
  end
  desc 'Create the yard documentation and view it'
  task :yard => %i[ yard:private yard:view ]
end