blob: 8888328068de7492d224ccb9e65684f8374afd60 [file] [log] [blame]
Larry Peterson80143522018-06-28 10:43:40 -07001# Makefile for building CORD docs site, guide.opencord.org
2# Building docs requires the following tools:
3# - Gitbook toolchain: https://toolchain.gitbook.com/setup.html
4# - NPM (for Gitbook and Swagger)
5# - Python (for build glossary script)
6# - linkchecker (for test target) http://wummel.github.io/linkchecker/
Zack Williamsda8a5d82017-09-08 12:45:14 -07007
Larry Peterson80143522018-06-28 10:43:40 -07008default: serve
Matteo Scandolo431781c2017-09-06 15:33:07 -07009
Larry Peterson80143522018-06-28 10:43:40 -070010# use bash for pushd/popd, and to fail if commands within a pipe fail
11SHELL = bash -o pipefail
Zack Williamsda8a5d82017-09-08 12:45:14 -070012
Zack Williamsa34afb52019-03-13 08:12:30 -070013GENERATED_DOCS =
Matteo Scandolo431781c2017-09-06 15:33:07 -070014
Larry Peterson80143522018-06-28 10:43:40 -070015LINT_STYLE ?= mdl_relaxed.rb
Zack Williams6c78f912018-06-21 10:56:24 -070016
Larry Peterson80143522018-06-28 10:43:40 -070017serve: setup
Matteo Scandolo8419c082019-03-11 13:54:44 -070018 gitbook serve --log=debug --debug
Matteo Scandolo431781c2017-09-06 15:33:07 -070019
Larry Peterson80143522018-06-28 10:43:40 -070020build: setup
21 gitbook build
Zack Williamsda8a5d82017-09-08 12:45:14 -070022
Matteo Scandolo8419c082019-03-11 13:54:44 -070023setup:
Larry Peterson80143522018-06-28 10:43:40 -070024 gitbook init
25 gitbook install
Matteo Scandolo431781c2017-09-06 15:33:07 -070026
Larry Peterson80143522018-06-28 10:43:40 -070027test: linkcheck lint
28
29linkcheck: build
30 linkchecker -a _book/
31
32lint:
33 @echo "markdownlint(mdl) version: `mdl --version`"
34 @echo "style config:"
35 @echo "---"
36 @cat $(LINT_STYLE)
37 @echo "---"
38 mdl -s $(LINT_STYLE) `find -L . ! -path "./_book/*" ! -path "./node_modules/*" -name "*.md"`
39
Larry Petersonb658e8b2018-06-29 09:21:16 -070040# HOW TO
41# - load the virtual env (https://guide.opencord.org/xos/dev/local_env.html)
42# - run `make`
43# - open the browser at `http://127.0.0.1:8080/ui`
44# - you'll see the 'core' apis
45# - you can see a list of available apis at `http://127.0.0.1:8080/specs/`
46# - just replace the swagger file (top bar) with another one to see different APIs (to be improved)
Larry Peterson80143522018-06-28 10:43:40 -070047
Larry Petersonb658e8b2018-06-29 09:21:16 -070048DOCSDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
49
50swagger: swagger_clean swagger_docs swagger_serve_spec
51
Zack Williamsd6fc7502020-02-24 16:12:59 -070052venv_xosdocs:
53 virtualenv -p python3 $@ ;\
54 source ./$@/bin/activate ;\
55 pip install --upgrade pip ;\
56 pip install -e ../lib/xos-genx
Larry Petersonb658e8b2018-06-29 09:21:16 -070057
Zack Williamsd6fc7502020-02-24 16:12:59 -070058swagger_docs: venv_xosdocs
59 source ./$</bin/activate ; set -u ;\
60 python $(DOCSDIR)scripts/swagger_docs.py
Larry Petersonb658e8b2018-06-29 09:21:16 -070061
62swagger_clean:
63 rm -rf swagger/specs/*
64
65venv_clean:
66 rm -rf $(DOCSDIR)venv-xosdocs
67
68swagger_serve_spec:
69 http-server --cors ./swagger
70
71clean: swagger_clean venv_clean
Larry Peterson80143522018-06-28 10:43:40 -070072 rm -rf $(GENERATED_DOCS)
73 rm -rf _book
74 rm -rf node_modules