Class: Glossarist::Validation::Rules::AsciidocXrefRule
- Defined in:
- lib/glossarist/validation/rules/asciidoc_xref_rule.rb
Instance Method Summary collapse
- #applicable?(context) ⇒ Boolean
- #category ⇒ Object
- #check(context) ⇒ Object
- #code ⇒ Object
- #scope ⇒ Object
- #severity ⇒ Object
Methods inherited from Base
Instance Method Details
#applicable?(context) ⇒ Boolean
12 13 14 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 12 def applicable?(context) context.concept.localizations&.any? end |
#category ⇒ Object
8 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 8 def category = :references |
#check(context) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 16 def check(context) concept = context.concept fname = context.file_name extractor = ReferenceExtractor.new issues = [] concept.localizations.each do |l10n| lang = l10n.language_code || "unknown" l10n.text_content.each do |text| next unless text extractor.extract_from_text(text).each do |ref| next unless ref.is_a?(BibliographicReference) next if context.bibliography_index.resolve?(ref.anchor) issues << issue( "unresolved bibliography reference <<#{ref.anchor}>>", code: code, severity: severity, location: "#{fname}/#{lang}", suggestion: "add '#{ref.anchor}' as a source, " \ "or verify it exists in bibliography.yaml", ) end end end issues end |
#code ⇒ Object
7 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 7 def code = "GLS-102" |
#scope ⇒ Object
10 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 10 def scope = :concept |
#severity ⇒ Object
9 |
# File 'lib/glossarist/validation/rules/asciidoc_xref_rule.rb', line 9 def severity = "warning" |