Class: Docbook::Services::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/docbook/services/linter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document, input_path: nil) ⇒ Linter

Returns a new instance of Linter.



8
9
10
11
12
13
# File 'lib/docbook/services/linter.rb', line 8

def initialize(document, input_path: nil)
  @document = document
  @input_path = input_path
  @errors = []
  @warnings = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/docbook/services/linter.rb', line 6

def errors
  @errors
end

#warningsObject (readonly)

Returns the value of attribute warnings.



6
7
8
# File 'lib/docbook/services/linter.rb', line 6

def warnings
  @warnings
end

Instance Method Details

#check(strict: false) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/docbook/services/linter.rb', line 15

def check(strict: false)
  check_duplicate_ids
  check_empty_elements
  if strict
    check_broken_xrefs
    check_missing_images
  end
  self
end

#ok?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/docbook/services/linter.rb', line 25

def ok?
  @errors.empty?
end