diff --git a/docs/Makefile b/docs/Makefile index 2c2b837..c896264 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,44 +1,50 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = _build HTMLDIR = $(BUILDDIR)/html INSTALL_HOST = pergamon.internal.softwareheritage.org INSTALL_DIR = /srv/softwareheritage/docs/webroot/devel INSTALL_GROUP = swhdev INSTALL_PERMS = g+rwX + html: sphinx/html -sphinx/html: links-stamp apidoc-stamp +sphinx/html: links-stamp apidoc-stamp images-stamp links-stamp: bin/ln-sphinx-subprojects touch $@ apidoc-stamp: - make -C ../../ docs-apidoc + $(MAKE) -C ../../ docs-apidoc + touch $@ + +images-stamp: + $(MAKE) -C images touch $@ clean: sphinx/clean bin/ln-sphinx-subprojects --remove + $(MAKE) -C images clean rm -f *-stamp distclean: clean make -C ../../ docs-clean help: sphinx/help @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) sphinx/%: @$(SPHINXBUILD) -M $* "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) install: html test -d $(HTMLDIR) rsync -avuz $(BUILDDIR)/html/ $(INSTALL_HOST):$(INSTALL_DIR)/ ssh $(INSTALL_HOST) \ "chgrp -R $(INSTALL_GROUP) $(INSTALL_DIR) ; \ chmod -R $(INSTALL_PERMS) $(INSTALL_DIR) ; \ find $(INSTALL_DIR) -type d -exec chmod g+s {} +" .PHONY: help html clean distclean install diff --git a/docs/bin/py-depgraph b/docs/bin/py-depgraph new file mode 100755 index 0000000..dae46ce --- /dev/null +++ b/docs/bin/py-depgraph @@ -0,0 +1,65 @@ +#!/bin/bash + +# generate dependency graph (in DOT(1) format) for all known python modules +# +# include by default both internal and external dependencies, but can asked to +# include either or none of them (see --help) + +if [ ! -d swh-core -o ! -f pythonpath.sh ] ; then + echo "Error: you do not appear to be located in swh-environment dir," + echo "but this script should be run from there. Abort." + exit 2 +fi + +internal_modules=1 +external_modules=1 +while [ -n "$1" ] ; do + if [ "$1" = "--no-internal" ] ; then + internal_modules=0 + elif [ "$1" = "--no-external" ] ; then + external_modules=0 + elif [ "$1" = "--help" -o "$1" = "-h" ] ; then + echo "Usage: bin/py-depgraph [--no-internal] [--no-external] > FILE.dot" + exit 1 + fi + shift 1 +done + +pyrepos=$(bin/ls-py-modules) # available python repositories (with '-') + +declare -A pymods # available python modules (with '.') +for repo in $pyrepos ; do + pymod=${repo//-/.} + pymods[$pymod]=1 +done + +echo "digraph swh_py_deps {" + +for pymod in ${!pymods[@]} ; do + echo -e "\t\"$pymod\" ;" +done + +getdeps() { + grep -E -v '(^#|^[[:space:]]*$)' "$1" | cut -f 1 -d ' ' | tr 'A-Z' 'a-z' +} + +for repo in $pyrepos ; do + pymod=${repo//-/.} + reqs_int="${repo}/requirements-swh.txt" + reqs_ext="${repo}/requirements.txt" + + if [ "$internal_modules" -eq 1 -a -f "$reqs_int" ]; then + for dep in $( getdeps "$reqs_int" ) ; do + echo -e "\t\"${pymod}\" -> \"${dep}\" ;" + done + fi + + if [ "$external_modules" -eq 1 -a -f "$reqs_ext" ]; then + for dep in $( getdeps "$reqs_ext" ) ; do + echo -e "\t\"${dep}\" [style=dashed] ;" + echo -e "\t\"${pymod}\" -> \"${dep}\" ;" + done + fi +done | sort -u + +echo "}" diff --git a/docs/images/.gitignore b/docs/images/.gitignore new file mode 100644 index 0000000..2ae7901 --- /dev/null +++ b/docs/images/.gitignore @@ -0,0 +1,2 @@ +py-deps-*.dot +py-deps-*.pdf diff --git a/docs/images/Makefile b/docs/images/Makefile new file mode 100644 index 0000000..0da305a --- /dev/null +++ b/docs/images/Makefile @@ -0,0 +1,21 @@ + +PY_REQUIREMENTS = $(wildcard ../../../*/requirements*.txt) +DEP_GRAPHS = py-deps-all.pdf py-deps-swh.pdf py-deps-ext.pdf +PY_DEPGRAPH = ../bin/py-depgraph + +all: $(DEP_GRAPHS) + +py-deps-all.dot: $(PY_DEPGRAPH) $(PY_REQUIREMENTS) + cd ../../.. ; $(CURDIR)/$(PY_DEPGRAPH) > $(CURDIR)/$@ + +py-deps-swh.dot: $(PY_DEPGRAPH) $(PY_REQUIREMENTS) + cd ../../.. ; $(CURDIR)/$(PY_DEPGRAPH) --no-external > $(CURDIR)/$@ + +py-deps-ext.dot: $(PY_DEPGRAPH) $(PY_REQUIREMENTS) + cd ../../.. ; $(CURDIR)/$(PY_DEPGRAPH) --no-internal > $(CURDIR)/$@ + +%.pdf: %.dot + dot -T pdf $< > $@ + +clean: + -rm -f $(DEP_GRAPHS) $(patsubst %.pdf,%.dot,$(DEP_GRAPHS))