@@ -66,6 +66,10 @@ MOST_GO_SRC_FILES := $(shell \
66
66
)
67
67
# All the shell files in the repo, excluding ignored files.
68
68
SHELL_SRC_FILES := $(shell find . $(FIND_EXCLUSIONS ) -type f -name '* .sh')
69
+ # All markdown files in docs directory, used to determine if docs targets should run
70
+ DOCS_MD_FILES := $(shell find ./docs $(FIND_EXCLUSIONS ) -type f -name '* .md' 2>/dev/null | wc -l | tr -d ' ')
71
+ # Changed markdown files (if in a git repo), otherwise empty
72
+ DOCS_CHANGED_FILES := $(shell git diff --name-only --diff-filter=ACMR HEAD 2>/dev/null | grep -E '^docs/.* \.md$$' 2>/dev/null || echo "")
69
73
70
74
# Ensure we don't use the user's git configs which might cause side-effects
71
75
GIT_FLAGS = GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null
@@ -501,13 +505,54 @@ endif
501
505
.PHONY : fmt/shfmt
502
506
503
507
fmt/markdown : node_modules/.installed
504
- echo " $( GREEN) ==>$( RESET) $( BOLD) fmt/markdown$( RESET) "
505
- pnpm format-docs
508
+ @if [ " $( DOCS_MD_FILES) " -gt 0 ]; then \
509
+ echo " $( GREEN) ==>$( RESET) $( BOLD) fmt/markdown$( RESET) " ; \
510
+ if echo " $( MAKEFLAGS) " | grep -q " all" ; then \
511
+ echo " Formatting all documentation files..." ; \
512
+ pnpm format-docs; \
513
+ else \
514
+ if [ -n " $( DOCS_CHANGED_FILES) " ]; then \
515
+ echo " Formatting changed files only: $( DOCS_CHANGED_FILES) " ; \
516
+ pnpm exec markdown-table-formatter $(DOCS_CHANGED_FILES ) 2> /dev/null || echo " No tables found to format" ; \
517
+ else \
518
+ echo " No changed files detected, running standard format..." ; \
519
+ pnpm format-docs; \
520
+ fi ; \
521
+ fi ; \
522
+ else \
523
+ echo " $( GREEN) ==>$( RESET) $( BOLD) fmt/markdown$( RESET) (skipped - no docs files)" ; \
524
+ fi
506
525
.PHONY : fmt/markdown
507
526
508
527
lint : lint/shellcheck lint/go lint/ts lint/examples lint/helm lint/site-icons lint/markdown
509
528
.PHONY : lint
510
529
530
+ # Check document style with Vale (optional, opt-in, --all to check all files)
531
+ lint/docs-style : node_modules/.installed
532
+ @if [ " $( DOCS_MD_FILES) " -gt 0 ]; then \
533
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/docs-style$( RESET) " ; \
534
+ if command -v vale > /dev/null 2>&1 ; then \
535
+ if echo " $( MAKEFLAGS) " | grep -q " all" ; then \
536
+ echo " Checking all documentation files..." ; \
537
+ vale --no-exit --config=.github/docs/vale/.vale.ini docs/; \
538
+ else \
539
+ if [ -n " $( DOCS_CHANGED_FILES) " ]; then \
540
+ echo " Checking changed files only: $( DOCS_CHANGED_FILES) " ; \
541
+ vale --no-exit --config=.github/docs/vale/.vale.ini $(DOCS_CHANGED_FILES ) ; \
542
+ else \
543
+ echo " No changed files detected, checking representative files..." ; \
544
+ vale --no-exit --config=.github/docs/vale/.vale.ini docs/README.md docs/index.md 2> /dev/null || echo " No representative files found" ; \
545
+ fi ; \
546
+ fi ; \
547
+ else \
548
+ echo " Vale is an optional tool for style checking." ; \
549
+ echo " If you want to install it: brew install vale (or see https://vale.sh)" ; \
550
+ fi ; \
551
+ else \
552
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/docs-style$( RESET) (skipped - no docs files)" ; \
553
+ fi
554
+ .PHONY : lint/docs-style
555
+
511
556
lint/site-icons :
512
557
./scripts/check_site_icons.sh
513
558
.PHONY : lint/site-icons
@@ -540,9 +585,54 @@ lint/helm:
540
585
.PHONY : lint/helm
541
586
542
587
lint/markdown : node_modules/.installed
543
- pnpm lint-docs
588
+ @if [ " $( DOCS_MD_FILES) " -gt 0 ]; then \
589
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/markdown$( RESET) " ; \
590
+ if echo " $( MAKEFLAGS) " | grep -q " all" ; then \
591
+ echo " Checking all documentation files..." ; \
592
+ pnpm lint-docs; \
593
+ else \
594
+ if [ -n " $( DOCS_CHANGED_FILES) " ]; then \
595
+ echo " Checking changed files only: $( DOCS_CHANGED_FILES) " ; \
596
+ pnpm exec markdownlint-cli2 $(DOCS_CHANGED_FILES ) ; \
597
+ else \
598
+ echo " No changed files detected, running standard lint..." ; \
599
+ pnpm lint-docs; \
600
+ fi ; \
601
+ fi ; \
602
+ else \
603
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/markdown$( RESET) (skipped - no docs files)" ; \
604
+ fi
544
605
.PHONY : lint/markdown
545
606
607
+ # Comprehensive documentation check (--all to check all files, otherwise only changed files)
608
+ lint/docs : lint/markdown
609
+ @if [ " $( DOCS_MD_FILES) " -gt 0 ]; then \
610
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/docs$( RESET) " ; \
611
+ echo " Checking for broken links in markdown files..." ; \
612
+ if command -v lychee > /dev/null 2>&1 ; then \
613
+ if echo " $( MAKEFLAGS) " | grep -q " all" ; then \
614
+ echo " Checking all documentation files..." ; \
615
+ lychee --config .github/docs/.lycheeignore docs/** /* .md; \
616
+ else \
617
+ if [ -n " $( DOCS_CHANGED_FILES) " ]; then \
618
+ echo " Checking changed files only: $( DOCS_CHANGED_FILES) " ; \
619
+ lychee --config .github/docs/.lycheeignore $(DOCS_CHANGED_FILES ) ; \
620
+ else \
621
+ echo " No changed files detected, checking representative files..." ; \
622
+ lychee --config .github/docs/.lycheeignore docs/README.md docs/index.md; \
623
+ fi ; \
624
+ fi ; \
625
+ else \
626
+ echo " Lychee not found for link checking. Install with 'cargo install lychee' or see https://github.com/lycheeverse/lychee" ; \
627
+ fi ; \
628
+ echo " " ; \
629
+ echo " To run additional style checks, use: make lint/docs-style" ; \
630
+ echo " To check all files (not just changed ones), use: make lint/docs --all" ; \
631
+ else \
632
+ echo " $( GREEN) ==>$( RESET) $( BOLD) lint/docs$( RESET) (skipped - no docs files)" ; \
633
+ fi
634
+ .PHONY : lint/docs
635
+
546
636
# All files generated by the database should be added here, and this can be used
547
637
# as a target for jobs that need to run after the database is generated.
548
638
DB_GEN_FILES := \
0 commit comments