Class: Docbook::Services::Linter
- Inherits:
-
Object
- Object
- Docbook::Services::Linter
- Defined in:
- lib/docbook/services/linter.rb
Overview
Lightweight lint checks for DocBook documents.
Checks for common issues without requiring full RELAX NG validation: duplicate IDs, broken cross-references, missing images, empty sections.
Usage: linter = Docbook::Services::Linter.new(parsed_doc) result = linter.check(strict: true) result.errors # => [{ message: "...", location: "..." }] result.warnings # => [{ message: "...", location: "..." }]
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#check(strict: false) ⇒ self
Run lint checks on the document.
-
#initialize(document, input_path: nil) ⇒ Linter
constructor
A new instance of Linter.
-
#ok? ⇒ Boolean
True if no errors were found.
Constructor Details
#initialize(document, input_path: nil) ⇒ Linter
Returns a new instance of Linter.
21 22 23 24 25 26 |
# File 'lib/docbook/services/linter.rb', line 21 def initialize(document, input_path: nil) @document = document @input_path = input_path @errors = [] @warnings = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
17 18 19 |
# File 'lib/docbook/services/linter.rb', line 17 def errors @errors end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
17 18 19 |
# File 'lib/docbook/services/linter.rb', line 17 def warnings @warnings end |
Instance Method Details
#check(strict: false) ⇒ self
Run lint checks on the document.
31 32 33 34 35 36 37 38 39 |
# File 'lib/docbook/services/linter.rb', line 31 def check(strict: false) check_duplicate_ids check_empty_elements if strict check_broken_xrefs check_missing_images end self end |
#ok? ⇒ Boolean
Returns true if no errors were found.
42 43 44 |
# File 'lib/docbook/services/linter.rb', line 42 def ok? @errors.empty? end |