Makefile
# TODO #2170: search for old/preceding protocol name AND number, and adapt
# You can set these variables from the command line.
SPHINXOPTS = -j auto -aE -n -W --keep-going
SPHINXBUILD = poetry run sphinx-build
SOURCEDIR = .
TMPDOCDIR = /tmp/octezdoc
BUILDDIR = _build
TOPBUILDDIR = ../_build
TOPBUILDDIR_ABS = $(abspath $(CURDIR)/$(TOPBUILDDIR))
DOCGENDIR = doc_gen
DOCERRORDIR = $(DOCGENDIR)/errors
P2PDOCEXE = $(TOPBUILDDIR)/default/docs/$(DOCGENDIR)/p2p_doc.exe
RPCDOCEXE = $(TOPBUILDDIR)/default/docs/$(DOCGENDIR)/rpc_doc.exe
ERRDOCEXE = $(TOPBUILDDIR)/default/docs/$(DOCERRORDIR)/error_doc.exe
NAMED_PROTOS = nairobi
PROTOCOLS = $(NAMED_PROTOS) alpha
# The following variables names are lowercase, so their names can be computed
# from the names of the corresponding protocol directories
nairobi_long = PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf
alpha_long = ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK
nairobi_short = PtNairob
alpha_short = alpha
SCRIPTSDIR = scripts
CHECKXREFS = $(SCRIPTSDIR)/check_proto_xrefs.py
# Build all documentation (with CLI manuals and odoc) but without old PROTOCOLS
all: odoc-lite
# Html needs the API pages for OCaml modules, generated by odoc, because of
# the :package: custom roles in RST files; so run html *after* odoc
${MAKE} html
# Build the full documentation including archived protocols; for publishing only
full: odoc
# Same ordering constraint: html *after* odoc (see target "all")
${MAKE} html
# Build the manuals for a given protocol
%/octez-client.html:
@../octez-client -protocol $($(@D)_long) man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > $@
%/octez-baker.html:
@../octez-baker-$($(@D)_short) man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > $@
%/octez-accuser.html:
@../octez-accuser-$($(@D)_short) man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > $@
%/octez-smart-rollup-node.html:
@../octez-smart-rollup-node-$($(@D)_short) man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > $@
%/octez-smart-rollup-client.html:
@../octez-smart-rollup-client-$($(@D)_short) man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > $@
manuals: \
$(PROTOCOLS:%=%/octez-client.html) \
$(PROTOCOLS:%=%/octez-baker.html) \
$(PROTOCOLS:%=%/octez-accuser.html) \
$(PROTOCOLS:%=%/octez-smart-rollup-node.html) \
$(PROTOCOLS:%=%/octez-smart-rollup-client.html)
# generic
@../octez-admin-client man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-admin-client.html
@../octez-signer man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-signer.html
@../octez-codec man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-codec.html
@../octez-snoop man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-snoop.html
@ ../octez-dac-node man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-dac-node.html
@ ../octez-dac-client man -verbosity 3 -format html | sed "s#${HOME}#\$$HOME#g" > api/octez-dac-client.html
@../octez-node --help | grep -v '^Octez-node' | grep -v 'OCTEZ-NODE(1)' | \
./scripts/man2txt.py > api/octez-node.txt
@../octez-proxy-server --help | grep -v '^Octez-proxy-server' | grep -v 'OCTEZ-PROXY-SERVER(1)' | \
./scripts/man2txt.py > api/octez-proxy-server.txt
@../octez-smart-rollup-node man -verbosity 3 -format html | \
sed "s#${HOME}#\$$HOME#g" > api/octez-smart-rollup-node.html
.PHONY: odoc
odoc:
cd $$(pwd)/.. ; dune build @doc >docs/odoc.log 2>&1; \
RESULT=$$?; (grep '^Error:' docs/odoc.log || true); exit $$RESULT
@rm -rf $$(pwd)/_build/api/odoc
@mkdir -p $$(pwd)/_build/api
@cp -r $$(pwd)/../_build/default/_doc $$(pwd)/_build/api/odoc
odoc-lite:
rm -rf $(TMPDOCDIR)/
mkdir -p $(TMPDOCDIR)/
rsync --recursive --links --perms \
../scripts ../script-inputs ../src ../tezt ../vendors ../dune ../dune-project ../dune-workspace $(TMPDOCDIR)/
cd $(TMPDOCDIR)/ && ./scripts/remove-old-protocols.sh
@echo "Running odoc in $(TMPDOCDIR), with build directory $(TOPBUILDDIR_ABS) and outputs in $(TMPDOCDIR)/odoc.log"
ODOC_WARN_ERROR=true dune build @doc --build-dir=$(TOPBUILDDIR_ABS) --root=$(TMPDOCDIR) >$(TMPDOCDIR)/odoc.log 2>&1; \
RESULT=$$?; \
(grep '^Error:' $(TMPDOCDIR)/odoc.log || true) ; \
exit $$RESULT
rm -rf $(CURDIR)/_build/api/odoc
mkdir -p $(CURDIR)/_build/api
cp -r $(TOPBUILDDIR_ABS)/default/_doc $(CURDIR)/_build/api/odoc
.PHONY: linkcheck
linkcheck: html
@echo "Running linkcheck, outputs messages to $(BUILDDIR)/output.txt"
@$(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) >$@;\
RESULT=$$?; cat $(BUILDDIR)/output.txt; exit $$RESULT
.PHONY: fixlinkcheck
fixlinkcheck:
@scripts/update_links.sh
.PHONY: redirectcheck
redirectcheck: html
@cd $$(pwd)/.. ; ./scripts/lint.sh --check-redirects
# xrefs should be checked:
# - on the active protocol using its numeric name (not the "active" symlink)
# - on each other protocol including alpha, also checking label defs (option -l)
xrefscheck:
$(CHECKXREFS) nairobi
$(CHECKXREFS) -l alpha
installcheck:
scripts/test_install_scripts.sh install-bin-focal
scripts/test_install_scripts.sh install-bin-jammy
scripts/test_install_scripts.sh install-bin-fedora37
scripts/test_install_scripts.sh install-bin-fedora38
scripts/test_install_scripts.sh install-bin-rc-focal
scripts/test_install_scripts.sh install-bin-rc-jammy
scripts/test_install_scripts.sh install-bin-rc-fedora37
scripts/test_install_scripts.sh install-bin-rc-fedora38
scripts/test_install_scripts.sh install-opam-scratch
scripts/test_install_scripts.sh install-opam-focal
scripts/test_install_scripts.sh compile-release-sources-bullseye
scripts/test_install_scripts.sh compile-sources-bullseye
# build dune targets together to avoid concurrent dunes
docexes:
cd .. && dune build docs/$(DOCERRORDIR)/error_doc.exe docs/$(DOCGENDIR)/rpc_doc.exe docs/$(DOCGENDIR)/p2p_doc.exe
developer/metrics.csv:
../octez-node dump-metrics > developer/metrics.csv
$(ERRDOCEXE): docexes
$(RPCDOCEXE): docexes
$(P2PDOCEXE): docexes
api/errors.rst: $(ERRDOCEXE)
$(ERRDOCEXE) > api/errors.rst
shell/rpc.rst: $(RPCDOCEXE)
$(RPCDOCEXE) index shell /shell/rpc_introduction.rst.inc > $@
%/rpc.rst: $(RPCDOCEXE)
$(RPCDOCEXE) index $(@D) $($(@D)_long) /include/rpc_introduction.rst.inc > $@
user/default-acl.json: $(RPCDOCEXE)
$(RPCDOCEXE) acl > $@
rpc: user/default-acl.json shell/rpc.rst \
alpha/rpc.rst
# To be triggered manually when needed
rpc-protocols: $(NAMED_PROTOS:%=%/rpc.rst)
p2p: $(P2PDOCEXE) shell/p2p_usage.rst.inc
@$(P2PDOCEXE) < shell/p2p_usage.rst.inc > shell/p2p_api.rst
.PHONY: install-dependencies
install-dependencies:
@poetry install
user/node-config.json: user/node-config.sh
cd ..; ./docs/user/node-config.sh >docs/$@
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
html: api/errors.rst developer/metrics.csv user/node-config.json \
rpc p2p manuals install-dependencies
(echo ':orphan:'; echo ''; cat ../CHANGES.rst) > CHANGES-dev.rst
@$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
@ln -s active "$(BUILDDIR)/nairobi" || true
# pylint does not support pyproject.toml configuration for now
# It is configured by ./.pylint.rc
# In pylint, we ignore the following additional errors:
# - C0330: pylint is wrong (https://github.com/psf/black/issues/48)
PYLINTRC?=../.pylintrc
PYLINT=PYLINTRC=${PYLINTRC} poetry run pylint --disable C0330
# pycodestyle does not support pyproject.toml configuration for now
# https://github.com/PyCQA/pydocstyle/issues/447
#
# In pycodestyle we ignore the following additional errors w.r.t to defaults
# (i.e. E121,E123,E126,E226,E24,E704,W503)
# - E203 :: pycodestyle is wrong (https://github.com/psf/black/issues/315)
# and black takes care of it
# - E231 :: same as E203
#
# Other error codes are detailed at https://www.flake8rules.com/
PYCODESTYLE=poetry run pycodestyle
PYCODESTYLE_OPTIONS=\
--ignore=E121,E123,E126,E226,E24,E704,W503,E203,E231 \
--max-line-length=80
TYPECHECK=poetry run mypy
BLACK=poetry run black
PYTHON_SRCS?=conf.py _extensions/*.py scripts/*.py
pylint:
@echo "Linting with pylint, version:"
@poetry run pylint --version | sed 's/^/ /'
$(PYLINT) $(PYTHON_SRCS)
lint_black:
@echo "Running black formatter as style checker"
$(BLACK) --check $(PYTHON_SRCS)
pycodestyle:
@echo "Linting with pycodestyle version `poetry run pycodestyle --version` (`poetry run which pycodestyle`)"
$(PYCODESTYLE) $(PYCODESTYLE_OPTIONS) $(PYTHON_SRCS)
typecheck:
@echo "Typechecking with mypy version `poetry run mypy --version`"
$(TYPECHECK) $(PYTHON_SRCS)
lint: pylint pycodestyle lint_black typecheck
# black options are set in pyproject.toml
black:
@echo "Running black formatter"
$(BLACK) $(PYTHON_SRCS)
fmt: black
clean:
@-rm -Rf "$(BUILDDIR)" linkcheck odoc.log
@-rm -f $(ERRDOCEXE) $(RPCDOCEXE) $(P2PDOCEXE)
@-rm -Rf api/errors.rst developer/metrics.csv user/node-config.json alpha/rpc.rst shell/rpc.rst shell/p2p_api.rst user/default-acl.json CHANGES-dev.rst
@-rm -Rf api/octez-*.html api/octez-*.txt nairobi/octez-*.html alpha/octez-*.html