A lot of examples in the documentation are out of date. I feel like doc tests would trivially catch these.
Some examples:
Unfortunately, data packs and resource packs aren't limited to neatly namespaced files and can contain extra files at the pack level and at the namespace level. Still, the beet library handles extra files as first-class citizens. In fact, pack.mcmeta and pack.png are both handled through this mechanism.
from beet import JsonFile
pack = DataPack()
pack.extra == {
"pack.mcmeta": JsonFile({"pack": {"description": "", "pack_format": 6}})
}
This one's a bit more exciting (...if you consider an attribute change a more 'exciting' flavor of API breakage):
Because all the data stored in data packs is ultimately represented by file instances, beet can implement a very straight-forward merging strategy that lets conflicting files decide if they should overwrite or merge with existing ones. For example, tag files will be merged together.
p1 = DataPack()
p1["demo:foo"] = Function(["say hello"], tags=["minecraft:tick"])
p2 = DataPack()
p2["demo:bar"] = Function(["say world"], tags=["minecraft:tick"])
p1.merge(p2)
dict(p1.content) == {
"demo:foo": Function(["say hello"]),
"demo:bar": Function(["say world"]),
"minecraft:tick": FunctionTag({"values": ["demo:foo", "demo:bar"]}),
}
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[20], line 9
5 p2["demo:bar"] = Function(["say world"], tags=["minecraft:tick"])
7 p1.merge(p2)
----> 9 dict(p1.content) == {
10 "demo:foo": Function(["say hello"]),
11 "demo:bar": Function(["say world"]),
12 "minecraft:tick": FunctionTag({"values": ["demo:foo", "demo:bar"]}),
13 }
AttributeError: 'DataPack' object has no attribute 'content'
A lot of examples in the documentation are out of date. I feel like doc tests would trivially catch these.
Some examples:
This one's a bit more exciting (...if you consider an attribute change a more 'exciting' flavor of API breakage):