Skip to content

Commit

Permalink
Merge branch 'develop' into Add-New-Zone-Ideal-Loads-Output-Variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jmythms committed Oct 6, 2020
2 parents 5acf86f + 75fcd72 commit 0bc4fdf
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 93 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/doc-problem-match.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "latex-parser",
"pattern": [
{
"regexp": "^\\[LATEX(WARNING|ERROR)::(.*?):(\\d+)::(.*?)\\]$",
"severity": 1,
"file": 2,
"line": 3,
"message": 4
}
]
}
]
}
5 changes: 4 additions & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:

- name: Configure CMake
working-directory: ${{runner.workspace}}/EnergyPlus/doc/build
run: cmake -DTEX_INTERACTION=batchmode ..
run: cmake -DTEX_INTERACTION=batchmode -DDOCS_TESTING=ON ..

- name: Add problem matcher
run: echo "::add-matcher::.github/workflows/doc-problem-match.json"

- name: Build Docs
working-directory: ${{runner.workspace}}/EnergyPlus/doc/build
Expand Down
133 changes: 53 additions & 80 deletions doc/tools/parse_latex_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,40 +168,6 @@ def find_multiply_defined_labels(root_dir, label):
target = "\\label{" + label + "}"
return find_locations(root_dir, target)


def parse_warning(line, src_dir):
"""
- line: string, the line to parse
- src_dir: string, the root directory of the LaTeX source files
RETURN: None or one of:
- {'type': 'Label multiply defined',
'label': string,
'message': string}
- {'type': 'Hyper reference undefined',
'label': string,
'message': string}
"""
m = LABEL_MULTIPLY_DEFINED_WARN.match(line)
if m is not None:
label = m.group(1)
locations = find_multiply_defined_labels(src_dir, label)
return {'severity': SEVERITY_WARNING,
'type': "Label multiply defined",
'locations': locations,
'message': line,
'label': m.group(1)}
m = HYPER_UNDEFINED_WARN.match(line)
if m is not None:
label = m.group(1)
locations = find_undefined_hyperref(src_dir, label)
return {'severity': SEVERITY_WARNING,
'type': "Hyper reference undefined",
'locations': locations,
'message': line,
'label': m.group(1)}
return None


def parse_line_number(message):
"""
- message: string
Expand Down Expand Up @@ -233,53 +199,68 @@ def __init__(self, log_path, src_dir, verbose=False):
self.src_dir = src_dir
self.verbose = verbose

def _read_tex_error(self, line):
def _read_tex_error(self):
line_no = parse_line_number(self._current_issue)
self._issues['issues'].append({
'severity': SEVERITY_ERROR,
'level': SEVERITY_ERROR,
'type': self._type,
'locations': [{
'file': self._current_tex_file,
'line': line_no}],
'path': self._current_tex_file,
'line': {"start": line_no, "end": line_no},
'message': self._current_issue.strip()})

def _read_warning(self, line):
warn = parse_warning(self._current_issue, self.src_dir)
if self._current_issue.strip() not in ISSUES_TO_SKIP:
if warn is not None:
self._issues['issues'].append(warn)
else:
line_no = parse_on_input_line(self._current_issue)
self._issues['issues'].append({
'severity': SEVERITY_WARNING,
'type': self._type,
'locations': [{
'file': self._current_tex_file,
'line': line_no}],
'message': self._current_issue.strip()})

def _read_error(self, line):
if self._current_issue not in ISSUES_TO_SKIP:
def _read_warning(self):
warns = []
m1 = LABEL_MULTIPLY_DEFINED_WARN.match(self._current_issue)
m2 = HYPER_UNDEFINED_WARN.match(self._current_issue)
if m1 is not None:
label = m1.group(1)
locations = find_multiply_defined_labels(self.src_dir, label)
for loc in locations:
warns.append({
'level': SEVERITY_WARNING,
'type': "Label multiply defined",
'path': loc["file"],
'line': {"start": loc["line"], "end": loc["line"]},
'message': self._current_issue.strip(),
'label': m1.group(1)
})
elif m2 is not None:
label = m2.group(1)
locations = find_undefined_hyperref(self.src_dir, label)
for loc in locations:
warns.append({
'level': SEVERITY_WARNING,
'type': "Hyper reference undefined",
'path': loc["file"],
'line': {"start": loc["line"], "end": loc["line"]},
'message': self._current_issue.strip(),
'label': m2.group(1)
})
elif self._current_issue.strip() not in ISSUES_TO_SKIP:
line_no = parse_on_input_line(self._current_issue)
self._issues['issues'].append({
'severity': SEVERITY_ERROR,
warns = [{
'level': SEVERITY_WARNING,
'type': self._type,
'locations': [{
'file': self._current_tex_file,
'line': line_no}],
'message': self._current_issue.strip()})
'path': self._current_tex_file,
'line': {"start": line_no, "end": line_no},
'message': self._current_issue.strip()}]
self._issues['issues'] += warns

def _read_error(self):
if self._current_issue not in ISSUES_TO_SKIP:
self._read_tex_error()

def _read_issue(self, line):
is_ws = (line.strip() == "")
first_line = (self._issue_line == 1)
nonempty = len(line) > 1
if is_ws and (not (first_line and nonempty)):
if self._in_tex_err:
self._read_tex_error(line)
self._read_tex_error()
elif self._in_warn:
self._read_warning(line)
self._read_warning()
elif self._in_err:
self._read_error(line)
self._read_error()
else:
raise Exception("unhandled issue read")
self._reset_after_read()
Expand Down Expand Up @@ -388,16 +369,10 @@ def update_paths_to_be_from_repo_root(issues, repo_root_to_src):
updated = []
for issue in issues:
update = copy.deepcopy(issue)
if 'locations' in update:
new_locs = []
for location in update['locations']:
loc = copy.deepcopy(location)
if 'file' in location:
loc['file'] = os.path.join(
repo_root_to_src,
location['file'])
new_locs.append(loc)
update['locations'] = new_locs
if 'path' in update:
update['path'] = os.path.join(
repo_root_to_src,
update['path'])
updated.append(update)
return updated

Expand Down Expand Up @@ -440,16 +415,14 @@ def find_issues(log_path, json_error_path, src_dir):
f = sys.stdout
for issue in errs['issues']:
f.write("[LATEX")
f.write(issue['severity'] + "::")
locs = [loc['file'] + ":" + str(loc['line'])
for loc in issue['locations']]
f.write(",".join(locs) + "::")
f.write(issue['level'] + "::")
f.write(issue['path'] + ":" + str(issue["line"]["start"]))
msg = issue['message'].replace("\r\n", " ")
msg = msg.replace("\n", " ")
msg = msg.replace("\r", " ")
msg = msg.replace("\t", " ")
msg = " ".join(msg.split())
f.write(msg + "]\n")
f.write("::" + msg + "]\n")
with open(json_error_path, 'w', encoding='utf-8') as f:
json.dump(errs, f, ensure_ascii=False, indent=4)
return (num_issues > 0)
Expand Down
5 changes: 3 additions & 2 deletions third_party/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ kiva-ep/README.md

# submodules
penumbra/.gitmodules
btwxt/.gitmodules

# unused btwxt repo directories/files
# unused repo directories/files
btwxt/vendor/googletest
btwxt/.gitmodules
penumbra/vendor/googletest
9 changes: 0 additions & 9 deletions third_party/penumbra/.gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion third_party/penumbra/vendor/googletest
Submodule googletest deleted from 2fe3bd

0 comments on commit 0bc4fdf

Please sign in to comment.