blob: 2c499ac214f6f6c0e54c32252a105036f476b6c4 [file] [log] [blame]
Joey Armstrongad7bd3f2023-10-02 16:55:59 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -04003# Copyright 2017-2022 Open Networking Foundation
Joey Armstrongad7bd3f2023-10-02 16:55:59 -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#
Joey Armstronga5325392024-04-02 13:22:12 -04009# http://www.apache.org/licenses/LICENSE-2.0
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040010#
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
Joey Armstrong6fdded62023-11-30 12:47:50 -050018$(if $(DEBUG),$(eval LINT_DOC8_DEBUG=1))
19
20$(if $(LINT_DOC8_DEBUG),$(warning ENTER))
21
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040022##-------------------##
23##---] GLOBALS [---##
24##-------------------##
25.PHONY: lint-doc8 lint-doc8-all lint-doc8-modified
26
27have-doc8-files := $(if $(strip $(DOC8_SOURCE)),true)
28DOC8_SOURCE ?= $(error DOC8_SOURCE= is required)
29
30# -----------------------------------------------------------------------
31# Well that is annoying. Cannot pass two --config switches, doc8 will
32# use only one. Repos have more special exclusions so pass onf-make
33# doc8 config as command line args so local makefiles to use --config
34# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040035ifdef USE_DOC8_INI
36 lint-doc8-args += --config $(ONF_MAKEDIR)/lint/doc8/doc8.ini
37endif
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040038
39## -----------------------------------------------------------------------
40## -----------------------------------------------------------------------
41ifndef NO-LINT-DOC8
42 lint-doc8-mode := $(if $(have-doc8-files),mod,all)
43 lint : lint-doc8-$(lint-doc8-mode)
44endif# NO-LINT-DOC8
45
46## -----------------------------------------------------------------------
47# Support consistent lint target names across makefiles
48# Clone logic makefiles/lint/shellcheck/shellcheck.mk deps
49# *-{mod, src} targets and exclusiosn.
50## -----------------------------------------------------------------------
51lint-doc8-all : lint-doc8
52lint-doc8-mod : lint-doc8
53lint-doc8-src : lint-doc8
54
55## -----------------------------------------------------------------------
Joey Armstrong6fdded62023-11-30 12:47:50 -050056## Intent: Morph exclusion strings into command line arguments.
57## NOTE: Do not double-quote argument: -ignore-path "$(dir)"
58## Single quotes surrounding exclusion strings added in doc8/excl.mk
59## will become part of exclusion string and fail pattern matching.
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040060## -----------------------------------------------------------------------
Joey Armstrong6fdded62023-11-30 12:47:50 -050061## [TODO] - move lint-doc8-excl into doc8.ini (autogenerate)
62## -----------------------------------------------------------------------
63lint-doc8-excl := $(strip \
64 $(foreach dir,$(onf-excl-dirs) $(lint-doc8-excl-raw),\
65 $(if $(LINT_DOC8_DEBUG),$(info ** linux-doc8-excl += [$(dir)]))\
66 --ignore-path $(dir))\
67)
68
69## -----------------------------------------------------------------------
70## Usage: make lint-doc8 LINT_DOC8_DEBUG=1
71## -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040072lint-doc8: \
73 lint-doc8-cmd-version \
74 lint-doc8-ini-tmp
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040075
76 $(call banner-enter,Target $@)
77 $(activate) && doc8 $(lint-doc8-excl) $(lint-doc8-args)
78 $(call banner-enter,Target $@)
79
Joey Armstrong6fdded62023-11-30 12:47:50 -050080$(if $(LINT_DOC8_DEBUG),$(warning LEAVE))
81
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040082# [EOF]