Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow documentation exclusions with --doc-exclude

  • Loading branch information...
commit f02b19c41652d5f9008be9f575f981aa32399e28 1 parent 72af786
@justincampbell justincampbell authored
View
27 lib/cane/doc_check.rb
@@ -14,12 +14,17 @@ def self.key; :doc; end
def self.name; "documentation checking"; end
def self.options
{
- doc_glob: ['Glob to run doc checks over',
- default: '{app,lib}/**/*.rb',
- variable: 'GLOB',
- clobber: :no_doc],
- no_readme: ['Disable readme checking', cast: ->(x) { !x }],
- no_doc: ['Disable documentation checking', cast: ->(x) { !x }]
+ doc_glob: ['Glob to run doc checks over',
+ default: '{app,lib}/**/*.rb',
+ variable: 'GLOB',
+ clobber: :no_doc],
+ doc_exclude: ['Exclude file from documentation checking',
+ variable: 'FILE',
+ type: Array,
+ default: [],
+ clobber: :no_doc],
+ no_readme: ['Disable readme checking', cast: ->(x) { !x }],
+ no_doc: ['Disable documentation checking', cast: ->(x) { !x }]
}
end
@@ -68,7 +73,7 @@ def missing_file_violations
end
def file_names
- Dir[opts.fetch(:doc_glob)]
+ Dir[opts.fetch(:doc_glob)].reject { |file| excluded?(file) }
end
def class_definition?(line)
@@ -83,6 +88,14 @@ def extract_class_name(line)
line.match(/class\s+([^\s;]+)/)[1]
end
+ def exclusions
+ @exclusions ||= opts.fetch(:doc_exclude, []).flatten.to_set
+ end
+
+ def excluded?(file)
+ exclusions.include?(file)
+ end
+
def worker
Cane.task_runner(opts)
end
View
13 spec/doc_check_spec.rb
@@ -71,4 +71,17 @@ class Doc; end
"Missing documentation", "No README found"
]
end
+
+ it 'skips declared exclusions' do
+ file_name = make_file <<-FILE.gsub /^\s{6}/, ''
+ class NeedsDocumentation
+ end
+ FILE
+
+ violations = check(file_name,
+ doc_exclude: [file_name]
+ ).violations
+
+ violations.length.should == 0
+ end
end
View
2  spec/parser_spec.rb
@@ -63,11 +63,13 @@ def run(cli_args)
it 'supports exclusions' do
options = [
"--abc-exclude", "Harness#complex_method",
+ "--doc-exclude", 'myfile',
"--style-exclude", 'myfile'
].join(' ')
_, result = run(options)
result[:abc_exclude].should == [['Harness#complex_method']]
+ result[:doc_exclude].should == [['myfile']]
result[:style_exclude].should == [['myfile']]
end
Please sign in to comment.
Something went wrong with that request. Please try again.