Skip to content

Commit

Permalink
Add documentation for TOML modules (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot authored Jan 16, 2024
1 parent a6c4ddb commit d399497
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion docs/sync-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This page aims to describe how Rojo turns files on the filesystem into Roblox ob
| [Localization Tables](#localization-tables) | `*.csv` |
| [Plain Text](#plain-text) | `*.txt` |
| [JSON Modules](#json-modules) | `*.json` |
| [TOML Modules](#toml-modules) | `*.toml` |
| [JSON Models](#json-models) | `*.model.json` |
| [Projects](#projects) | `*.project.json` |
| [Meta Files](#meta-files) | `*.meta.json` |
Expand Down Expand Up @@ -109,7 +110,39 @@ Any file with the `txt` extension is transformed into a `StringValue` instance.

## JSON Modules

Any file with the `json` extension that is not a [JSON Model](#json-models) or a [Project File](#project-file)
Any file with the `json` extension that is not a [JSON Model](#json-models) or a [Project File](#project-file) will be synced as a `ModuleScript` that returns a table representing the same structure as the JSON file. That is, the following JSON:

```json
{
"Hello": "world!",
"bool": true,
"array": [1, 2, 3],
"object": {
"key 1": 1337,
"key 2": []
}
}
```

Would become a `ModuleScript` with the following `Source`:
```lua
return {
Hello = "world!",
array = {1, 2, 3},
bool = true,
object = {
["key 1"] = 1337,
["key 2"] = {},
},
}
```


## TOML Modules

Any file with the `toml` extension will be synced as a `ModuleScript` that returns a table representing the same structure as the TOML file. Due to the easy to read and edit format of TOML, it can be convenient to use them as config files. For a better idea of what synced `toml` files look like, see [JSON Modules](#json-modules).

There is a single limitation for TOML syncing: `DateTime` values are converted into `string` values and not the corresponding data type. This is due to the conflicting formats used between them. This is not something most people should have to worry about, but it's still something to be aware of.

## JSON Models

Expand Down

0 comments on commit d399497

Please sign in to comment.