Integration edits for repo:voltha-docs use.
This patch will add makefile targets and exclusions for doc8 (estructuredText) linting.
makefiles/lint/doc8/excl.mk
makefiles/lint/doc8/doc8.mk
makefiles/lint/doc8/help.mk
makefiles/lint/doc8/include.mk
makefiles/lint/doc8/install.mk
------------------------------
o Apply exclusion list so checking will not fail on python venv dirs.
o Split include.mk into named modular makfiles.
makefiles/lint/include.mk
makefiles/lint/shell.mk
-------------------------
o Remove legacy shell.mk config, lint target loads from lint/shell/*.
Change-Id: I8c214dc499356edf9778ae7ec1deeddf35bd3b65
diff --git a/makefiles/lint/doc8/doc8.mk b/makefiles/lint/doc8/doc8.mk
new file mode 100644
index 0000000..04101fe
--- /dev/null
+++ b/makefiles/lint/doc8/doc8.mk
@@ -0,0 +1,59 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2017-2022 Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+##-------------------##
+##---] GLOBALS [---##
+##-------------------##
+.PHONY: lint-doc8 lint-doc8-all lint-doc8-modified
+
+have-doc8-files := $(if $(strip $(DOC8_SOURCE)),true)
+DOC8_SOURCE ?= $(error DOC8_SOURCE= is required)
+
+# -----------------------------------------------------------------------
+# Well that is annoying. Cannot pass two --config switches, doc8 will
+# use only one. Repos have more special exclusions so pass onf-make
+# doc8 config as command line args so local makefiles to use --config
+# -----------------------------------------------------------------------
+# lint-doc8-args += --config $(ONF_MAKEDIR)/lint/doc8/doc8.ini
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+ifndef NO-LINT-DOC8
+ lint-doc8-mode := $(if $(have-doc8-files),mod,all)
+ lint : lint-doc8-$(lint-doc8-mode)
+endif# NO-LINT-DOC8
+
+## -----------------------------------------------------------------------
+# Support consistent lint target names across makefiles
+# Clone logic makefiles/lint/shellcheck/shellcheck.mk deps
+# *-{mod, src} targets and exclusiosn.
+## -----------------------------------------------------------------------
+lint-doc8-all : lint-doc8
+lint-doc8-mod : lint-doc8
+lint-doc8-src : lint-doc8
+
+## -----------------------------------------------------------------------
+## -----------------------------------------------------------------------
+## [TODO] - move lint-doc8-excl into doc8.ini
+lint-doc8-excl := $(foreach dir,$(onf-excl-dirs) $(lint-doc8-excl),--ignore-path "$(dir)")
+lint-doc8: lint-doc8-cmd-version
+
+ $(call banner-enter,Target $@)
+ $(activate) && doc8 $(lint-doc8-excl) $(lint-doc8-args)
+ $(call banner-enter,Target $@)
+
+# [EOF]
diff --git a/makefiles/lint/doc8/excl.mk b/makefiles/lint/doc8/excl.mk
index efa71da..65bf3fa 100644
--- a/makefiles/lint/doc8/excl.mk
+++ b/makefiles/lint/doc8/excl.mk
@@ -20,21 +20,31 @@
## -----------------------------------------------------------------------
## -----------------------------------------------------------------------
-## excl := $(wildcar */*/.git)
+lint-doc8-excl-raw += '*/.git'
lint-doc8-excl-raw += '$(venv-name)'
lint-doc8-excl-raw += '*/$(venv-name)'
+
+# Should we filter generated content as redundant ?
+# Considering _build will be published and consumed.
$(if $(BUILDDIR),\
$(excl lint-doc8-excl-raw += '$(BUILDDIR)'))
+# -----------------------------------------------------------------------
# YUCK! -- overhead
# o Submodule(s) use individual/variant virtualenv install paths.
# o Exclude special snowflakes to enable library makefile use.
# o All can use virtualenv.mk for consistent names and cleanup
# o [TODO] Ignore submodules, individual repos should check their sources.
+# -----------------------------------------------------------------------
+lint-doc8-excl-raw += '*/venv_*'# # '*/venv_cord'
+lint-doc8-excl-raw += '*/*_cord'# # '*/vst_venv'
-lint-doc8-excl-raw += '*/venv_cord'
-lint-doc8-excl-raw += '*/vst_venv'
-
+## -----------------------------------------------------------------------
+## repo:voltha-docs exclusions
+## Migrate into one of:
+## makefiles/local/lint/doc8/doc8.ini
+## makefiles/local/lint/doc8/excl.mk
+## -----------------------------------------------------------------------
lint-doc8-excl-raw += './cord-tester'
lint-doc8-excl-raw += './repos/cord-tester'
diff --git a/makefiles/lint/doc8/help.mk b/makefiles/lint/doc8/help.mk
new file mode 100644
index 0000000..1ec6cb8
--- /dev/null
+++ b/makefiles/lint/doc8/help.mk
@@ -0,0 +1,46 @@
+# -*- makefile -*-
+# -----------------------------------------------------------------------
+# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# -----------------------------------------------------------------------
+
+$(if $(DEBUG),$(warning ENTER))
+
+## -----------------------------------------------------------------------
+## Intent: Display topic help
+## -----------------------------------------------------------------------
+help-summary ::
+ @printf ' %-30s %s\n' 'lint-doc8'\
+ 'Style check ReStructed Text (rst) documents'
+ @printf ' %-30s %s\n' 'lint-doc8-help'\
+ 'Show verbose target help'
+ ifdef VERBOSE
+ @$(MAKE) --no-print-directory lint-doc8-help
+ endif
+
+## -----------------------------------------------------------------------
+## Intent: Display extended topic help
+## -----------------------------------------------------------------------
+.PHONY: lint-doc8-help
+lint-doc8-help ::
+ @printf ' %-30s %s\n' 'lint-doc8-all'\
+ 'Doc8 check available sources'
+ @printf ' %-30s %s\n' 'lint-doc8-mod'\
+ 'Doc8 check locally modified files (git status)'
+# @printf ' %-30s %s\n' 'lint-doc8-src'\
+# 'Doc8 check files by path'
+
+$(if $(DEBUG),$(warning LEAVE))
+
+# [EOF]
diff --git a/makefiles/lint/doc8/include.mk b/makefiles/lint/doc8/include.mk
index 22a24fa..564fca9 100644
--- a/makefiles/lint/doc8/include.mk
+++ b/makefiles/lint/doc8/include.mk
@@ -15,59 +15,12 @@
# limitations under the License.
# -----------------------------------------------------------------------
-##-------------------##
-##---] GLOBALS [---##
-##-------------------##
-.PHONY: lint-doc8 lint-doc8-all lint-doc8-modified
-
-have-doc8-files := $(if $(strip $(DOC8_SOURCE)),true)
-DOC8_SOURCE ?= $(error DOC8_SOURCE= is required)
-
##--------------------##
##---] INCLUDES [---##
##--------------------##
-# include $(ONF_MAKEDIR)/lint/doc8/help.mk
+include $(ONF_MAKEDIR)/lint/doc8/doc8.mk
+include $(ONF_MAKEDIR)/lint/doc8/excl.mk
+include $(ONF_MAKEDIR)/lint/doc8/help.mk
include $(ONF_MAKEDIR)/lint/doc8/install.mk
-# -----------------------------------------------------------------------
-# Well that is annoying. Cannot pass two --config switches, doc8 will
-# use only one. Repos have more special exclusions so pass onf-make
-# doc8 config as command line args so local makefiles to use --config
-# -----------------------------------------------------------------------
-# lint-doc8-args += --config $(ONF_MAKEDIR)/lint/doc8/doc8.ini
-
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-ifndef NO-LINT-DOC8
- lint-doc8-mode := $(if $(have-doc8-files),modified,all)
- lint : lint-doc8-$(lint-doc8-mode)
-endif# NO-LINT-DOC8
-
-# Consistent targets across lint makefiles
-lint-doc8-all : lint-doc8
-lint-doc8-modified : lint-doc8
-
-## -----------------------------------------------------------------------
-## -----------------------------------------------------------------------
-## [TODO] - move lint-doc8-excl into doc8.ini
-# lint-doc8-excl := $(foreach dir,$(onf-excl-dirs) $(lint-doc8-excl),--ignore-path "$(dir)")
-lint-doc8-excl := $(null)
-lint-doc8: lint-doc8-cmd-version
-
- $(call banner-enter,Target $@)
- $(activate) && doc8 --version
- @echo
- $(activate) && doc8 $(lint-doc8-excl) $(lint-doc8-args)
- $(call banner-enter,Target $@)
-
-## -----------------------------------------------------------------------
-## Intent: Display command usage
-## -----------------------------------------------------------------------
-help::
- @echo ' lint-doc8 Syntax check python using the doc8 command'
- ifdef VERBOSE
- @echo ' lint-doc8-all doc8 checking: exhaustive'
- @echo ' lint-doc8-modified doc8 checking: only modified'
- endif
-
# [EOF]
diff --git a/makefiles/lint/include.mk b/makefiles/lint/include.mk
index be19569..2a004af 100644
--- a/makefiles/lint/include.mk
+++ b/makefiles/lint/include.mk
@@ -40,7 +40,7 @@
include $(ONF_MAKEDIR)/lint/license/include.mk
include $(ONF_MAKEDIR)/lint/makefile.mk
include $(ONF_MAKEDIR)/lint/python/include.mk
-include $(ONF_MAKEDIR)/lint/shell.mk
+include $(ONF_MAKEDIR)/lint/shell/include.mk
include $(ONF_MAKEDIR)/lint/tox/include.mk
include $(ONF_MAKEDIR)/lint/yaml/include.mk
diff --git a/makefiles/lint/shell.mk b/makefiles/lint/shell.mk
deleted file mode 100644
index 1aeb7c0..0000000
--- a/makefiles/lint/shell.mk
+++ /dev/null
@@ -1,104 +0,0 @@
-# -*- makefile -*-
-# -----------------------------------------------------------------------
-# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -----------------------------------------------------------------------
-# https://gerrit.opencord.org/plugins/gitiles/onf-make
-# ONF.makefile.version = 1.1
-# -----------------------------------------------------------------------
-
-##-------------------##
-##---] GLOBALS [---##
-##-------------------##
-
-# Gather sources to check
-# TODO: implement deps, only check modified files
-shell-check-find := find .
-# vendor scripts but they really should be lintable
-shell-check-find += -name 'vendor' -prune
-shell-check-find += -o \( -name '*.sh' \)
-shell-check-find += -type f -print0
-
-shell-check := $(env-clean) shellcheck
-# shell-check := shellcheck
-
-shell-check-args += --check-sourced
-shell-check-args += --external-sources
-
-##-------------------##
-##---] TARGETS [---##
-##-------------------##
-ifndef NO-LINT-SHELL
- lint : lint-shell
-endif
-
-## -----------------------------------------------------------------------
-## All or on-demand
-## -----------------------------------------------------------------------
-ifdef LINT_SRC
- lint-shell : lint-shell-src
-else
- lint-shell : lint-shell-all
-endif
-
-## -----------------------------------------------------------------------
-## Intent: Perform a lint check on command line script sources
-## -----------------------------------------------------------------------
-lint-shell-all:
- $(shell-check) -V
- @echo
- $(HIDE)$(env-clean) $(shell-check-find) \
- | $(xargs-n1) $(shell-check) $(shell-check-args)
-
-## -----------------------------------------------------------------------
-## Intent: On-demand lint checking
-## -----------------------------------------------------------------------
-lint-shell-src:
- ifndef SHELL_SRC
- @echo "ERROR: Usage: $(MAKE) $@ SHELL_SRC="
- @exit 1
- endif
- $(shell-check) --version
- @echo
- $(HIDE) $(shell-check) $(shell-check-args) $(SHELL_SRC)
-
-## -----------------------------------------------------------------------
-## Intent: Perform lint check on a named list of files
-## -----------------------------------------------------------------------
-# git show --diff-filter=AM --pretty="format:" --name-only #{commitId}
-# lint-shell-bygit = $(shell git diff --name-only HEAD | grep '\.sh')
-lint-shell-bygit = $(git status -s | grep '\.sh' | grep -v -e '^D' -e '^?' | cut -c4-)
-
-# $(error lint-shell-bygit = $(lint-shell-bygit))
-lint-shell-mod:
- $(shell-check) --version
- @echo
- $(foreach fyl,$(lint-shell-bygit),$(shell-check) $(shell-check-args) $(fyl))
-
-## -----------------------------------------------------------------------
-## Intent: Display command help
-## -----------------------------------------------------------------------
-help-summary ::
- @echo ' lint-shell Conditionally lint shell source'
- ifdef VERBOSE
- @echo ' lint-shell-all Lint all available sources'
- @echo ' lint-shell-mod Lint locally modified (git status)'
- @echo ' lint-shell-src Lint individually (BY_SRC=list-of-files)'
- endif
-
-# [SEE ALSO]
-# -----------------------------------------------------------------------
-# o https://www.shellcheck.net/wiki/Directive
-
-# [EOF]