Class: Uniword::Validation::Rules::BookmarkUniquenessRule

Inherits:
ModelRule
  • Object
show all
Defined in:
lib/uniword/validation/rules/bookmark_uniqueness_rule.rb

Overview

DOC-202: bookmark names should be unique.

Duplicate names confuse cross-references and GoTo navigation. The Word-internal "_GoBack" bookmark is exempt.

Instance Method Summary collapse

Methods inherited from ModelRule

#context_type

Methods inherited from Base

#applicable?, #context_type, #description, #validity_rule

Instance Method Details

#categoryObject



12
# File 'lib/uniword/validation/rules/bookmark_uniqueness_rule.rb', line 12

def category = :bookmarks

#check(context) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/uniword/validation/rules/bookmark_uniqueness_rule.rb', line 15

def check(context)
  body = context.document.body
  return [] unless body

  duplicates(body.bookmark_starts || []).map do |name|
    issue("Duplicate bookmark name '#{name}'",
          part: "word/document.xml")
  end
end

#codeObject



11
# File 'lib/uniword/validation/rules/bookmark_uniqueness_rule.rb', line 11

def code = "DOC-202"

#severityObject



13
# File 'lib/uniword/validation/rules/bookmark_uniqueness_rule.rb', line 13

def severity = "warning"