|
| 1 | +# ============================================================================== |
| 2 | +# TYPO3 Documentation - Makefile |
| 3 | +# ============================================================================== |
| 4 | +# Run `make` or `make help` to see available commands |
| 5 | +# |
| 6 | +# Prerequisites: |
| 7 | +# - Docker (for docs rendering) |
| 8 | +# - DDEV (for code generation tasks) |
| 9 | +# ============================================================================== |
| 10 | + |
| 11 | +# ------------------------------------------------------------------------------ |
| 12 | +# Configuration |
| 13 | +# ------------------------------------------------------------------------------ |
| 14 | +DOCKER_IMAGE := ghcr.io/typo3-documentation/render-guides:latest |
| 15 | +DOCKER_USER := $(shell id -u):$(shell id -g) |
| 16 | +DOCS_DIR := Documentation |
| 17 | +DOCS_OUTPUT := Documentation-GENERATED-temp |
| 18 | +COMPOSER_AUTOLOAD := .Build/vendor/autoload.php |
| 19 | + |
| 20 | +.DEFAULT_GOAL := help |
| 21 | + |
| 22 | +# ------------------------------------------------------------------------------ |
| 23 | +# Dependency Checks |
| 24 | +# ------------------------------------------------------------------------------ |
| 25 | +.PHONY: check-dependencies |
| 26 | +check-dependencies: |
| 27 | + @if [ ! -f "$(COMPOSER_AUTOLOAD)" ]; then \ |
| 28 | + echo ""; \ |
| 29 | + echo "ERROR: Dependencies not installed."; \ |
| 30 | + echo ""; \ |
| 31 | + echo "Please run:"; \ |
| 32 | + echo " make install"; \ |
| 33 | + echo ""; \ |
| 34 | + exit 1; \ |
| 35 | + fi |
| 36 | + |
| 37 | +# ------------------------------------------------------------------------------ |
| 38 | +# Help |
| 39 | +# ------------------------------------------------------------------------------ |
1 | 40 | .PHONY: help |
2 | | -help: ## Displays this list of targets with descriptions |
3 | | - @echo "The following commands are available:\n" |
4 | | - @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' |
5 | | - |
| 41 | +help: ## Display available commands |
| 42 | + @echo "Usage: make [target]\n" |
| 43 | + @echo "Targets:" |
| 44 | + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-20s\033[0m %s\n", $$1, $$2}' |
| 45 | + |
| 46 | +# ------------------------------------------------------------------------------ |
| 47 | +# Documentation |
| 48 | +# ------------------------------------------------------------------------------ |
6 | 49 | .PHONY: docs |
7 | | -docs: ## Generate projects documentation (from "Documentation" directory) |
8 | | - mkdir -p Documentation-GENERATED-temp |
9 | | - |
10 | | - docker run --user $(shell id -u):$(shell id -g) --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation |
| 50 | +docs: ## Build documentation locally |
| 51 | + mkdir -p $(DOCS_OUTPUT) |
| 52 | + docker run --user $(DOCKER_USER) --rm --pull always -v "$(shell pwd)":/project -t $(DOCKER_IMAGE) --config=$(DOCS_DIR) |
| 53 | + |
| 54 | +.PHONY: docs-test |
| 55 | +docs-test: ## Build documentation with strict validation (CI mode) |
| 56 | + mkdir -p $(DOCS_OUTPUT) |
| 57 | + docker run --user $(DOCKER_USER) --rm --pull always -v "$(shell pwd)":/project -t $(DOCKER_IMAGE) --config=$(DOCS_DIR) --no-progress --fail-on-log |
| 58 | + |
| 59 | +.PHONY: docs-open |
| 60 | +docs-open: ## Open rendered documentation in browser |
| 61 | + @if [ -f "$(DOCS_OUTPUT)/Index.html" ]; then \ |
| 62 | + xdg-open "$(DOCS_OUTPUT)/Index.html" 2>/dev/null || open "$(DOCS_OUTPUT)/Index.html" 2>/dev/null || echo "Open $(DOCS_OUTPUT)/Index.html in your browser"; \ |
| 63 | + else \ |
| 64 | + echo "Documentation not found. Run 'make docs' first."; \ |
| 65 | + fi |
| 66 | + |
| 67 | +# ------------------------------------------------------------------------------ |
| 68 | +# Code Generation (requires DDEV) |
| 69 | +# ------------------------------------------------------------------------------ |
| 70 | +.PHONY: generate |
| 71 | +generate: setup-typo3 codesnippets command-json ## Regenerate all auto-generated documentation |
11 | 72 |
|
12 | | -.PHONY: test-docs |
13 | | -test-docs: ## Test the documentation rendering |
14 | | - mkdir -p Documentation-GENERATED-temp |
| 73 | +.PHONY: codesnippets |
| 74 | +codesnippets: check-dependencies ## Regenerate PHP code snippets |
| 75 | + ddev exec .Build/bin/typo3 codesnippet:create $(DOCS_DIR)/ |
15 | 76 |
|
16 | | - docker run --user $(shell id -u):$(shell id -g) --rm --pull always -v "$(shell pwd)":/project -t ghcr.io/typo3-documentation/render-guides:latest --config=Documentation --no-progress --fail-on-log |
| 77 | +.PHONY: command-json |
| 78 | +command-json: check-dependencies ## Regenerate console commands JSON |
| 79 | + ddev exec .Build/bin/typo3 clinspector:gadget > $(DOCS_DIR)/ApiOverview/CommandControllers/commands.json |
| 80 | + echo "" >> $(DOCS_DIR)/ApiOverview/CommandControllers/commands.json |
17 | 81 |
|
18 | | -.PHONY: generate |
19 | | -generate: setup-typo3 codesnippets command-json ## Regenerate automatic code documentation |
| 82 | +# ------------------------------------------------------------------------------ |
| 83 | +# Setup (requires DDEV) |
| 84 | +# ------------------------------------------------------------------------------ |
| 85 | +.PHONY: install |
| 86 | +install: composer-update ## Install project dependencies |
20 | 87 |
|
21 | | -.PHONY: codesnippets |
22 | | -codesnippets: ## Regenerate code snippets |
23 | | - ddev exec .Build/bin/typo3 codesnippet:create Documentation/ |
| 88 | +.PHONY: composer-update |
| 89 | +composer-update: ## Update Composer dependencies |
| 90 | + Build/Scripts/runTests.sh -s composerUpdate |
24 | 91 |
|
25 | 92 | .PHONY: setup-typo3 |
26 | | -setup-typo3: ## Setup TYPO3 stub |
| 93 | +setup-typo3: check-dependencies ## Initialize TYPO3 for documentation generation |
27 | 94 | ddev exec '.Build/bin/typo3 setup --driver=sqlite --username=db --password=db --admin-username=john-doe --admin-user-password="John-Doe-1701D." --admin-email="john.doe@example.com" --project-name="TYPO3 Docs" --no-interaction --server-type=apache --force' |
28 | 95 |
|
29 | | -.PHONY: command-json |
30 | | -command-json: ## Regenerate JSON file containing all console commands |
31 | | - ddev exec .Build/bin/typo3 clinspector:gadget > Documentation/ApiOverview/CommandControllers/commands.json |
32 | | - echo "" >> Documentation/ApiOverview/CommandControllers/commands.json |
| 96 | +# ------------------------------------------------------------------------------ |
| 97 | +# Testing |
| 98 | +# ------------------------------------------------------------------------------ |
| 99 | +.PHONY: test |
| 100 | +test: docs-test test-lint test-cgl test-yaml ## Run all tests |
33 | 101 |
|
34 | 102 | .PHONY: test-lint |
35 | | -test-lint: ## Regenerate code snippets |
| 103 | +test-lint: ## Check PHP syntax |
36 | 104 | Build/Scripts/runTests.sh -s lint |
37 | 105 |
|
38 | 106 | .PHONY: test-cgl |
39 | | -test-cgl: ## Regenerate code snippets |
40 | | - Build/Scripts/runTests.sh -s cgl |
| 107 | +test-cgl: check-dependencies ## Check TYPO3 Coding Guidelines (dry-run) |
| 108 | + Build/Scripts/runTests.sh -s cgl -n |
41 | 109 |
|
42 | 110 | .PHONY: test-yaml |
43 | | -test-yaml: ## Regenerate code snippets |
| 111 | +test-yaml: check-dependencies ## Validate YAML files |
44 | 112 | Build/Scripts/runTests.sh -s yamlLint |
45 | 113 |
|
46 | | - |
47 | | -.PHONY: composerUpdate |
48 | | -composerUpdate: ## Update all dependencies (the composer.lock is not commited) |
49 | | - Build/Scripts/runTests.sh -s composerUpdate |
50 | | - |
51 | | -.PHONY: install |
52 | | -install: composerUpdate## Update all dependencies (the composer.lock is not commited) |
53 | | - |
54 | | -.PHONY: test |
55 | | -test: test-docs test-lint test-cgl test-yaml## Test the documentation rendering |
| 114 | +# ------------------------------------------------------------------------------ |
| 115 | +# Fixing |
| 116 | +# ------------------------------------------------------------------------------ |
| 117 | +.PHONY: fix |
| 118 | +fix: fix-cgl ## Apply all automatic fixes |
56 | 119 |
|
57 | 120 | .PHONY: fix-cgl |
58 | | -fix-cgl: ## Fix cgl |
| 121 | +fix-cgl: check-dependencies ## Fix TYPO3 Coding Guidelines violations |
59 | 122 | Build/Scripts/runTests.sh -s cgl |
60 | 123 |
|
61 | | -.PHONY: Fix all |
62 | | -fix: fix-cgl## Test the documentation rendering |
| 124 | +# ------------------------------------------------------------------------------ |
| 125 | +# Cleanup |
| 126 | +# ------------------------------------------------------------------------------ |
| 127 | +.PHONY: clean |
| 128 | +clean: ## Remove generated documentation |
| 129 | + rm -rf $(DOCS_OUTPUT) |
| 130 | + @echo "Cleaned $(DOCS_OUTPUT)" |
0 commit comments