Skip to content

Commit

Permalink
Basic pages for all the schema objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mbasaglia committed Dec 14, 2023
1 parent 3298a52 commit 1997451
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 2 deletions.
44 changes: 44 additions & 0 deletions docs/specs/helpers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Helpers

## Int Boolean

{schema_string:helpers/int-boolean/description}

{schema_object:helpers/int-boolean}


## {schema_string:helpers/transform/title}

{schema_string:helpers/transform/description}

{schema_object:helpers/transform}


## {schema_string:helpers/visual-object/title}

{schema_string:helpers/visual-object/description}

{schema_object:helpers/visual-object}


## {schema_string:helpers/color/title}

{schema_string:helpers/color/description}

{schema_object:helpers/color}


## {schema_string:helpers/marker/title}

{schema_string:helpers/marker/description}

{schema_object:helpers/marker}


## {schema_string:helpers/bezier/title}

{schema_string:helpers/bezier/description}

{schema_object:helpers/bezier}


84 changes: 84 additions & 0 deletions docs/specs/properties.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Properties

## Introduction

### Base Keyframe

{schema_string:properties/base-keyframe/description}

{schema_object:properties/base-keyframe}

### Easing Handle

{schema_string:properties/easing-handle/description}

{schema_object:properties/easing-handle}

## Property types


### {schema_string:properties/multi-dimensional/title}

{schema_string:properties/multi-dimensional/description}

{schema_object:properties/multi-dimensional}


#### {schema_string:properties/vector-keyframe/title}

{schema_string:properties/vector-keyframe/description}

{schema_object:properties/vector-keyframe}
EXPAND:#/$defs/properties/base-keyframe


### {schema_string:properties/value/title}

{schema_string:properties/value/description}

{schema_object:properties/value}


### Position

{schema_string:properties/position/description}

{schema_object:properties/position}


#### {schema_string:properties/position-keyframe/title}

{schema_string:properties/position-keyframe/description}

{schema_object:properties/position-keyframe}
EXPAND:#/$defs/properties/base-keyframe


### {schema_string:properties/shape-property/title}

{schema_string:properties/shape-property/description}

{schema_object:properties/shape-property}


#### {schema_string:properties/shape-keyframe/title}

{schema_string:properties/shape-keyframe/description}

{schema_object:properties/shape-keyframe}
EXPAND:#/$defs/properties/base-keyframe

### {schema_string:properties/color-value/title}

{schema_string:properties/color-value/description}

{schema_object:properties/color-value}


#### {schema_string:properties/color-keyframe/title}

{schema_string:properties/color-keyframe/description}

{schema_object:properties/color-keyframe}
EXPAND:#/$defs/properties/base-keyframe

92 changes: 92 additions & 0 deletions docs/specs/shapes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Shapes

The shape objects are divided in 4 categories:

* [Raw Shapes](#raw-shapes) that define the actual curves but have no styling information
* [Grouping](#grouping), used to organize collections of shape elements
* [Styles](#styles), that define the visual appearance of raw shapes
* [Modifiers](#modifiers) alter the curves of the raw shapes

## {schema_string:shapes/shape-element/title}

{schema_string:shapes/shape-element/description}

{schema_object:shapes/shape-element}

The `ty` property defines the specific element type based on the following values:

{schema_subtype_table:shapes/all-shapes:ty}


## Raw Shapes

### {schema_string:shapes/shape/title}

{schema_string:shapes/shape/description}

{schema_object:shapes/shape}


### {schema_string:shapes/ellipse/title}

{schema_string:shapes/ellipse/description}

{schema_object:shapes/ellipse}


### {schema_string:shapes/path/title}

{schema_string:shapes/path/description}

{schema_object:shapes/path}


### {schema_string:shapes/rectangle/title}

{schema_string:shapes/rectangle/description}

{schema_object:shapes/rectangle}

## Grouping

### {schema_string:shapes/group/title}

{schema_string:shapes/group/description}

{schema_object:shapes/group}

### Transform

{schema_string:shapes/transform/description}

{schema_object:shapes/transform}

## Styles

### {schema_string:shapes/fill/title}

{schema_string:shapes/fill/description}

{schema_object:shapes/fill}


## Modifiers

### {schema_string:shapes/modifier/title}

{schema_string:shapes/modifier/description}

{schema_object:shapes/modifier}

### {schema_string:shapes/trim-path/title}

{schema_string:shapes/trim-path/description}

{schema_object:shapes/trim-path}


### {schema_string:shapes/shape-style/title}

{schema_string:shapes/shape-style/description}

{schema_object:shapes/shape-style}
1 change: 1 addition & 0 deletions schema/shapes/modifier.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"title": "Modifier",
"description": "Modifiers change the bezier curves of neighbouring shapes",
"allOf": [
{
"$ref": "#/$defs/shapes/shape-element"
Expand Down
1 change: 1 addition & 0 deletions schema/shapes/shape-style.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"title": "Shape Style",
"description": "Describes the style (like fill and stroke) of neighbouring shapes",
"allOf": [
{
"$ref": "#/$defs/shapes/shape-element"
Expand Down
2 changes: 1 addition & 1 deletion schema/shapes/shape.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"title": "Shape",
"description": "Drawable shape",
"description": "Drawable shape, defines the actual shape but not the style",
"allOf": [
{
"$ref": "#/$defs/shapes/shape-element"
Expand Down
36 changes: 36 additions & 0 deletions tools/docs-generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
import pathlib
import argparse
from schema_tools.schema import SchemaPath, Schema


def print_object(obj: Schema):
path = "/".join(obj.path.chunks[1:])
print("## {schema_string:%s/title}\n" % path)
print("{schema_string:%s/description}\n" % path)
print("{schema_object:%s}\n\n" % path)


root = pathlib.Path(__file__).absolute().parent.parent

parser = argparse.ArgumentParser()
parser.add_argument(
"--schema",
help="Schema file",
type=pathlib.Path,
default=root / "docs" / "lottie.schema.json"
)
parser.add_argument(
"path",
help="Schema path",
type=SchemaPath,
)
args = parser.parse_args()

schema = Schema.load(args.schema).get_ref(args.path)

if "type" in schema:
print_object(schema)
else:
for v in schema:
print_object(v)
9 changes: 9 additions & 0 deletions tools/lottie_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ def _add_properties(self, schema_props, prop_dict):

prop_dict[name] = SchemaProperty(**data)

def _conditional_properties(self, object, prop_dict, base_list):
if "if" in object:
self._object_properties(object["then"], prop_dict, base_list)
if "else" in object:
self._object_properties(object["else"], prop_dict, base_list)

def _object_properties(self, object, prop_dict, base_list):
if "properties" in object:
self._add_properties(object["properties"], prop_dict)
Expand All @@ -309,6 +315,9 @@ def _object_properties(self, object, prop_dict, base_list):
self._add_properties(chunk["properties"], prop_dict)
elif "$ref" in chunk:
base_list.append(chunk["$ref"])
self._conditional_properties(chunk, prop_dict, base_list)

self._conditional_properties(object, prop_dict, base_list)

def _base_link(self, parent, ref):
link = ref_links(ref, self.schema_data)[0]
Expand Down
9 changes: 8 additions & 1 deletion tools/schema_tools/schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import pathlib


class SchemaPath:
Expand Down Expand Up @@ -96,3 +95,11 @@ def items(self):

def child(self, key):
return Schema(SchemaPath.step(self.schema, key), self.path / key)

@classmethod
def load(cls, file):
if hasattr(file, "read"):
return cls(json.load(file))

with open(file, "r") as f:
return cls(json.load(f))

0 comments on commit 1997451

Please sign in to comment.