cli/validate: allow exempting certain markers from validation

This commit is contained in:
2026-01-27 16:52:07 +09:00
parent 306d35fb23
commit 7cb7e0c0e7
6 changed files with 98 additions and 15 deletions

View File

@@ -172,6 +172,35 @@ See the other marker sets for inspiration.
4. Add the marker set with a description to this README file.
## Making exceptions for the validation tool
Sometimes, you might want to add a marker that doesn't pass validation.
You can do this by setting the `skip_validation` parameter to `True` when creating the marker.
```python
from lib_marker import Point, Track
MARKERS = [
...,
Point(
name="My Invalid Marker",
x=100,
y=200,
z=300,
skip_validation=True,
),
Track(
name="My Invalid Track",
points=[
(0, 64, 0),
(10000, 64, 10000),
],
skip_validation=True,
),
...,
]
```
## See also
- [BlueMap documentation for markers](https://bluemap.bluecolored.de/wiki/customization/Markers.html)

View File

@@ -8,8 +8,11 @@ from marker_sets import WORLDS
def main() -> None:
result_is_ok = True
worlds_to_be_validated = remove_markers_not_to_be_validated(WORLDS)
for test_name, test_f in _tests.items():
results = test_f(WORLDS)
results = test_f(worlds_to_be_validated)
if len(results) > 0:
result_is_ok = False
print(f"[X] {test_name}")
@@ -87,6 +90,28 @@ class ValidationErrorPoint:
return f"({self.x}, {self.y}, {self.z})"
def remove_markers_not_to_be_validated(
worlds: dict[str, list[MarkerSet]],
) -> dict[str, list[MarkerSet]]:
result = {}
for world_name, marker_sets in worlds.items():
result[world_name] = []
for marker_set in marker_sets:
new_marker_set = MarkerSet(
name=marker_set.name,
show_by_default=marker_set.show_by_default,
markers=[
marker
for marker in marker_set.markers
if not marker.skip_validation
],
)
result[world_name].append(new_marker_set)
return result
def validate_no_non_included_files(
worlds: dict[str, list[MarkerSet]],
) -> list[ValidationError]:

View File

@@ -1,9 +1,17 @@
from dataclasses import dataclass
from .marker import Marker
@dataclass
class Area(Marker):
points: list[tuple[int, int, int]]
icon: str | None = None
def __init__(
self,
name: str,
points: list[tuple[int, int, int]],
icon: str | None = None,
skip_validation: bool = False,
) -> None:
super().__init__(name, skip_validation)
self.points = points
self.icon = icon

View File

@@ -1,8 +1,10 @@
from abc import ABC
from dataclasses import dataclass
@dataclass
class Marker(ABC):
name: str
skip_validation: bool = False
# icon: str | None = None
def __init__(self, name: str, skip_validation: bool = False) -> None:
self.name = name
self.skip_validation = skip_validation

View File

@@ -1,11 +1,23 @@
from dataclasses import dataclass
from .marker import Marker
@dataclass
class Point(Marker):
x: int
y: int
z: int
icon: str | None = None
skip_validation: bool = False
def __init__(
self,
name: str,
x: int,
y: int,
z: int,
icon: str | None = None,
skip_validation: bool = False,
) -> None:
super().__init__(name, skip_validation)
self.x = x
self.y = y
self.z = z
self.icon = icon

View File

@@ -1,9 +1,16 @@
from dataclasses import dataclass
from .marker import Marker
@dataclass
class Track(Marker):
points: list[tuple[int, int, int]]
icon: str | None = None
def __init__(
self,
name: str,
points: list[tuple[int, int, int]],
icon: str | None = None,
skip_validation: bool = False,
) -> None:
super().__init__(name, skip_validation)
self.points = points
self.icon = icon