-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (69 loc) · 2.51 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Directory of YAML files
YAML_DIR = ./yaml
# Directory of bundled YAML files
BUNDLED_DIR = ./_bundled
# Output directory
DOCS_DIR = ./docs
# List of all YAML files
YAML_FILES := $(wildcard $(YAML_DIR)/*.yaml)
# Set of top-level files containing OpenAPI specifications
OPENAPI_FILES := $(shell grep -rl "openapi:" $(YAML_DIR)/*.yaml)
# Files generated by bundling top-level files
BUNDLED_FILES := $(patsubst $(YAML_DIR)/%.yaml, $(BUNDLED_DIR)/%.yaml, $(OPENAPI_FILES))
# Files generated by running redocly on bundled files
HTML_FILES := $(patsubst $(YAML_DIR)/%.yaml, $(DOCS_DIR)/%.html, $(OPENAPI_FILES))
# Path to redocly
REDOCLY := node_modules/.bin/redocly
# Default target
all: bundled docs indexpage
.PHONY: all
################################################################################
# Initialization
################################################################################
clone-nena-repos:
./clone-nena-repos.sh
update-nena-repos:
./update-nena-repos.sh
copy-yaml-files:
mkdir -p yaml/
find NENA911/ -iname "*.yaml" -exec cp {} yaml/ \;
initialize: clone-nena-repos copy-yaml-files
.PHONY: clone-nena-repos update-nena-repos copy-yaml-files initialize
################################################################################
# Show shell-defined variables
################################################################################
show-openapi:
@echo $(OPENAPI_FILES)
show-bundled:
@echo $(BUNDLED_FILES)
show-docs:
@echo $(HTML_FILES)
.PHONY: show-openapi show-bundled show-docs
################################################################################
# Generate bundled OpenAPI files and HTML documentation
################################################################################
# Generate all bundled files
bundled: $(BUNDLED_FILES)
$(BUNDLED_DIR)/%.yaml: $(YAML_DIR)/%.yaml
@echo "Bundling $< into $@"
$(REDOCLY) bundle $< --output $@
# Generate all HTML documentation
docs: $(HTML_FILES)
$(DOCS_DIR)/%.html: $(BUNDLED_DIR)/%.yaml
@echo "Generating HTML docs for $< into $@"
$(REDOCLY) build-docs $< --output $@
# Generate top-level index.html
# Rule to generate the index.html file
$(DOCS_DIR)/index.html: index.mustache generate_index.js
@echo "Generating index.html with Mustache..."
node generate_index.js
@echo "index.html created successfully."
indexpage: $(DOCS_DIR)/index.html
# Clean up generated files
clean:
@echo "Cleaning up generated files..."
rm -Rf $(BUNDLED_DIR)
rm -Rf $(DOCS_DIR)
nuke: clean
rm -Rf $(YAML_DIR)
.PHONY: bundled docs indexpage clean nuke