evennia/docs/Makefile

165 lines
5.7 KiB
Makefile
Raw Normal View History

2020-05-22 00:56:04 +02:00
# Makefile to control Evennia documentation building.
# Most common commands are `make help`, `make quick` and `make local`.
2020-07-10 17:58:07 +02:00
SOURCEDIR = source
BUILDDIR = build
AUTODOCDIR = $(SOURCEDIR)/api
2022-02-05 16:05:12 +01:00
2020-04-05 00:02:02 +02:00
# You can set these variables from the command line, and also
# from the environment for the first two.
2020-04-05 16:50:52 +02:00
SPHINXOPTS ?=
2020-04-05 00:02:02 +02:00
SPHINXBUILD ?= sphinx-build
2020-04-05 13:26:57 +02:00
SPHINXMULTIVERSION ?= sphinx-multiversion
SPHINXAPIDOC ?= sphinx-apidoc
2020-07-10 17:58:07 +02:00
SPHINXAPIDOCOPTS = --tocfile evennia-api --module-first --force -d 6 --separate --templatedir=$(SOURCEDIR)/_templates/
2021-10-21 21:04:14 +02:00
SPHINXAPIDOCOPTSQUICK = --tocfile evennia-api --module-first -d 6 --separate --templatedir=$(SOURCEDIR)/_templates/
2020-04-07 23:13:24 +02:00
SPHINXAPIDOCENV = members,undoc-members,show-inheritance
2020-07-10 18:04:55 +02:00
SPHINXAPIDOCEXCLUDE = ../*/migrations/* ../evennia/game_template/* ../evennia/*/tests/* ../evennia/*/tests.py
2020-04-05 00:02:02 +02:00
2020-04-05 11:37:35 +02:00
EVDIR ?= $(realpath ../evennia)
2020-04-05 00:02:02 +02:00
EVGAMEDIR ?= $(realpath ../../gamedir)
2020-04-05 15:02:38 +02:00
cblue = $(shell echo "\033[1m\033[34m")
cnorm = $(shell echo "\033[0m")
2020-06-19 18:53:36 +02:00
# set specific files to only run for quick run (even if unset, will still not build new api docs)
QUICKFILES=
2020-04-05 15:02:38 +02:00
2020-04-05 00:02:02 +02:00
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Evennia-specific: "
2021-10-21 21:04:14 +02:00
@echo " $(cblue)install$(cnorm) to get doc build requirements"
2020-04-05 15:02:38 +02:00
@echo " $(cblue)clean$(cnorm) to remove remnants of a previous build"
2021-10-21 21:04:14 +02:00
@echo " $(cblue)quick$(cnorm) to build local docs but skip the autodocs (for quick testing)"
@echo " $(cblue)quickstrict$(cnorm) to build like 'quick' but abort immediately on any error"
2020-04-05 15:02:38 +02:00
@echo " $(cblue)local$(cnorm) to build local html docs of the current branch (no multiversion)."
2021-10-26 21:34:32 +02:00
@echo " $(cblue)localupdate$(cnorm) to build local html docs (only update changes)"
2020-06-14 20:19:31 +02:00
@echo " $(cblue)mv-local$(cnorm) to build multiversion html docs, without deploying (req: local git commit first)"
@echo " $(cblue)deploy$(cnorm) to deploy previously built multiversion docs online (req: commit and github push access)"
@echo " $(cblue)release$(cnorm) to build + deploy multiversion docs online (req: commit and github push access)"
2020-04-05 15:02:38 +02:00
2020-04-05 00:02:02 +02:00
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
2020-04-05 13:00:01 +02:00
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2020-04-05 00:02:02 +02:00
# Evennia - custom commands
2020-04-05 16:50:52 +02:00
# helper targets
2020-04-05 00:02:02 +02:00
2020-04-05 13:19:32 +02:00
_check-env:
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) bash -e checkenv.sh
2020-04-05 00:02:02 +02:00
2020-04-05 13:19:32 +02:00
_multiversion-check-env:
2020-04-05 13:00:01 +02:00
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) bash -e checkenv.sh multiversion
2020-04-07 23:13:24 +02:00
_clean_api_index:
rm source/api/*
2020-10-12 22:19:22 +02:00
# remove superfluos 'module' and 'package' text from api headers
2020-06-18 23:30:11 +02:00
_reformat_apidoc_headers:
for f in source/api/*.rst; do\
perl -pi -e 's/(module|package)$$// if $$. == 1' $$f ;\
done
2020-04-05 13:19:32 +02:00
_autodoc-index:
2020-06-18 23:30:11 +02:00
make _clean_api_index
2020-04-07 23:13:24 +02:00
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) SPHINX_APIDOC_OPTIONS=$(SPHINXAPIDOCENV) $(SPHINXAPIDOC) $(SPHINXAPIDOCOPTS) -o $(SOURCEDIR)/api/ $(EVDIR) $(SPHINXAPIDOCEXCLUDE)
2020-06-18 23:30:11 +02:00
make _reformat_apidoc_headers
2021-10-21 21:04:14 +02:00
pylib/api_rst2md.py
_quick_autodoc-index:
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) SPHINX_APIDOC_OPTIONS=$(SPHINXAPIDOCENV) $(SPHINXAPIDOC) $(SPHINXAPIDOCOPTSQUICK) -o $(SOURCEDIR)/api/ $(EVDIR) $(SPHINXAPIDOCEXCLUDE)
2020-04-05 13:19:32 +02:00
_multiversion-autodoc-index:
2021-01-30 15:57:23 +01:00
make _autodoc-index
2020-10-13 18:46:02 +02:00
git diff-index --quiet HEAD || git commit -a -m "Updated API autodoc index." || :
2020-04-05 13:00:01 +02:00
2020-06-14 20:19:31 +02:00
_html-build:
2020-04-05 15:02:38 +02:00
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html"
2020-06-14 20:19:31 +02:00
_quick-html-build:
2020-04-05 16:50:52 +02:00
@NOAUTODOC=1 EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(QUICKFILES)
2020-04-05 13:19:32 +02:00
_multiversion-build:
@EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXMULTIVERSION) $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS)
2020-04-05 13:00:01 +02:00
2020-04-05 13:19:32 +02:00
_multiversion-deploy:
2020-04-05 00:02:02 +02:00
@bash -e deploy.sh
2020-06-14 20:19:31 +02:00
_latex-build:
@NOAUTODOC=1 EVDIR=$(EVDIR) EVGAMEDIR=$(EVGAMEDIR) $(SPHINXBUILD) -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)/latex" $(QUICKFILES)
2020-04-05 00:02:02 +02:00
2021-03-20 10:47:57 +01:00
install:
2020-04-05 13:19:32 +02:00
@pip install -r requirements.txt
clean:
@rm -Rf $(BUILDDIR)
2020-10-12 22:19:22 +02:00
@git clean -f -d docs/
2020-04-05 13:19:32 +02:00
@echo "Cleaned old build dir and leftover files."
2020-06-14 20:19:31 +02:00
# not fully working at this time
pdf:
make _latex-build
@echo ""
@echo "Documentation built (single version, no autodocs)."
@echo "To see result, open evennia/docs/build/latex/evennia.pdf in a PDF reader."
2020-04-05 15:02:38 +02:00
quick:
2022-01-21 00:47:11 +01:00
make _check-env
2021-10-21 21:04:14 +02:00
make _quick_autodoc-index
2022-01-21 00:47:11 +01:00
make _html-build
2020-04-05 15:02:38 +02:00
@echo ""
2020-06-14 20:19:31 +02:00
@echo "Documentation built (single version, no autodocs)."
@echo "To see result, open evennia/docs/build/html/index.html in a browser."
2020-04-05 15:02:38 +02:00
2022-01-21 00:58:26 +01:00
# abort on warnings too (not working atm)
2020-10-12 22:19:22 +02:00
quickstrict:
SPHINXOPTS=-W make quick
2021-02-24 19:27:55 +01:00
# we build index directly for the current branch
2020-04-05 16:50:52 +02:00
local:
2020-04-05 13:19:32 +02:00
make _check-env
2020-04-05 16:50:52 +02:00
make clean
2020-04-05 15:02:38 +02:00
make _autodoc-index
2020-06-14 20:19:31 +02:00
make _html-build
2020-04-05 13:22:51 +02:00
@echo ""
2020-06-14 20:19:31 +02:00
@echo "Documentation built (single version)."
@echo "To see result, open evennia/docs/build/html/index.html in a browser."
2021-10-21 21:04:14 +02:00
2021-05-08 10:09:04 +02:00
# build only that which updated since last run (no clean or index-creation)
localupdate:
make _check-env
make _html-build
@echo ""
@echo "Documentation built (single version, only updates, no auto-index)."
@echo "To see result, open evennia/docs/build/html/index.html in a browser."
2020-04-05 13:19:32 +02:00
2021-02-24 19:27:55 +01:00
# note that this should be done for each relevant multiversion branch.
mv-index:
make _multiversion-autodoc-index
@echo "(Re)Built and committed api rst files for this branch only."
2020-04-05 13:00:01 +02:00
mv-local:
2020-04-05 13:19:32 +02:00
make _multiversion-check-env
2020-04-05 00:02:02 +02:00
make clean
2020-04-05 13:19:32 +02:00
make _multiversion-build
2020-06-14 20:19:31 +02:00
@echo ""
@echo "Documentation built (multiversion + autodocs)."
@echo "To see result, open evennia/docs/build/html/<version>/index.html in a browser."
2020-04-05 13:00:01 +02:00
2020-04-05 15:02:38 +02:00
deploy:
make _multiversion-deploy
2020-06-14 20:19:31 +02:00
@echo "Documentation deployed."
2020-04-05 15:02:38 +02:00
2020-04-05 13:00:01 +02:00
# build and prepare the docs for release
2022-01-25 23:49:19 +01:00
#
2020-04-05 13:19:32 +02:00
release:
2020-04-05 13:00:01 +02:00
make mv-local
2020-06-13 00:13:16 +02:00
make deploy
2020-06-14 20:19:31 +02:00
@echo "Release complete."