Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 3 | # Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 4 | # |
| 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 | # ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 17 | # Makefile for Sphinx documentation |
| 18 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 19 | .DEFAULT_GOAL := help |
| 20 | |
| 21 | TOP ?= . |
| 22 | MAKEDIR ?= $(TOP)/makefiles |
| 23 | |
| 24 | $(if $(VERBOSE),$(eval export VERBOSE=$(VERBOSE))) # visible to include(s) |
| 25 | |
| 26 | ##--------------------## |
| 27 | ##---] INCLUDES [---## |
| 28 | ##--------------------## |
| 29 | include $(MAKEDIR)/consts.mk |
| 30 | include $(MAKEDIR)/help/include.mk |
| 31 | include $(MAKEDIR)/patches/include.mk |
| 32 | include $(MAKEDIR)/help/variables.mk |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 33 | |
| 34 | # You can set these variables from the command line. |
| 35 | SPHINXOPTS ?= |
| 36 | SPHINXBUILD ?= sphinx-build |
| 37 | SOURCEDIR ?= . |
| 38 | BUILDDIR ?= _build |
| 39 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 40 | # Other repos with documentation to include. |
| 41 | # edit the `git_refs` file with the commit/tag/branch that you want to use |
Andrea Campanella | c18d118 | 2021-09-10 12:01:38 +0200 | [diff] [blame] | 42 | OTHER_REPO_DOCS ?= bbsim cord-tester ofagent-go openolt voltctl voltha-openolt-adapter voltha-openonu-adapter-go voltha-protos voltha-system-tests device-management-interface voltha-helm-charts |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 43 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 44 | ifdef NO_OTHER_REPO_DOCS |
| 45 | # Inhibit pulling in external repos. |
| 46 | # python 3.10+ patching not supported by all repos yet. |
| 47 | OTHER_REPO_DOCS := $(null) |
| 48 | endif |
| 49 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 50 | # Static docs, built by other means (usually robot framework) |
| 51 | STATIC_DOCS := _static/voltha-system-tests _static/cord-tester |
| 52 | |
| 53 | # name of python virtualenv that is used to run commands |
| 54 | VENV_NAME := venv_docs |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 55 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 56 | .PHONY: help test lint reload Makefile prep |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 57 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 58 | # Put it first so that "make" without argument is like "make help". |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 59 | help :: $(VENV_NAME) |
| 60 | @ echo |
| 61 | @ source $</bin/activate ; set -u ;\ |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 62 | $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 63 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 64 | # ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 65 | # Create the virtualenv with all the tools installed |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 66 | # ----------------------------------------------------------------------- |
Joey Armstrong | f88b738 | 2022-12-02 15:04:21 -0500 | [diff] [blame] | 67 | .PHONY: venv |
| 68 | venv: $(VENV_NAME) |
| 69 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 70 | $(VENV_NAME): |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 71 | @echo |
| 72 | @echo "=============================" |
| 73 | @echo "Installing python virtual env" |
| 74 | @echo "=============================" |
| 75 | virtualenv -p python3 $@ ;\ |
| 76 | source ./$@/bin/activate ;\ |
| 77 | python -m pip install -r requirements.txt |
| 78 | ifndef NO_PATCH |
| 79 | @echo |
| 80 | @echo "========================================" |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 81 | @echo "Applying python virtualenv patches as needed (v3.10+)" |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 82 | @echo "========================================" |
Joey Armstrong | 1a9b7d1 | 2022-12-19 14:13:07 -0500 | [diff] [blame] | 83 | ./patches/python_310_migration.sh '--venv' "$@" 'apply' |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 84 | endif |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 85 | |
| 86 | # automatically reload changes in browser as they're made |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 87 | reload: $(VENV_NAME) |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 88 | source $</bin/activate ; set -u ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 89 | sphinx-reload $(SOURCEDIR) |
| 90 | |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 91 | ## ----------------------------------------------------------------------- |
| 92 | ## Intent: lint and link verification. linkcheck is part of sphinx |
| 93 | ## ----------------------------------------------------------------------- |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 94 | test: lint linkcheck |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 95 | |
Joey Armstrong | 8d62cd9 | 2022-12-22 13:53:48 -0500 | [diff] [blame] | 96 | ## ----------------------------------------------------------------------- |
| 97 | ## Intent: Exercise all generation targets |
| 98 | ## ----------------------------------------------------------------------- |
| 99 | test-all-targets += html |
| 100 | test-all-targets += coverage |
| 101 | # test-all-targets += changes |
| 102 | # test-all-targets += info |
| 103 | test-all-targets += man |
| 104 | test-all-targe4ts += text |
| 105 | # test-all-targets += latex |
| 106 | |
| 107 | |
| 108 | test-all : test |
| 109 | $(MAKE) $(test-all-targets) |
| 110 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 111 | # doctest |
| 112 | # coverage |
| 113 | # linkcheck |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 114 | lint: doc8 |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 115 | # include $(MAKEDIR)/lint/shell.mk |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 116 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 117 | doc8: $(VENV_NAME) | $(OTHER_REPO_DOCS) |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 118 | source $</bin/activate ; set -u ;\ |
| 119 | doc8 --max-line-length 119 \ |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 120 | $$(find . -name \*.rst ! -path "*venv*" ! -path "*vendor*" ! -path "*repos*" ) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 121 | |
| 122 | # markdown linting |
| 123 | # currently not enabled, should be added to lint target |
| 124 | LINT_STYLE ?= mdl_strict.rb |
| 125 | md-lint: | $(OTHER_REPO_DOCS) |
| 126 | @echo "markdownlint(mdl) version: `mdl --version`" |
| 127 | @echo "style config:" |
| 128 | @echo "---" |
| 129 | @cat $(LINT_STYLE) |
| 130 | @echo "---" |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 131 | mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_$(VENV_NAME)/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"` |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 132 | |
| 133 | # clean up |
| 134 | clean: |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 135 | $(RM) -r $(BUILDDIR) $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 136 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 137 | clean-all sterile: clean |
| 138 | $(RM) -r $(VENV_NAME) repos |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 139 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 140 | # checkout the repos inside repos/ dir |
| 141 | repos: |
| 142 | mkdir repos |
| 143 | |
| 144 | # build directory paths in repos/* to perform 'git clone <repo>' into |
| 145 | CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo)) |
| 146 | |
| 147 | # Host holding the git server |
| 148 | REPO_HOST ?= https://gerrit.opencord.org |
| 149 | |
| 150 | # For QA patchset validation - set SKIP_CHECKOUT to the repo name and |
| 151 | # pre-populate it under repos/ with the specific commit to being validated |
| 152 | SKIP_CHECKOUT ?= |
| 153 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 154 | # clone (only if doesn't exist) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 155 | $(CHECKOUT_REPOS): | repos |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 156 | if [ ! -d '$@' ] ;\ |
| 157 | then git clone $(REPO_HOST)/$(@F) $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 158 | fi |
| 159 | |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 160 | # checkout correct ref if not under test, then copy subdirectories into main |
Zack Williams | 17e3402 | 2019-12-20 13:51:54 -0700 | [diff] [blame] | 161 | # docs dir |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 162 | $(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS) |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 163 | if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\ |
| 164 | then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 165 | cd "repos/$@" && git checkout $$GIT_REF ;\ |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 166 | fi |
Zack Williams | 17e3402 | 2019-12-20 13:51:54 -0700 | [diff] [blame] | 167 | GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 168 | cp -r repos/$(@)$$GIT_SUBDIR $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 169 | |
Andrea Campanella | 92bd59b | 2020-01-30 17:26:32 +0100 | [diff] [blame] | 170 | # Build Robot documentation in voltha-system-tests and copy it into _static. |
| 171 | _static/voltha-system-tests: | $(OTHER_REPO_DOCS) |
| 172 | make -C voltha-system-tests gendocs |
| 173 | mkdir -p $@ |
| 174 | cp -r voltha-system-tests/gendocs/* $@ |
| 175 | |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame] | 176 | # Build Robot documentation in cord-tester and copy it into _static. |
| 177 | _static/cord-tester: | $(OTHER_REPO_DOCS) |
| 178 | make -C cord-tester gendocs |
| 179 | mkdir -p $@ |
| 180 | cp -r cord-tester/gendocs/* $@ |
| 181 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 182 | # generate a list of git checksums suitable for updating git_refs |
| 183 | freeze: repos |
| 184 | @for repo in $(OTHER_REPO_DOCS) ; do \ |
| 185 | GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 186 | cd "repos/$$repo" > /dev/null ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 187 | HEAD_SHA=`git rev-parse HEAD` ;\ |
| 188 | printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 189 | cd ../.. ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 190 | done |
| 191 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 192 | # build multiple versions |
| 193 | multiversion: $(VENV_NAME) Makefile | prep $(OTHER_REPO_DOCS) |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 194 | source $</bin/activate ; set -u ;\ |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 195 | sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/multiversion" $(SPHINXOPTS) |
| 196 | cp "$(SOURCEDIR)/_templates/meta_refresh.html" "$(BUILDDIR)/multiversion/index.html" |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 197 | |
Zack Williams | 16042b6 | 2020-03-29 22:03:16 -0700 | [diff] [blame] | 198 | # prep target - used in sphinx-multiversion to properly link |
| 199 | prep: | $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
Andy Bavier | 5dee6ae | 2020-01-29 16:03:40 -0700 | [diff] [blame] | 200 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 201 | # Catch-all target: route all unknown targets to Sphinx using the new |
| 202 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 203 | # %: $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
| 204 | |
Joey Armstrong | 1a9b7d1 | 2022-12-19 14:13:07 -0500 | [diff] [blame] | 205 | include $(MAKEDIR)/voltha/docs-catchall-targets.mk |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 206 | $(voltha-docs-catchall): $(VENV_NAME) Makefile | $(OTHER_REPO_DOCS) $(STATIC_DOCS) |
| 207 | @echo " ** CATCHALL: $@" |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 208 | source $</bin/activate ; set -u ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 209 | $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 210 | |
Joey Armstrong | a8bc8e1 | 2022-12-04 07:06:59 -0500 | [diff] [blame] | 211 | ## ----------------------------------------------------------------------- |
| 212 | ## ----------------------------------------------------------------------- |
| 213 | BROWSER ?= $(error Usage: $(MAKE) $@ BROWSER=) |
| 214 | view-html: |
| 215 | "$(BROWSER)" _build/html/index.html |
| 216 | |
| 217 | ## ----------------------------------------------------------------------- |
| 218 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 219 | include $(MAKEDIR)/help/trailer.mk |
| 220 | |
| 221 | # [EOF] |