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

Prepare antora documentation #70

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,61 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'open3'

require 'bundler'
require 'bundler/gem_tasks'

begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end

require 'rspec/core/rake_task'
require 'rubocop/rake_task'

Dir['tasks/**/*.rake'].each { |t| load t }

RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end

desc 'Run RuboCop over this gem'
RuboCop::RakeTask.new(:internal_investigation)

desc 'Confirm documentation is up to date'
task confirm_documentation: :generate_cops_documentation do
_, _, _, process =
Open3.popen3('git diff --exit-code docs/')

unless process.value.success?
abort 'Please run `rake generate_cops_documentation` ' \
raise 'Please run `rake generate_cops_documentation` ' \
'and add docs/ to the commit.'
end
end

task default: :spec
task default: %i[spec
internal_investigation
documentation_syntax_check
confirm_documentation]

desc 'Generate a new cop template'
task :new_cop, [:cop] do |_task, args|
require 'rubocop'

cop_name = args.fetch(:cop) do
warn "usage: bundle exec rake 'new_cop[ThreadSafety/Name]'"
exit!
end

generator = RuboCop::Cop::Generator.new(cop_name)

generator.write_source
generator.write_spec
generator.inject_require(root_file_path: 'lib/rubocop-thread_safety.rb')
generator.inject_config(config_file_path: 'config/default.yml')

puts generator.todo
end
5 changes: 5 additions & 0 deletions docs/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: rubocop-thread_safety
title: RuboCop Thread Safety
version: ~
nav:
- modules/ROOT/nav.adoc
6 changes: 6 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* xref:index.adoc[Home]
* xref:installation.adoc[Installation]
* xref:usage.adoc[Usage]
* xref:cops.adoc[Cops]
* Cops Documentation
** xref:cops_threadsafety.adoc[thread_safety]
4 changes: 4 additions & 0 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= RuboCop Thread Safety

Thread safety analysis for your projects, as an extension to
https://github.com/rubocop/rubocop[RuboCop].
15 changes: 15 additions & 0 deletions docs/modules/ROOT/pages/installation.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
= Installation

Just install the `rubocop-thread_safety` gem

[source,bash]
----
gem install rubocop-thread_safety
----

or if you use bundler put this in your `Gemfile`

[source,ruby]
----
gem 'rubocop-thread_safety'
----
32 changes: 32 additions & 0 deletions docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
= Usage

You need to tell RuboCop to load the Thread Safety extension. There are three
ways to do this:

== RuboCop configuration file

Put this into your `.rubocop.yml`.

[source,yaml]
----
require: rubocop-thread_safety
----

Now you can run `rubocop` and it will automatically load the RuboCop Thread Safety
cops together with the standard cops.

== Command line

[source,sh]
----
$ rubocop --require rubocop-thread_safety
----

== Rake task

[source,ruby]
----
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-thread_safety'
end
----
Loading