diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9ab6603..d7cbfa8 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -32,9 +32,7 @@ jobs: pip install -r tools/requirements.txt - name: Docs - run: | - ./tools/schema-merge.py - ./tools/mkdocs build -d site + run: make - name: Setup Pages uses: actions/configure-pages@v4 diff --git a/.github/workflows/test-schema.yml b/.github/workflows/test-schema.yml index 5c5495a..e9c4846 100644 --- a/.github/workflows/test-schema.yml +++ b/.github/workflows/test-schema.yml @@ -15,12 +15,7 @@ jobs: sudo apt update -q sudo apt install -yy python3 python3-pip graphviz pip install -r tools/requirements.txt - - - name: Build - run: | - ./tools/schema-merge.py - ./tools/mkdocs build -d site - name: Validate run: | - ./tools/schema-validate.py --html site/specs + make validate_full diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..476b44b --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +# Executable names +PIP ?= pip +PYTHON ?= python +MKDOCS ?= PYTHONPATH="$(SOURCE_DIR)/tools" mkdocs + +# Paths +SOURCE_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +OUTPUT_DIR ?= $(CURDIR)/site + +.SUFFIXES: +.PHONY: all install_dependencies docs docs_serve lottie.schema.json validate validate_links + + +all: docs + +lottie.schema.json:$(SOURCE_DIR)/docs/lottie.schema.json + +$(SOURCE_DIR)/docs/lottie.schema.json: $(wildcard $(SOURCE_DIR)/schema/**/*.json) +$(SOURCE_DIR)/docs/lottie.schema.json: $(SOURCE_DIR)/tools/schema-merge.py + $(SOURCE_DIR)/tools/schema-merge.py + +docs:$(OUTPUT_DIR)/index.html + +$(OUTPUT_DIR)/index.html:$(wildcard $(SOURCE_DIR)/docs/**/*) +$(OUTPUT_DIR)/index.html:$(SOURCE_DIR)/docs/lottie.schema.json +$(OUTPUT_DIR)/index.html:$(SOURCE_DIR)/tools/lottie_markdown.py + $(MKDOCS) build -f $(SOURCE_DIR)/mkdocs.yml -d $(OUTPUT_DIR) + +docs_serve:$(SOURCE_DIR)/docs/lottie.schema.json + $(MKDOCS) serve -f $(SOURCE_DIR)/mkdocs.yml + +install_dependencies: + $(PIP) install -r $(SOURCE_DIR)/tools/requirements.txt + +validate: $(SOURCE_DIR)/docs/lottie.schema.json + $(SOURCE_DIR)/tools/schema-validate.py + + +validate_full:$(OUTPUT_DIR)/index.html + $(SOURCE_DIR)/tools/schema-validate.py --html $(OUTPUT_DIR)/specs diff --git a/docs/editing/schema.md b/docs/editing/schema.md index a569b7e..3c00817 100644 --- a/docs/editing/schema.md +++ b/docs/editing/schema.md @@ -105,6 +105,34 @@ To build a static HTML site run the following: The output will be in `/site`. +### Makefile + +To simplify the build process, there is a makefile that allows you to +run all the commands above with a single `make` invocation`. + +Follows a list of useful `make` targets: + +```bash +# Installs Python packages +make install_dependencies + +# Builds the schema and docs into HTML +make + +# Equivalent to mkdocs serve +make docs_serve + +# Builds only the combined schema +make lottie.schema.json + +# Runs basic schema validation (without rebuilding the HTML) +make validate + +# Runs the full validation, including building the HTML pages +make validate_full +``` + + ### Schema Validation You can validate schema syntax and internal references using