Skip to content

Commit

Permalink
Generate docs/
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsh2102 committed Jun 15, 2020
1 parent d67f3bd commit 4bed899
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/antora.yml
@@ -0,0 +1,5 @@
name: rubocop-packaging
title: RuboCop Packaging
version: master
nav:
- modules/ROOT/nav.adoc
6 changes: 6 additions & 0 deletions docs/modules/ROOT/nav.adoc
@@ -0,0 +1,6 @@
* xref:index.adoc[Home]
* xref:installation.adoc[Installation]
* xref:usage.adoc[Usage]
* xref:cops.adoc[Cops]
* Cops Documentation
** xref:cops_packaging.adoc[Packaging]
7 changes: 7 additions & 0 deletions docs/modules/ROOT/pages/cops.adoc
@@ -0,0 +1,7 @@
// START_COP_LIST

= Department xref:cops_packaging.adoc[Packaging]

* xref:cops_packaging.adoc#packaginggemspecgit[Packaging/GemspecGit]

// END_COP_LIST
59 changes: 59 additions & 0 deletions docs/modules/ROOT/pages/cops_packaging.adoc
@@ -0,0 +1,59 @@
= Packaging

== Packaging/GemspecGit

|===
| Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged

| Enabled
| Yes
| No
| 0.86
| -
|===

This cop is used to identify the usage of `git ls-files`
and suggests to use a plain Ruby alternative, like `Dir`,
`Dir.glob` or `Rake::FileList` instead.

=== Examples

[source,ruby]
----
# bad
Gem::Specification.new do |spec|
spec.files = `git ls-files`.split('\n')
end
# bad
Gem::Specification.new do |spec|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split('\\x0').reject { |f| f.match(%r{^(test|spec|features)/}) }
end
end
# bad
Gem::Specification.new do |spec|
spec.files = `git ls-files`.split('\n')
spec.test_files = `git ls-files -- test/{functional,unit}/*`.split('\n')
spec.executables = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) }
end
# good
Gem::Specification.new do |spec|
spec.files = Dir['lib/**/*', 'LICENSE', 'README.md']
spec.test_files = Dir['spec/**/*']
end
# good
Gem::Specification.new do |spec|
spec.files = Rake::FileList['**/*'].exclude(*File.read('.gitignore').split)
end
# good
Gem::Specification.new do |spec|
spec.files = Dir.glob('lib/**/*')
spec.test_files = Dir.glob('test/{functional,test}/*')
spec.executables = Dir.glob('bin/*').map{ |f| File.basename(f) }
end
----
10 changes: 10 additions & 0 deletions docs/modules/ROOT/pages/index.adoc
@@ -0,0 +1,10 @@
= RuboCop Packaging

`RuboCop::Packaging` is an extension of [RuboCop](https://rubocop.org/),
which is a Ruby static code analyzer (a.k.a. linter) and code formatter.

It contains a set of Cops which enforces some of the guidelines that
are expected of upstream maintainers so that the downstream can build
their packages in a clean environment without any problems.
Some of the other basic guidelines can be found
[here](https://wiki.debian.org/Teams/Ruby/RubyExtras/UpstreamDevelopers).
22 changes: 22 additions & 0 deletions docs/modules/ROOT/pages/installation.adoc
@@ -0,0 +1,22 @@
= Installation

Add this line to your application's Gemfile:

[source,ruby]
----
gem 'rubocop-packaging', require: false
----

And then execute:

[source,bash]
----
$ bundle install
----

Or install it yourself as:

[source,bash]
----
$ gem install rubocop-packaging
----
42 changes: 42 additions & 0 deletions docs/modules/ROOT/pages/usage.adoc
@@ -0,0 +1,42 @@
= Usage

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

== RuboCop configuration file

Put this into your `.rubocop.yml` file:

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

Alternatively, use the following array notation when specifying multiple
extensions:

[source,yaml]
----
require:
- rubocop-other-extension
- rubocop-packaging
----

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

== Command line

[source,bash]
----
rubocop --require rubocop-packaging
----

== Rake task

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

0 comments on commit 4bed899

Please sign in to comment.