File: cops_documentation.rake

package info (click to toggle)
ruby-rubocop-packaging 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 220 kB
  • sloc: ruby: 739; sh: 4; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

require "yard"
require "rubocop"
require "rubocop-packaging"
require "rubocop/cops_documentation_generator"

YARD::Rake::YardocTask.new(:yard_for_generate_documentation) do |task|
  task.files = ["lib/rubocop/cop/**/*.rb"]
  task.options = ["--no-output"]
end

desc "Generate docs of all cops departments"
task generate_cops_documentation: :yard_for_generate_documentation do
  deps = ["Packaging"]
  CopsDocumentationGenerator.new(departments: deps).call
end

desc "Verify that documentation is up to date"
task verify_cops_documentation: :generate_cops_documentation do
  # Do not print diff and yield whether exit code was zero
  sh("git diff --quiet docs") do |outcome, _|
    exit if outcome

    # Output diff before raising error
    sh("GIT_PAGER=cat git diff docs")

    warn "The docs directory is out of sync. " \
      "Run `rake generate_cops_documentation` and commit the results."
    exit!
  end
end