1.5.6 • Published 11 months ago
protodef-yaml v1.5.6
protodef-yaml
Transforms YAML-like syntax to ProtoDef JSON schema and HTML documentation.
Usage
npm install -g protodef-yaml
protodef-yaml <input yaml file> <output json file> # generate json
protodef-yaml <input yaml file> <output html file> # generate docsor through npx,
npx protodef-yaml input.yml
npx protodef-yaml input.yml docs.htmlAPI
See API.md
Syntax
Refer to this documentation, also see test/ for example files
Example input:
ScoreEntries:
   type: u8 =>
      0: change
      1: remove
   entries: []varint
      scoreboard_id: zigzag64
      objective_name: string
      score: li32
      _: type?
         if remove:
            entry_type: i8 =>
               1: player
               2: entity
               3: fake_player
            _: entry_type?
               if player or entity:
                  entity_unique_id: zigzag64
               if fake_player:
                  custom_name: stringOutput
{
  "ScoreEntries": [
    "container",
    [
      {
        "name": "type",
        "type": [
          "mapper",
          {
            "type": "u8",
            "mappings": {
              "0": "change",
              "1": "remove"
            }
          }
        ]
      },
      {
        "name": "entries",
        "type": [
          "array",
          {
            "countType": "varint",
            "type": [
              "container",
              [
                {
                  "name": "scoreboard_id",
                  "type": "zigzag64"
                },
                {
                  "name": "objective_name",
                  "type": "string"
                },
                {
                  "name": "score",
                  "type": "li32"
                },
                {
                  "anon": true,
                  "type": [
                    "switch",
                    {
                      "compareTo": "../type",
                      "fields": {
                        "remove": [
                          "container",
                          [
                            {
                              "name": "entry_type",
                              "type": [
                                "mapper",
                                {
                                  "type": "i8",
                                  "mappings": {
                                    "1": "player",
                                    "2": "entity",
                                    "3": "fake_player"
                                  }
                                }
                              ]
                            },
                            {
                              "anon": true,
                              "type": [
                                "switch",
                                {
                                  "compareTo": "entry_type",
                                  "fields": {
                                    "player": [
                                      "container",
                                      [
                                        {
                                          "name": "entity_unique_id",
                                          "type": "zigzag64"
                                        }
                                      ]
                                    ],
                                    "entity": [
                                      "container",
                                      [
                                        {
                                          "name": "entity_unique_id",
                                          "type": "zigzag64"
                                        }
                                      ]
                                    ],
                                    "fake_player": [
                                      "container",
                                      [
                                        {
                                          "name": "custom_name",
                                          "type": "string"
                                        }
                                      ]
                                    ]
                                  },
                                  "default": "void"
                                }
                              ]
                            }
                          ]
                        ]
                      },
                      "default": "void"
                    }
                  ]
                }
              ]
            ]
          }
        ]
      }
    ]
  ]
}Info
The differences to YAML:
- parent nodes with children can have a value
 - keys starting with '!' are ignored in the final output
 
You can also embed JSON for custom ProtoDef types as usual, for example:
string: ["pstring", {"countType": "i32"}]Note: the parser only supports this at a root level. To use nested json inside yaml, you can encapsulate a JSON array with a single quote. For example:
SomeType:
   some_string: '["pstring", {"countType": "i32"}]'1.5.5
11 months ago
1.5.6
11 months ago
1.5.4
1 year ago
1.5.3
1 year ago
1.5.2
1 year ago
1.5.1
1 year ago
1.5.0
1 year ago
1.4.0
2 years ago
1.2.5
4 years ago
1.3.0
4 years ago
1.2.4
4 years ago
1.2.0
4 years ago
1.2.2
4 years ago
1.2.1
4 years ago
1.1.0
4 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago