tex_log_parser 1.0.0.pre.14 → 1.0.0.pre.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9452fd78396c5094be2717ac70979ac88892678f73433966ee1ca79ba21fa73d
4
- data.tar.gz: 0e72ee4dc90ca406c2ba557eb017bca1c1a6ae682f9b2847d7f391ac4ddf0483
3
+ metadata.gz: 04cec17bca7fe8b297a5b35114d1334e3d5f530fba5f1e952672035c55d6627c
4
+ data.tar.gz: ec8e3cd45e18157f2fddb43b4c610f590792c0784bf857abd6d69b2d811e53f7
5
5
  SHA512:
6
- metadata.gz: 52cf6f343c49d26fcc9e880301ea082e89f279a65a59ef1bd3c02c25d5810bf05de410224ec28008d55d64b295ea3168b683422b1a85e530a9e886507963da33
7
- data.tar.gz: cda1bbf061fb89616784def652834b4020061d020be9c3874099a5bb7b7ed3b165f6343bf00398f3cbdbddae42cf8ab12b41d7dfc87929619c419f2fd56c32e5
6
+ metadata.gz: 3ce2d48f6d26848b14efecef85d48878cf93e9d5d638a77cf2c8a61af429b0a61364013dace4e5bbf532452dd9290d7dc3359d35b7c322f9bef69491bc893377
7
+ data.tar.gz: 9a062a9b01e3c467a64ac0166fe054f5e73174745c859d88767abd9faecaabdc8915e3ee879e72ddedf1435991992331a674b6d9392afc01150809ffdf351718
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # TeXLogParser
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/tex_log_parser.svg)](https://badge.fury.io/rb/tex_log_parser)
4
- [![Yard docs](http://img.shields.io/badge/yard-docs-green.svg)](http://www.rubydoc.info/gems/tex_log_parser/1.0.0.pre.2) **˙**
4
+ [![Yard docs](http://img.shields.io/badge/yard-docs-green.svg)](http://www.rubydoc.info/gems/tex_log_parser/1.0.0) **˙**
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/748992a2c5f6570797d4/maintainability)](https://codeclimate.com/github/reitzig/texlogparser/maintainability)
6
6
  [![Test Coverage](https://api.codeclimate.com/v1/badges/748992a2c5f6570797d4/test_coverage)](https://codeclimate.com/github/reitzig/texlogparser/test_coverage) **˙**
7
7
  [![Circle CI](https://circleci.com/gh/reitzig/texlogparser.svg?style=svg)](https://circleci.com/gh/reitzig/texlogparser)
@@ -5,12 +5,39 @@ require 'log_parser/buffer'
5
5
  require 'log_parser/message'
6
6
  require 'log_parser/pattern'
7
7
 
8
- # TODO: document
8
+ # Parses a log, extracting messages according to a set of {Pattern}.
9
+ #
10
+ # Instances are single-use; create a new one for every log and parsing run.
9
11
  module LogParser
12
+ # @return [Array<Message>]
13
+ # the messages this parser found in the given log.
10
14
  attr_reader :messages
15
+
16
+ # The parser keeps a record of the scope changes it detects.
17
+ #
18
+ # **Note:** Only available in debug mode; see {Logger}.
19
+ #
20
+ # The keys are line indices.
21
+ # The values are arrays of strings, with one string per scope change,
22
+ # in the same order as in the original line.
23
+ # * Entering a new scope is denoted by
24
+ #
25
+ # ```
26
+ # push filename
27
+ # ```
28
+ # and
29
+ # * leaving a scope by
30
+ #
31
+ # ```
32
+ # pop filename
33
+ # ```
34
+ # Note the extra space after `pop` here; it's there for quaint cosmetic reasons.
35
+ #
36
+ # @return [Hash<Integer, Array<String>>]
37
+ # the scope changes this parser detected in the given log.
11
38
  attr_reader :scope_changes_by_line if Logger.debug?
12
39
 
13
- # TODO: document
40
+ # Parses the given log lines and extracts all messages (of known form).
14
41
  # @return [Array<Message>]
15
42
  def parse
16
43
  skip_empty_lines
@@ -45,25 +72,33 @@ module LogParser
45
72
 
46
73
  # @abstract
47
74
  # @return [Array<Pattern>]
75
+ # The set of patterns this parser utilizes to extract messages.
48
76
  def patterns
49
77
  raise NotImplementedError
50
78
  end
51
79
 
80
+ # Extracts scope changes in the form of stack operations from the given line.
81
+ #
52
82
  # @abstract
53
83
  # @param [String] _line
54
- # @return [Array<String,:pop>] A list of new scopes this line enters (strings)
55
- # and leaves (`:pop`).
56
- # Read stack operations from left to right.
84
+ # @return [Array<String,:pop>]
85
+ # A list of new scopes this line enters (filename strings) and leaves (`:pop`).
86
+ # Read stack operations from left to right.
57
87
  def scope_changes(_line)
58
88
  raise NotImplementedError
59
89
  end
60
90
 
91
+ # @return [true,false]
92
+ # `true` if (and only if) there are no more lines to consume.
61
93
  def empty?
62
94
  @lines.empty?
63
95
  end
64
96
 
65
97
  private
66
98
 
99
+ # Forwards the internal buffer up to the next line that contains anything but whitespace.
100
+ #
101
+ # @return [void]
67
102
  def skip_empty_lines
68
103
  @lines.first
69
104
 
@@ -71,8 +106,12 @@ module LogParser
71
106
  remove_consumed_lines(first_nonempty_line || @lines.buffer_size)
72
107
  end
73
108
 
74
- # TODO: document
109
+ # Reads the log until the next full message, consuming the lines.
110
+ # Assumes that empty lines have already been skipped.
111
+ #
75
112
  # @return [Message,nil]
113
+ # The next message that could be extracted, or `nil` if none could be found.
114
+ # @raise If parsing already finished.
76
115
  def parse_next_lines
77
116
  raise 'Parse already done!' if @lines.empty?
78
117
 
@@ -102,6 +141,9 @@ module LogParser
102
141
  msg
103
142
  end
104
143
 
144
+ # After reading `i` lines, remove them from the internal buffer using this method.
145
+ #
146
+ # @return [void]
105
147
  def remove_consumed_lines(i)
106
148
  @lines.forward(i)
107
149
  @log_line_number += i
@@ -109,7 +151,15 @@ module LogParser
109
151
  @scope_changes_by_line[@log_line_number] = [] if Logger.debug? && i.positive?
110
152
  end
111
153
 
154
+ # Consume as many lines as the given pattern will match.
155
+ # Assumes that `pattern.begins_at?(@lines.first)` is `true`.
156
+ #
157
+ # If applying `pattern` is not successful, this method consumes a single line.
158
+ #
159
+ # @param [Pattern] pattern
160
+ # The pattern to use for matching.
112
161
  # @return [Message,nil]
162
+ # The message `pattern` produced, if any.
113
163
  def consume_pattern(pattern)
114
164
  # Apply the pattern, i.e. read the next message!
115
165
 
@@ -129,6 +179,9 @@ module LogParser
129
179
  return nil
130
180
  end
131
181
 
182
+ # Extracts the scope changes from the current line and applies them to the file stack `@files`.
183
+ #
184
+ # @return [void]
132
185
  def apply_scope_changes
133
186
  # In the hope that scope changes happen not on the same
134
187
  # line as messages. Gulp.
@@ -1,7 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TexLogParser
4
- # TODO: document
4
+ # Matches messages of this form:
5
+ #
6
+ # Overfull \hbox (68.36201pt too wide) in paragraph at lines 33--34
7
+ # []\OT1/cmr/m/n/10 Let's try to for-ce an over-full box: []
8
+ # []
9
+ #
10
+ # and
11
+ #
12
+ # Underfull \hbox (badness 10000) in paragraph at lines 35--36
13
+ #
14
+ # []
5
15
  class BadHboxWarning
6
16
  include LogParser::RegExpPattern
7
17
 
@@ -3,8 +3,8 @@
3
3
  class TexLogParser
4
4
  # Matches messages of this form:
5
5
  #
6
- # ! ==> Fatal error occurred, no output PDF file produced!
7
- # Transcript written on plain.log.
6
+ # ! ==> Fatal error occurred, no output PDF file produced!
7
+ # Transcript written on plain.log.
8
8
  class FatalErrorOccurred
9
9
  include LogParser::RegExpPattern
10
10
 
@@ -7,7 +7,7 @@ class TexLogParser
7
7
  # (tocbasic) because of feature `nobabel' available
8
8
  # (tocbasic) for `toc' on input line 132.
9
9
  #
10
- # Note: currently fails if lines get broken badly, e.g. in 000.log:634.
10
+ # **Note:** Fails to pick up the fill message if lines get broken badly, e.g. in `000_pdf_fl.log:634`.
11
11
  class PrefixedMultiLinePattern
12
12
  include LogParser::RegExpPattern
13
13
 
@@ -4,6 +4,9 @@ require 'log_parser/log_parser'
4
4
  Dir["#{File.expand_path(__dir__)}/tex_log_parser/patterns/*.rb"].each { |p| require p }
5
5
 
6
6
  # Parses logs (and output) of LaTeX interpreters, e.g. `pdflatex`, `xelatex` and `lualatex`.
7
+ # Messages are extracted according to a set of patterns (see below).
8
+ #
9
+ # Instances are single-use; create a new one for every log and parsing run.
7
10
  #
8
11
  # *Note:* Due to shortcomings in the native format of those logs, please be
9
12
  # aware of these recommendations:
@@ -24,7 +27,8 @@ class TexLogParser
24
27
 
25
28
  protected
26
29
 
27
- # (see LogParser#patterns)
30
+ # @return [Array<Pattern>]
31
+ # The set of patterns this parser utilizes to extract messages.
28
32
  def patterns
29
33
  [HighlightedMessages.new,
30
34
  FileLineError.new,
@@ -35,9 +39,15 @@ class TexLogParser
35
39
  BadHboxWarning.new]
36
40
  end
37
41
 
38
- # (see LogParser#scope_changes)
42
+ # Extracts scope changes in the form of stack operations from the given line.
43
+ #
44
+ # @param [String] line
45
+ # @return [Array<String,:pop>]
46
+ # A list of new scopes this line enters (filename strings) and leaves (`:pop`).
47
+ # Read stack operations from left to right.
48
+ #
39
49
  #
40
- # _Implementation note:_ The basic format in LaTeX logs is that
50
+ # *Implementation note:* The basic format in LaTeX logs is that
41
51
  # * `(filename` marks the beginning of messages from that file, and
42
52
  # * the matching `)` marks the end.
43
53
  # Those nest, of course.
@@ -67,6 +77,13 @@ class TexLogParser
67
77
  # Scopes close on a dedicated line, except if they don't (cf 000.log:624)
68
78
  # So we have to continue on the rest of the line. Uh oh.
69
79
  ([:pop] * Regexp.last_match(1).length) + scope_changes(Regexp.last_match(2))
80
+ when /v.*? \d{4}-\d{2}-\d{2}\)(.*)$/
81
+ # Apparently, some nasty packages write their version number in front
82
+ # of the closing parenthesis, despite otherwise adhering to the format.
83
+ # See e.g. `002_pdf_fl.log:12`.
84
+ # This is a fix specifically for that situation -- let's hope that there
85
+ # are not many more similar ones.
86
+ [:pop] + scope_changes(Regexp.last_match(2))
70
87
  when /\([^)]*$/
71
88
  # BROKEN_BY_LINEBREAKS
72
89
  # Bad linebreaks can cause trailing ) to spill over. Narf.
data/lib/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # @attr [String] VERSION
4
4
  # The version of TexLogParser.
5
5
  class TexLogParser
6
- VERSION = '1.0.0.pre.14'
6
+ VERSION = '1.0.0.pre.15'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tex_log_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.14
4
+ version: 1.0.0.pre.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Reitzig
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.16'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: yard
71
85
  requirement: !ruby/object:Gem::Requirement