open5e / open5e-api

The api for open5e.com
Other
150 stars 95 forks source link

Data file formatting #403

Open Sturlen opened 9 months ago

Sturlen commented 9 months ago

The current json file indentation does not appear to be any standard format, which makes it difficult to make a PRs that stick to this format. I've managed to match it by outputting a file with json.dumps(indent=2) and them removing two spaces from each line using lines = [re.sub(r'^ ','', line) for line in lines]

Instead it would be great if we agreed on a standard format and updated the unused scripts/lint_json.py to format files using this.

Kordishal commented 5 months ago

This would be useful yes. The current formatting is generated by the exporter with this line

I am a bit confused why this django serializer creates this weird format for json serialization. It just says indent=2 which should give the same result. Would have to investigate why that is that then adjust it. Because otherwise the export would just be annoying if you have to format the json with an extra script after using the exporter.

augustjohnson commented 1 month ago

Django's code for producing these is here: https://github.com/django/django/blob/main/django/core/serializers/json.py#L21

In addition, v2 will support form data entry using the admin features built into django (on localhost). I think that the data file formats themselves are fine, I would like to see some better input and output formats though. I will say that a trick I've got is that you import in whatever format works (i don't believe whitespace, order, or even field existence matters on import?) and then export it out again. That results in clean files.

I wonder if someone who is experienced writing linters could assist with this? I'm certainly not.