Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 1 | # Makefile for Sphinx documentation |
| 2 | |
| 3 | # use bash for pushd/popd, and to fail quickly |
| 4 | SHELL = bash -e -o pipefail |
| 5 | |
| 6 | # You can set these variables from the command line. |
| 7 | SPHINXOPTS ?= |
| 8 | SPHINXBUILD ?= sphinx-build |
| 9 | SOURCEDIR ?= . |
| 10 | BUILDDIR ?= _build |
| 11 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 12 | # Other repos with documentation to include. |
| 13 | # edit the `git_refs` file with the commit/tag/branch that you want to use |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame^] | 14 | OTHER_REPO_DOCS ?= bbsim voltha-go voltha-openolt-adapter voltha-openonu-adapter voltha-protos voltctl voltha-system-tests cord-tester |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 15 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 16 | # Put it first so that "make" without argument is like "make help". |
| 17 | help: doc_venv |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 18 | source $</bin/activate ; set -u ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 19 | $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 20 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 21 | .PHONY: help test lint reload Makefile prep |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 22 | |
| 23 | # Create the virtualenv with all the tools installed |
| 24 | doc_venv: |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 25 | virtualenv -p python3 doc_venv ;\ |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 26 | source $@/bin/activate ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 27 | pip install livereload ;\ |
| 28 | pip install -r requirements.txt |
| 29 | |
| 30 | # automatically reload changes in browser as they're made |
| 31 | reload: doc_venv |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 32 | source $</bin/activate ; set -u ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 33 | sphinx-reload $(SOURCEDIR) |
| 34 | |
| 35 | # lint and link verification. linkcheck is part of sphinx |
| 36 | test: lint linkcheck |
| 37 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 38 | lint: doc8 |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 39 | |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 40 | doc8: doc_venv | $(OTHER_REPO_DOCS) |
| 41 | source $</bin/activate ; set -u ;\ |
| 42 | doc8 --max-line-length 119 \ |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame^] | 43 | $$(find . -name \*.rst ! -path "*doc_venv*" ! -path "*vendor*" ! -path "*repos/voltha-system-tests/vst_venv/*" ! -path "*repos/cord-tester/venv_cord/*") |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 44 | |
| 45 | # markdown linting |
| 46 | # currently not enabled, should be added to lint target |
| 47 | LINT_STYLE ?= mdl_strict.rb |
| 48 | md-lint: | $(OTHER_REPO_DOCS) |
| 49 | @echo "markdownlint(mdl) version: `mdl --version`" |
| 50 | @echo "style config:" |
| 51 | @echo "---" |
| 52 | @cat $(LINT_STYLE) |
| 53 | @echo "---" |
| 54 | mdl -s $(LINT_STYLE) `find -L $(SOURCEDIR) ! -path "./_doc_venv/*" ! -path "./_build/*" ! -path "./repos/*" ! -path "*vendor*" -name "*.md"` |
| 55 | |
| 56 | # clean up |
| 57 | clean: |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame^] | 58 | rm -rf $(BUILDDIR) $(OTHER_REPO_DOCS) _static/voltha-system-tests _static/cord-tester |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 59 | |
| 60 | clean-all: clean |
| 61 | rm -rf doc_venv repos |
| 62 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 63 | # checkout the repos inside repos/ dir |
| 64 | repos: |
| 65 | mkdir repos |
| 66 | |
| 67 | # build directory paths in repos/* to perform 'git clone <repo>' into |
| 68 | CHECKOUT_REPOS = $(foreach repo,$(OTHER_REPO_DOCS),repos/$(repo)) |
| 69 | |
| 70 | # Host holding the git server |
| 71 | REPO_HOST ?= https://gerrit.opencord.org |
| 72 | |
| 73 | # For QA patchset validation - set SKIP_CHECKOUT to the repo name and |
| 74 | # pre-populate it under repos/ with the specific commit to being validated |
| 75 | SKIP_CHECKOUT ?= |
| 76 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 77 | # clone (only if doesn't exist) |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 78 | $(CHECKOUT_REPOS): | repos |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 79 | if [ ! -d '$@' ] ;\ |
| 80 | then git clone $(REPO_HOST)/$(@F) $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 81 | fi |
| 82 | |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 83 | # checkout correct ref if not under test, then copy subdirectories into main |
Zack Williams | 17e3402 | 2019-12-20 13:51:54 -0700 | [diff] [blame] | 84 | # docs dir |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 85 | $(OTHER_REPO_DOCS): | $(CHECKOUT_REPOS) |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 86 | if [ "$(SKIP_CHECKOUT)" != "$@" ] ;\ |
| 87 | then GIT_REF=`grep '^$@ ' git_refs | awk '{print $$3}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 88 | cd "repos/$@" && git checkout $$GIT_REF ;\ |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 89 | fi |
Zack Williams | 17e3402 | 2019-12-20 13:51:54 -0700 | [diff] [blame] | 90 | GIT_SUBDIR=`grep '^$@ ' git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 3308552 | 2020-02-28 11:41:01 -0700 | [diff] [blame] | 91 | cp -r repos/$(@)$$GIT_SUBDIR $@ ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 92 | |
Andrea Campanella | 92bd59b | 2020-01-30 17:26:32 +0100 | [diff] [blame] | 93 | # Build Robot documentation in voltha-system-tests and copy it into _static. |
| 94 | _static/voltha-system-tests: | $(OTHER_REPO_DOCS) |
| 95 | make -C voltha-system-tests gendocs |
| 96 | mkdir -p $@ |
| 97 | cp -r voltha-system-tests/gendocs/* $@ |
| 98 | |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame^] | 99 | # Build Robot documentation in cord-tester and copy it into _static. |
| 100 | _static/cord-tester: | $(OTHER_REPO_DOCS) |
| 101 | make -C cord-tester gendocs |
| 102 | mkdir -p $@ |
| 103 | cp -r cord-tester/gendocs/* $@ |
| 104 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 105 | # generate a list of git checksums suitable for updating git_refs |
| 106 | freeze: repos |
| 107 | @for repo in $(OTHER_REPO_DOCS) ; do \ |
| 108 | GIT_SUBDIR=`grep "^$$repo " git_refs | awk '{print $$2}'` ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 109 | cd "repos/$$repo" > /dev/null ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 110 | HEAD_SHA=`git rev-parse HEAD` ;\ |
| 111 | printf "%-24s %-8s %-40s\n" $$repo $$GIT_SUBDIR $$HEAD_SHA ;\ |
Zack Williams | 6c1703f | 2019-12-20 15:31:58 -0700 | [diff] [blame] | 112 | cd ../.. ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 113 | done |
| 114 | |
Zack Williams | 88df474 | 2019-12-20 08:24:47 -0700 | [diff] [blame] | 115 | # use sphinxcontrib-versioning to make a versioned copy of the |
| 116 | # NOTE: document root is now in _build, not _build/html |
| 117 | versioned: doc_venv Makefile | $(OTHER_REPO_DOCS) |
| 118 | source $</bin/activate ; set -u ;\ |
| 119 | sphinx-versioning build -r master "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) |
| 120 | |
| 121 | # prep target - used in sphinxcontrib-versioning to create versioned repos when |
| 122 | # building multiple versions |
| 123 | prep: | $(OTHER_REPO_DOCS) |
| 124 | |
Andy Bavier | 39d67b1 | 2020-02-27 16:08:52 -0700 | [diff] [blame^] | 125 | html: doc_venv Makefile | $(OTHER_REPO_DOCS) _static/voltha-system-tests _static/cord-tester |
Andy Bavier | 5dee6ae | 2020-01-29 16:03:40 -0700 | [diff] [blame] | 126 | source $</bin/activate ; set -u ;\ |
| 127 | $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 128 | |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 129 | # Catch-all target: route all unknown targets to Sphinx using the new |
| 130 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). |
Zack Williams | c6460c2 | 2019-12-18 14:54:43 -0700 | [diff] [blame] | 131 | %: doc_venv Makefile | $(OTHER_REPO_DOCS) |
| 132 | source $</bin/activate ; set -u ;\ |
Zack Williams | 071eda2 | 2019-05-15 18:19:51 -0700 | [diff] [blame] | 133 | $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
| 134 | |