Class: TexOutputFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/trex.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(texOutput, verbose = false, quiet = false, source = nil, errorGroups = nil) ⇒ TexOutputFormatter

Returns a new instance of TexOutputFormatter.



429
430
431
432
433
434
435
436
437
438
439
440
# File 'lib/trex.rb', line 429

def initialize(texOutput, verbose=false, quiet=false,  source=nil,
              errorGroups=nil)
    #TODO add arg check
    @texOutput     = texOutput
    @source        = source
    @totalWarnings = 0
    @parsed        = false
    @verbose       = verbose
    @quiet         = quiet
    @errorGroups   = errorGroups
    self.initialize_error_groups
end

Instance Attribute Details

#citationWarningsObject (readonly)

Returns the value of attribute citationWarnings.



426
427
428
# File 'lib/trex.rb', line 426

def citationWarnings
  @citationWarnings
end

#errorGroupsObject

Returns the value of attribute errorGroups.



426
427
428
# File 'lib/trex.rb', line 426

def errorGroups
  @errorGroups
end

#referenceWarningsObject (readonly)

Returns the value of attribute referenceWarnings.



426
427
428
# File 'lib/trex.rb', line 426

def referenceWarnings
  @referenceWarnings
end

Instance Method Details

#add(handler) ⇒ Object




524
525
526
527
# File 'lib/trex.rb', line 524

def add(handler)
    handler.filestate = @filestate
    @errorGroups.push handler
end

#hasCitationWarnings?Boolean


Returns:

  • (Boolean)


512
513
514
515
# File 'lib/trex.rb', line 512

def hasCitationWarnings?
    self.parse unless @parsed
    not @citationWarnings.empty?
end

#hasReferenceWarnings?Boolean

Returns:

  • (Boolean)


517
518
519
520
# File 'lib/trex.rb', line 517

def hasReferenceWarnings?
    self.parse unless @parsed
    not @referenceWarnings.empty?
end

#initialize_error_groupsObject



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/trex.rb', line 442

def initialize_error_groups
    interestingLimits   = 50
    interestingLimits   = 0 if @quiet
    uninterestingLimits = 0
    uninterestingLimits = 50 if @verbose
    return unless @errorGroups.nil?

    @filestate         = FilenameParser.new
    @citationWarnings  = CitationWarning.new(interestingLimits)
    @referenceWarnings = ReferenceWarning.new(interestingLimits)
    @errorGroups = [
      PDFVersionMismatchWarning.new(uninterestingLimits),

      TexWarning.new('Underfull lines',
                     /Underfull.*/,
                     /\(badness [0-9]+\) in \w+/,
                     uninterestingLimits),

      TexWarning.new('Overfull lines',
                     /Overfull.*/,
                     /\w+ \(.*?\) in \w+/,
                     uninterestingLimits),

      TexWarning.new('Float changes',
                     /Warning:.*?float specifier changed to/,
                     /float specifier .*/,
                     uninterestingLimits),

      TexWarning.new('Package Warning',
                     /Package .* Warning/,
                     /.*/,
                     uninterestingLimits),


      FontWarning.new(uninterestingLimits),

      @citationWarnings, @referenceWarnings,

      TooManyWarning.new(interestingLimits),

      RepeatedPageNumberWarning.new(uninterestingLimits),

      TexError.new('Undefined Control Sequence',
                    /! Undefined control /,
                    /\\.*/, interestingLimits),

      TexError.new('LaTeX error', /! LaTeX Error/, /.*/,
                    interestingLimits),

      MissingParenthesisWarning.new(@source, interestingLimits),

      PharagraphEndedWarning.new(@source, interestingLimits),

      TexWarning.new('File not Found',
                     /Warning: File/,
                     /[^ ]+ not found/,
                     interestingLimits),

      MultipleLabelWarning.new(@source, interestingLimits),

      TexError.new('Other Errors', /^! /, /.*/, interestingLimits),

      @filestate,

      OtherWarning.new,
    ]
    @errorGroups.each { |eg| eg.filestate = @filestate }
end


529
530
531
532
533
534
535
536
# File 'lib/trex.rb', line 529

def print
    self.parse unless @parsed
    @errorGroups.each { |group|
        if not group.empty?
             Kernel.print group.to_s
        end
    }
end