blob: 1af4f5e9fe11ee91b7f29cdd07d136a6ae56fd49 [file] [log] [blame]
Joey Armstronga5278142023-06-28 16:56:54 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong098eedd2024-02-11 10:00:59 -05003# Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstronga5278142023-06-28 16:56:54 -04004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17
18##-------------------##
19##---] GLOBALS [---##
20##-------------------##
21.PHONY: lint-mdl lint-mdl-all lint-mdl-modified
22
23have-rst-files := $(if $(strip $(RST_SOURCE)),true)
24RST_SOURCE ?= $(error RST_SOURCE= is required)
25
26## -----------------------------------------------------------------------
27## -----------------------------------------------------------------------
28ifndef NO-LINT-MARKDOWN
29 lint-mdl-mode := $(if $(have-mdl-files),modified,all)
30 lint : lint-mdl-$(lint-mdl-mode)
31endif# NO-LINT-MDL
32
33# Consistent targets across lint makefiles
34lint-mdl-all : lint-mdl
35lint-mdl-modified : lint-mdl
36
37# onf-excl-dirs
38LINT_STYLE ?= mdl_strict.rb
39
40mdl-excludes := $(foreach path,$(onf-exclude-dirs),! -path "./$(path)/*")
41
42lint-mdl:
43 $(call banner-enter,Target $@)
44 @echo "markdownlint(mdl) version: `mdl --version`"
45 @echo "style config:"
46 @echo "---"
47 @cat $(LINT_STYLE)
48 @echo "---"
49# mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(venv-activate-script)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"`
50 mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) $(mdl-excludes) -iname "*.md"`
51
52## -----------------------------------------------------------------------
53## Intent: Display command usage
54## -----------------------------------------------------------------------
55help::
56 @echo ' lint-mdl Syntax check python using the mdl command'
57 ifdef VERBOSE
58 @echo ' lint-mdl-all mdl checking: exhaustive'
59 @echo ' lint-mdl-modified mdl checking: only modified'
60 endif
61
62# [EOF]