Skip to content

Commit 0238def

Browse files
committed
Switch developer guide linting to asciidoctor-lint
1 parent b3f57dd commit 0238def

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

.github/workflows/developer-guide-docs.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,41 +82,28 @@ jobs:
8282
with:
8383
ruby-version: '3.1'
8484

85-
- name: Set up Java for docToolchain
86-
uses: actions/setup-java@v4
87-
with:
88-
distribution: temurin
89-
java-version: '17'
90-
9185
- name: Install Asciidoctor tooling
9286
run: |
93-
gem install --no-document asciidoctor asciidoctor-pdf
87+
gem install --no-document asciidoctor asciidoctor-pdf asciidoctor-lint
9488
95-
- name: Download docToolchain
96-
run: |
97-
set -euo pipefail
98-
DT_VERSION="3.4.2"
99-
DT_ROOT="${RUNNER_TEMP}/doctoolchain"
100-
mkdir -p "$DT_ROOT"
101-
curl -fsSL -o "$DT_ROOT/doctoolchain.zip" "https://github.com/docToolchain/docToolchain/releases/download/v${DT_VERSION}/docToolchain-${DT_VERSION}.zip"
102-
unzip -q "$DT_ROOT/doctoolchain.zip" -d "$DT_ROOT"
103-
DOC_TOOLCHAIN_HOME="$DT_ROOT/docToolchain-${DT_VERSION}"
104-
echo "DOC_TOOLCHAIN_HOME=$DOC_TOOLCHAIN_HOME" >> "$GITHUB_ENV"
105-
106-
- name: Run docToolchain AsciiDoc linter
89+
- name: Run Asciidoctor lint
10790
run: |
10891
set -euo pipefail
10992
REPORT_DIR="build/developer-guide/reports"
11093
REPORT_FILE="${REPORT_DIR}/asciidoc-lint-report.txt"
11194
mkdir -p "$REPORT_DIR"
95+
if ! command -v asciidoctor-lint >/dev/null 2>&1; then
96+
echo "asciidoctor-lint is not available" >&2
97+
exit 1
98+
fi
11299
set +e
113-
"$DOC_TOOLCHAIN_HOME/bin/doctoolchain" docs/developer-guide asciidocLint | tee "$REPORT_FILE"
100+
asciidoctor-lint docs/developer-guide/developer-guide.asciidoc | tee "$REPORT_FILE"
114101
STATUS=${PIPESTATUS[0]}
115102
set -e
116103
echo "ASCII_DOC_LINT_REPORT=$REPORT_FILE" >> "$GITHUB_ENV"
117104
echo "ASCII_DOC_LINT_STATUS=$STATUS" >> "$GITHUB_ENV"
118105
if [ "$STATUS" -ne 0 ]; then
119-
echo "docToolchain AsciiDoc linter exited with status $STATUS" >&2
106+
echo "asciidoctor-lint exited with status $STATUS" >&2
120107
fi
121108
122109
- name: Build Developer Guide HTML and PDF

scripts/developer-guide/summarize_reports.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,30 @@ def summarize_asciidoc(report: Path, status: str, summary_key: str, output: Path
7979
text = ""
8080
if report.is_file():
8181
text = report.read_text(encoding="utf-8", errors="ignore")
82-
issues = re.findall(r"\b(?:WARN|ERROR|SEVERE)\b", text)
8382

84-
if issues:
85-
summary = f"{len(issues)} issue(s) flagged"
83+
pattern = re.compile(r"^\s*[^:\n]+:\d+:\d+:\s+(ERROR|WARN(?:ING)?|INFO)\b", re.MULTILINE)
84+
matches = pattern.findall(text)
85+
86+
counts = {"error": 0, "warning": 0, "info": 0}
87+
for severity in matches:
88+
normalized = severity.upper()
89+
if normalized == "ERROR":
90+
counts["error"] += 1
91+
elif normalized in {"WARN", "WARNING"}:
92+
counts["warning"] += 1
93+
elif normalized == "INFO":
94+
counts["info"] += 1
95+
96+
total = sum(counts.values())
97+
98+
if total:
99+
parts = [f"{counts['error']} errors"] if counts["error"] else []
100+
if counts["warning"]:
101+
parts.append(f"{counts['warning']} warnings")
102+
if counts["info"]:
103+
parts.append(f"{counts['info']} info")
104+
detail = f" ({', '.join(parts)})" if parts else ""
105+
summary = f"{total} issue(s) flagged{detail}"
86106
if _has_nonzero_status(status):
87107
summary += f" (exit code {_normalize_status(status)})"
88108
elif _has_nonzero_status(status):
@@ -162,7 +182,7 @@ def summarize_unused_images(
162182

163183
output_lines = [f"{summary_key}={summary}"]
164184
if details_key and lines:
165-
details_value = "\\n".join(lines)
185+
details_value = "\n".join(lines)
166186
output_lines.append(f"{details_key}={details_value}")
167187

168188
write_output(output_lines, output)

0 commit comments

Comments
 (0)