blob: 4baf09f180d4e6fa0ec62817561fdb3e0bb2daf8 [file] [log] [blame]
Joey Armstrongad7bd3f2023-10-02 16:55:59 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrongf2f0a3f2024-04-04 15:50:09 -04003# Copyright 2017-2024 Open Networking Foundation Contributors
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 Armstrongf2f0a3f2024-04-04 15:50:09 -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# -----------------------------------------------------------------------
Joey Armstrongf2f0a3f2024-04-04 15:50:09 -040017# SPDX-FileCopyrightText: 2017-2024 Open Networking Foundation Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# Intent:
21# -----------------------------------------------------------------------
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040022
Joey Armstrong6fdded62023-11-30 12:47:50 -050023$(if $(DEBUG),$(eval LINT_DOC8_DEBUG=1))
24
25$(if $(LINT_DOC8_DEBUG),$(warning ENTER))
26
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040027##-------------------##
28##---] GLOBALS [---##
29##-------------------##
30.PHONY: lint-doc8 lint-doc8-all lint-doc8-modified
31
32have-doc8-files := $(if $(strip $(DOC8_SOURCE)),true)
33DOC8_SOURCE ?= $(error DOC8_SOURCE= is required)
34
35# -----------------------------------------------------------------------
36# Well that is annoying. Cannot pass two --config switches, doc8 will
37# use only one. Repos have more special exclusions so pass onf-make
38# doc8 config as command line args so local makefiles to use --config
39# -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040040ifdef USE_DOC8_INI
41 lint-doc8-args += --config $(ONF_MAKEDIR)/lint/doc8/doc8.ini
42endif
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040043
44## -----------------------------------------------------------------------
45## -----------------------------------------------------------------------
46ifndef NO-LINT-DOC8
47 lint-doc8-mode := $(if $(have-doc8-files),mod,all)
48 lint : lint-doc8-$(lint-doc8-mode)
49endif# NO-LINT-DOC8
50
51## -----------------------------------------------------------------------
52# Support consistent lint target names across makefiles
53# Clone logic makefiles/lint/shellcheck/shellcheck.mk deps
54# *-{mod, src} targets and exclusiosn.
55## -----------------------------------------------------------------------
56lint-doc8-all : lint-doc8
57lint-doc8-mod : lint-doc8
58lint-doc8-src : lint-doc8
59
60## -----------------------------------------------------------------------
Joey Armstrong6fdded62023-11-30 12:47:50 -050061## Intent: Morph exclusion strings into command line arguments.
62## NOTE: Do not double-quote argument: -ignore-path "$(dir)"
63## Single quotes surrounding exclusion strings added in doc8/excl.mk
64## will become part of exclusion string and fail pattern matching.
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040065## -----------------------------------------------------------------------
Joey Armstrong6fdded62023-11-30 12:47:50 -050066## [TODO] - move lint-doc8-excl into doc8.ini (autogenerate)
67## -----------------------------------------------------------------------
68lint-doc8-excl := $(strip \
69 $(foreach dir,$(onf-excl-dirs) $(lint-doc8-excl-raw),\
70 $(if $(LINT_DOC8_DEBUG),$(info ** linux-doc8-excl += [$(dir)]))\
71 --ignore-path $(dir))\
72)
73
74## -----------------------------------------------------------------------
75## Usage: make lint-doc8 LINT_DOC8_DEBUG=1
76## -----------------------------------------------------------------------
Joey Armstronga5325392024-04-02 13:22:12 -040077lint-doc8: \
78 lint-doc8-cmd-version \
79 lint-doc8-ini-tmp
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040080
81 $(call banner-enter,Target $@)
82 $(activate) && doc8 $(lint-doc8-excl) $(lint-doc8-args)
83 $(call banner-enter,Target $@)
84
Joey Armstrong6fdded62023-11-30 12:47:50 -050085$(if $(LINT_DOC8_DEBUG),$(warning LEAVE))
86
Joey Armstrongad7bd3f2023-10-02 16:55:59 -040087# [EOF]