Skip to content

Commit a92f82c

Browse files
authored
om2: Setup mdox formatter for openmetrics spec 2.0 (#2892)
* Setup mdox formatter for openmetrics spec 2.0 Signed-off-by: bwplotka <bwplotka@gmail.com> * avoid bingo Signed-off-by: bwplotka <bwplotka@gmail.com> * fix link Signed-off-by: bwplotka <bwplotka@gmail.com> * hard wraps Signed-off-by: bwplotka <bwplotka@gmail.com> * fmt Signed-off-by: bwplotka <bwplotka@gmail.com> --------- Signed-off-by: bwplotka <bwplotka@gmail.com>
1 parent 57c335e commit a92f82c

File tree

5 files changed

+103
-136
lines changed

5 files changed

+103
-136
lines changed

.github/workflows/link-validation.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Markdown Validation
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
check-md-files:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
11+
- name: Set up Go
12+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.2.0
13+
with:
14+
go-version: stable
15+
- name: Check for broken links
16+
run: |
17+
make check

.mdox.validator.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 1
2+
3+
# Don't check external URLs, they can time-out a lot (rate limits).
4+
validators:
5+
- type: ignore
6+
regex: http(s|)://.*

Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1-
.PHONY: mdox-check
2-
mdox-check:
3-
@mdox fmt --links.validate --check $$(find . -type d -name node_modules -prune -o -type d -name .next -prune -o -type d -name .git -prune -o -name '*.md' -print)
1+
# TODO(bwplotka): Add more files to format.
2+
MD_FILES_TO_FORMAT=docs/specs/om/open_metrics_spec_2_0.md
3+
4+
MDOX="mdox"
5+
$(MDOX):
6+
@go install github.com/bwplotka/mdox@v0.9.0
7+
8+
.PHONY: help
9+
help: ## Displays help.
10+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
11+
12+
.PHONY: fmt
13+
fmt: ## Format docs.
14+
fmt: $(MDOX)
15+
@echo "Formatting markdown files..."
16+
@$(MDOX) fmt --links.validate $(MD_FILES_TO_FORMAT)
17+
18+
.PHONY: check
19+
check: ## Checks if doc is formatter and links are correct (don't check external links).
20+
check: $(MDOX)
21+
@echo "Checking markdown file formatting and basic links..."
22+
@$(MDOX) fmt --links.validate --links.validate.config-file=./.mdox.validator.yaml --check $(MD_FILES_TO_FORMAT) || (echo "🔥 Validation failed, files not formatted or links are broken. Try running 'make fmt' to fix formatting!" && exit 1)
23+
@echo "✅ Markdown files correctly formatted"

0 commit comments

Comments
 (0)