mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-21 08:11:43 +02:00
Switch to mdformat to format docs
- Use mdformat and mdformat-mkdocs to format docs - Add mdformat to Makefile and pre-commit-config - Prettier ignores docs/
This commit is contained in:
committed by
nblock
parent
5c449db125
commit
47307d19cf
2
.mdformat.toml
Normal file
2
.mdformat.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[plugin.mkdocs]
|
||||||
|
align_semantic_breaks_in_lists = true
|
||||||
@@ -45,6 +45,14 @@ repos:
|
|||||||
exclude: ^docs/
|
exclude: ^docs/
|
||||||
types_or: [javascript, jsx, ts, tsx, yaml, json, toml, html, css, scss, sass, markdown]
|
types_or: [javascript, jsx, ts, tsx, yaml, json, toml, html, css, scss, sass, markdown]
|
||||||
|
|
||||||
|
# mdformat for docs
|
||||||
|
- id: mdformat
|
||||||
|
name: mdformat
|
||||||
|
entry: mdformat
|
||||||
|
language: system
|
||||||
|
types_or: [markdown]
|
||||||
|
files: ^docs/
|
||||||
|
|
||||||
# golangci-lint for Go code quality
|
# golangci-lint for Go code quality
|
||||||
- id: golangci-lint
|
- id: golangci-lint
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
|
|||||||
@@ -1,5 +1,2 @@
|
|||||||
.github/workflows/test-integration-v2*
|
.github/workflows/test-integration-v2*
|
||||||
docs/about/features.md
|
docs/
|
||||||
docs/ref/api.md
|
|
||||||
docs/ref/configuration.md
|
|
||||||
docs/ref/oidc.md
|
|
||||||
|
|||||||
17
Makefile
17
Makefile
@@ -21,7 +21,7 @@ endef
|
|||||||
# Source file collections using shell find for better performance
|
# Source file collections using shell find for better performance
|
||||||
GO_SOURCES := $(shell find . -name '*.go' -not -path './gen/*' -not -path './vendor/*')
|
GO_SOURCES := $(shell find . -name '*.go' -not -path './gen/*' -not -path './vendor/*')
|
||||||
PROTO_SOURCES := $(shell find . -name '*.proto' -not -path './gen/*' -not -path './vendor/*')
|
PROTO_SOURCES := $(shell find . -name '*.proto' -not -path './gen/*' -not -path './vendor/*')
|
||||||
DOC_SOURCES := $(shell find . \( -name '*.md' -o -name '*.yaml' -o -name '*.yml' -o -name '*.ts' -o -name '*.js' -o -name '*.html' -o -name '*.css' -o -name '*.scss' -o -name '*.sass' \) -not -path './gen/*' -not -path './vendor/*' -not -path './node_modules/*')
|
PRETTIER_SOURCES := $(shell find . \( -name '*.md' -o -name '*.yaml' -o -name '*.yml' -o -name '*.ts' -o -name '*.js' -o -name '*.html' -o -name '*.css' -o -name '*.scss' -o -name '*.sass' \) -not -path './gen/*' -not -path './vendor/*' -not -path './node_modules/*')
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
@@ -33,6 +33,7 @@ check-deps:
|
|||||||
$(call check_tool,go)
|
$(call check_tool,go)
|
||||||
$(call check_tool,golangci-lint)
|
$(call check_tool,golangci-lint)
|
||||||
$(call check_tool,gofumpt)
|
$(call check_tool,gofumpt)
|
||||||
|
$(call check_tool,mdformat)
|
||||||
$(call check_tool,prettier)
|
$(call check_tool,prettier)
|
||||||
$(call check_tool,clang-format)
|
$(call check_tool,clang-format)
|
||||||
$(call check_tool,buf)
|
$(call check_tool,buf)
|
||||||
@@ -52,7 +53,7 @@ test: check-deps $(GO_SOURCES) go.mod go.sum
|
|||||||
|
|
||||||
# Formatting targets
|
# Formatting targets
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt: fmt-go fmt-prettier fmt-proto
|
fmt: fmt-go fmt-mdformat fmt-prettier fmt-proto
|
||||||
|
|
||||||
.PHONY: fmt-go
|
.PHONY: fmt-go
|
||||||
fmt-go: check-deps $(GO_SOURCES)
|
fmt-go: check-deps $(GO_SOURCES)
|
||||||
@@ -60,9 +61,14 @@ fmt-go: check-deps $(GO_SOURCES)
|
|||||||
gofumpt -l -w .
|
gofumpt -l -w .
|
||||||
golangci-lint run --fix
|
golangci-lint run --fix
|
||||||
|
|
||||||
|
.PHONY: fmt-mdformat
|
||||||
|
fmt-mdformat: check-deps
|
||||||
|
@echo "Formatting documentation..."
|
||||||
|
mdformat docs/
|
||||||
|
|
||||||
.PHONY: fmt-prettier
|
.PHONY: fmt-prettier
|
||||||
fmt-prettier: check-deps $(DOC_SOURCES)
|
fmt-prettier: check-deps $(PRETTIER_SOURCES)
|
||||||
@echo "Formatting documentation and config files..."
|
@echo "Formatting markup and config files..."
|
||||||
prettier --write '**/*.{ts,js,md,yaml,yml,sass,css,scss,html}'
|
prettier --write '**/*.{ts,js,md,yaml,yml,sass,css,scss,html}'
|
||||||
|
|
||||||
.PHONY: fmt-proto
|
.PHONY: fmt-proto
|
||||||
@@ -116,7 +122,8 @@ help:
|
|||||||
@echo ""
|
@echo ""
|
||||||
@echo "Specific targets:"
|
@echo "Specific targets:"
|
||||||
@echo " fmt-go - Format Go code only"
|
@echo " fmt-go - Format Go code only"
|
||||||
@echo " fmt-prettier - Format documentation only"
|
@echo " fmt-mdformat - Format documentation only"
|
||||||
|
@echo " fmt-prettier - Format markup and config files only"
|
||||||
@echo " fmt-proto - Format Protocol Buffer files only"
|
@echo " fmt-proto - Format Protocol Buffer files only"
|
||||||
@echo " lint-go - Lint Go code only"
|
@echo " lint-go - Lint Go code only"
|
||||||
@echo " lint-proto - Lint Protocol Buffer files only"
|
@echo " lint-proto - Lint Protocol Buffer files only"
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ run `make lint` and `make fmt` before committing any code.
|
|||||||
The **Proto** code is linted with [`buf`](https://docs.buf.build/lint/overview) and
|
The **Proto** code is linted with [`buf`](https://docs.buf.build/lint/overview) and
|
||||||
formatted with [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html).
|
formatted with [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html).
|
||||||
|
|
||||||
|
The **docs** are formatted with [`mdformat`](https://mdformat.readthedocs.io).
|
||||||
|
|
||||||
The **rest** (Markdown, YAML, etc) is formatted with [`prettier`](https://prettier.io).
|
The **rest** (Markdown, YAML, etc) is formatted with [`prettier`](https://prettier.io).
|
||||||
|
|
||||||
Check out the `.golangci.yaml` and `Makefile` to see the specific configuration.
|
Check out the `.golangci.yaml` and `Makefile` to see the specific configuration.
|
||||||
|
|||||||
@@ -179,6 +179,10 @@
|
|||||||
yq-go
|
yq-go
|
||||||
ripgrep
|
ripgrep
|
||||||
postgresql
|
postgresql
|
||||||
|
python313Packages.mdformat
|
||||||
|
python313Packages.mdformat-footnote
|
||||||
|
python313Packages.mdformat-frontmatter
|
||||||
|
python313Packages.mdformat-mkdocs
|
||||||
prek
|
prek
|
||||||
|
|
||||||
# 'dot' is needed for pprof graphs
|
# 'dot' is needed for pprof graphs
|
||||||
|
|||||||
Reference in New Issue
Block a user