diff --git a/docs/Makefile b/docs/Makefile index 0b13155..c98428a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,66 +1,71 @@ SPHINXOPTS ?= SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = _build HTMLDIR = $(BUILDDIR)/html SWHPKGDIR ?= sources/swh/ INSTALL_HOST = pergamon.internal.softwareheritage.org INSTALL_DIR = /srv/softwareheritage/docs/webroot/devel INSTALL_GROUP = swhdev INSTALL_PERMS = g+rwX SPHINXAPIDOC = sphinx-apidoc APIDOC_DIR = apidoc APIDOC_OPTS = --ext-viewcode --separate APIDOC_EXCLUDES = */tests */tests/* */*/tests/* */*/*/tests/* APIDOC_EXCLUDES += */migrations */migrations/* */*/migrations/* */*/*/migrations/* APIDOC_EXCLUDES += */wsgi.py */*/wsgi.py */*/*/wsgi.py */*/*/wsgi.py APIDOC_EXCLUDES += deposit/settings/* web/settings/* dataset/* APIDOC_SWH_EXCLUDES = $(patsubst %,$(SWHPKGDIR)/%,$(APIDOC_EXCLUDES)) html: sphinx/html -sphinx/html: apidoc-stamp images-stamp rec-build-stamp +sphinx/html: links-stamp apidoc-stamp images-stamp rec-build-stamp + +links-stamp: + bin/ln-sphinx-subprojects + touch $@ apidoc: apidoc-stamp -apidoc-stamp: images-stamp +apidoc-stamp: links-stamp images-stamp $(SPHINXAPIDOC) --implicit-namespaces $(APIDOC_OPTS) -o $(APIDOC_DIR) $(SWHPKGDIR) $(APIDOC_SWH_EXCLUDES) touch $@ images-stamp: $(MAKE) -C images touch $@ # Build documentation recursively in all packages, to make sure that auxiliary, # non-sphinx managed documentation artifacts (e.g., schema diagrams) are also # built. rec-build-stamp: $(wildcard ../../swh-*/docs/*.rst) $(MAKE) -C ../../ docs-assets touch $@ clean: sphinx/clean + bin/ln-sphinx-subprojects --remove $(MAKE) -C images clean rm -f *-stamp rm -f $(APIDOC_DIR)/* distclean: clean make -C ../../ docs-clean help: sphinx/help sphinx/clean: $(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) sphinx/%: $(SPHINXBUILD) -b $* "$(SOURCEDIR)" "$(BUILDDIR)/$*" $(SPHINXOPTS) install: html test -d $(HTMLDIR) rsync -rlvuz --delete $(BUILDDIR)/html/ $(INSTALL_HOST):$(INSTALL_DIR)/ ssh $(INSTALL_HOST) \ "find $(INSTALL_DIR) -not -group $(INSTALL_GROUP) -exec chgrp -v $(INSTALL_GROUP) {} + ; \ find $(INSTALL_DIR) -not -perm -ug=rw,o=r -exec chmod -v ug+rw,o+r {} + ; \ find $(INSTALL_DIR) -type d -not -perm -g=xs,ou=x -exec chmod -v g+xs,ou+x {} +" .PHONY: help html clean distclean install diff --git a/docs/bin/ln-sphinx-subprojects b/docs/bin/ln-sphinx-subprojects new file mode 100755 index 0000000..718ce09 --- /dev/null +++ b/docs/bin/ln-sphinx-subprojects @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +create_links () { + mkdir -p sources + for pymodule in $(cd ../../ && bin/ls-py-modules) ; do + if [ "$pymodule" = 'swh-docs' ] ; then + continue + fi + if [ ! -e "$pymodule" -a -d "../../${pymodule}/docs" ] ; then + ln -s "../../${pymodule}/docs" "$pymodule" + fi + done +} + +remove_links () { + for pymodule in $(cd ../../ && bin/ls-py-modules) ; do + if [ "$pymodule" = 'swh-docs' ] ; then + continue + fi + if [ -L "$pymodule" ] ; then + rm "$pymodule" + fi + done +} + +if [ "$1" = "--remove" ] ; then + remove_links +else + create_links +fi diff --git a/tox.ini b/tox.ini index 6cbd508..a5c3e6b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,41 +1,41 @@ [tox] envlist=flake8,black [testenv] basepython = python3 passenv = SPHINXOPTS JAVA_HOME [testenv:sphinx] extras = building deps = django < 3 pifpaf setenv = SWHPKGDIR = {envsitepackagesdir}/swh commands = {envpython} -m pifpaf run postgresql -- make -C docs {posargs:html} [testenv:sphinx-dev] -setenv = - SWHPKGDIR = {envsitepackagesdir}/swh deps = django < 3 -rrequirements-swh-dev.txt pifpaf +setenv = + SWHPKGDIR = {envsitepackagesdir}/swh commands = {envpython} -m pifpaf run postgresql -- make -C docs {posargs:html} [testenv:black] skip_install = true deps = black commands = {envpython} -m black --check swh [testenv:flake8] skip_install = true deps = flake8 commands = {envpython} -m flake8