mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-25 06:01:02 +03:00
feat(validate): brief output by default, -Detailed for verbose
All 10 validation skills (meta, epf, skd, cf, cfe, form, mxl, role, subsystem, interface) now output a single summary line on success: === Validation OK: Type.Name (N checks) === Errors/warnings always shown. Full per-check [OK] output behind -Detailed flag. Removed all N/A check lines. Unified role-validate output format. Trimmed SKILL.md files from 42-119 to 51-67 lines. Version bumps: meta-validate v1.2, all others v1.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
93e4130ff2
commit
422e397381
@@ -1,10 +1,11 @@
|
||||
# mxl-validate v1.0 — Validate 1C spreadsheet
|
||||
# mxl-validate v1.1 — Validate 1C spreadsheet
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$TemplatePath,
|
||||
[string]$ProcessorName,
|
||||
[string]$TemplateName,
|
||||
[string]$SrcDir = "src",
|
||||
[switch]$Detailed,
|
||||
[int]$MaxErrors = 20
|
||||
)
|
||||
|
||||
@@ -44,10 +45,12 @@ $root = $xmlDoc.DocumentElement
|
||||
$errors = 0
|
||||
$warnings = 0
|
||||
$stopped = $false
|
||||
$script:okCount = 0
|
||||
|
||||
function Report-OK {
|
||||
param([string]$msg)
|
||||
Write-Host "[OK] $msg"
|
||||
$script:okCount++
|
||||
if ($Detailed) { Write-Host "[OK] $msg" }
|
||||
}
|
||||
|
||||
function Report-Error {
|
||||
@@ -66,8 +69,10 @@ function Report-Warn {
|
||||
}
|
||||
|
||||
$templateName = [System.IO.Path]::GetFileName([System.IO.Path]::GetDirectoryName([System.IO.Path]::GetDirectoryName($TemplatePath)))
|
||||
Write-Host "=== Validation: $templateName ==="
|
||||
Write-Host ""
|
||||
if ($Detailed) {
|
||||
Write-Host "=== Validation: $templateName ==="
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# --- Collect palettes ---
|
||||
|
||||
@@ -376,18 +381,18 @@ foreach ($drawing in $root.SelectNodes("d:drawing", $nsMgr)) {
|
||||
|
||||
# --- Summary ---
|
||||
|
||||
# :finish label equivalent
|
||||
Write-Host ""
|
||||
Write-Host "---"
|
||||
$checks = $script:okCount + $errors + $warnings
|
||||
|
||||
if ($stopped) {
|
||||
Write-Host "Stopped after $MaxErrors errors. Fix and re-run."
|
||||
}
|
||||
|
||||
if ($errors -eq 0 -and $warnings -eq 0) {
|
||||
Write-Host "All checks passed."
|
||||
if ($errors -eq 0 -and $warnings -eq 0 -and -not $Detailed) {
|
||||
Write-Host "=== Validation OK: Template.$templateName ($checks checks) ==="
|
||||
} else {
|
||||
Write-Host "Errors: $errors, Warnings: $warnings"
|
||||
Write-Host ""
|
||||
|
||||
if ($stopped) {
|
||||
Write-Host "Stopped after $MaxErrors errors. Fix and re-run."
|
||||
}
|
||||
|
||||
Write-Host "=== Result: $errors errors, $warnings warnings ($checks checks) ==="
|
||||
}
|
||||
|
||||
if ($errors -gt 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# mxl-validate v1.0 — Validate 1C spreadsheet document Template.xml
|
||||
# mxl-validate v1.1 — Validate 1C spreadsheet document Template.xml
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
"""Validates spreadsheet Template.xml: height, palette refs, column/row indices, areas, merges."""
|
||||
import sys, os, argparse
|
||||
@@ -17,24 +17,29 @@ NS = {
|
||||
|
||||
|
||||
class Reporter:
|
||||
def __init__(self, max_errors):
|
||||
def __init__(self, max_errors, detailed=False):
|
||||
self.errors = 0
|
||||
self.warnings = 0
|
||||
self.ok_count = 0
|
||||
self.stopped = False
|
||||
self.max_errors = max_errors
|
||||
self.detailed = detailed
|
||||
self.lines = []
|
||||
|
||||
def ok(self, msg):
|
||||
print(f'[OK] {msg}')
|
||||
self.ok_count += 1
|
||||
if self.detailed:
|
||||
self.lines.append(f'[OK] {msg}')
|
||||
|
||||
def error(self, msg):
|
||||
self.errors += 1
|
||||
print(f'[ERROR] {msg}')
|
||||
self.lines.append(f'[ERROR] {msg}')
|
||||
if self.errors >= self.max_errors:
|
||||
self.stopped = True
|
||||
|
||||
def warn(self, msg):
|
||||
self.warnings += 1
|
||||
print(f'[WARN] {msg}')
|
||||
self.lines.append(f'[WARN] {msg}')
|
||||
|
||||
|
||||
def int_text(node):
|
||||
@@ -54,6 +59,7 @@ def main():
|
||||
parser.add_argument('-ProcessorName', dest='ProcessorName', default='')
|
||||
parser.add_argument('-TemplateName', dest='TemplateName', default='')
|
||||
parser.add_argument('-SrcDir', dest='SrcDir', default='src')
|
||||
parser.add_argument('-Detailed', action='store_true')
|
||||
parser.add_argument('-MaxErrors', dest='MaxErrors', type=int, default=20)
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -61,6 +67,7 @@ def main():
|
||||
processor_name = args.ProcessorName
|
||||
template_name_arg = args.TemplateName
|
||||
src_dir = args.SrcDir
|
||||
detailed = args.Detailed
|
||||
max_errors = args.MaxErrors
|
||||
|
||||
# --- Resolve template path ---
|
||||
@@ -85,13 +92,13 @@ def main():
|
||||
xml_doc = etree.parse(resolved_path, xml_parser)
|
||||
root = xml_doc.getroot()
|
||||
|
||||
r = Reporter(max_errors)
|
||||
r = Reporter(max_errors, detailed)
|
||||
|
||||
# Derive template name from path: .../Templates/<Name>/Ext/Template.xml
|
||||
# Go up 2 levels from Template.xml -> Ext -> <Name>
|
||||
template_display_name = os.path.basename(os.path.dirname(os.path.dirname(resolved_path)))
|
||||
print(f'=== Validation: {template_display_name} ===')
|
||||
print()
|
||||
r.lines.append(f'=== Validation: Template.{template_display_name} ===')
|
||||
r.lines.append('')
|
||||
|
||||
# --- Collect palettes ---
|
||||
line_nodes = root.findall(f'{{{NS_D}}}line')
|
||||
@@ -176,8 +183,7 @@ def main():
|
||||
r.error(f'Font index {max_font_ref} exceeds palette size ({font_count})')
|
||||
elif max_font_ref > 0:
|
||||
r.error(f'Font index {max_font_ref} referenced but no fonts defined')
|
||||
else:
|
||||
r.ok('No font references')
|
||||
# No font references — no check needed
|
||||
|
||||
# --- Check 11: line/border indices in formats ---
|
||||
if line_count > 0:
|
||||
@@ -187,8 +193,7 @@ def main():
|
||||
r.error(f'Line index {max_line_ref} exceeds palette size ({line_count})')
|
||||
elif max_line_ref > 0:
|
||||
r.error(f'Line index {max_line_ref} referenced but no lines defined')
|
||||
else:
|
||||
r.ok('No line/border references')
|
||||
# No line/border references — no check needed
|
||||
|
||||
# --- Check 3, 4, 5, 6: row/cell checks ---
|
||||
max_cell_format_ref = 0
|
||||
@@ -348,17 +353,16 @@ def main():
|
||||
draw_id = draw_id_node.text if draw_id_node is not None else '?'
|
||||
r.error(f'Drawing id={draw_id}: pictureIndex={pic_idx} > picture count ({picture_count})')
|
||||
|
||||
# --- Summary ---
|
||||
print()
|
||||
print('---')
|
||||
|
||||
if r.stopped:
|
||||
print(f'Stopped after {max_errors} errors. Fix and re-run.')
|
||||
|
||||
if r.errors == 0 and r.warnings == 0:
|
||||
print('All checks passed.')
|
||||
# --- Finalize ---
|
||||
checks = r.ok_count + r.errors + r.warnings
|
||||
if r.errors == 0 and r.warnings == 0 and not detailed:
|
||||
result = f'=== Validation OK: Template.{template_display_name} ({checks} checks) ==='
|
||||
else:
|
||||
print(f'Errors: {r.errors}, Warnings: {r.warnings}')
|
||||
r.lines.append('')
|
||||
r.lines.append(f'=== Result: {r.errors} errors, {r.warnings} warnings ({checks} checks) ===')
|
||||
result = '\n'.join(r.lines)
|
||||
|
||||
print(result)
|
||||
|
||||
sys.exit(1 if r.errors > 0 else 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user