diff --git a/Dockerfile.test b/Dockerfile.test index c0e0927b..f3141e20 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -19,6 +19,7 @@ RUN dnf -y install \ python3-pytoml \ python3-semantic_version \ python3-sphinx \ + python3-sphinx-argparse \ python3-sphinx_rtd_theme \ python3-rpmfluff \ python3-librepo \ diff --git a/Makefile b/Makefile index 5805c4be..1d9edc48 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ DESTDIR ?= / PREFIX ?= /usr mandir ?= $(PREFIX)/share/man DOCKER ?= docker +DOCS_VERSION ?= next PKGNAME = lorax VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec) @@ -88,6 +89,10 @@ tag: docs: $(MAKE) -C docs apidoc html man +# This is needed to reset the ownership of the new docs files after they are created in a container +set-docs-owner: + chown -R $(LOCAL_UID):$(LOCAL_GID) docs/ + archive: @git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(TAG) > $(PKGNAME)-$(VERSION).tar @gzip $(PKGNAME)-$(VERSION).tar @@ -116,7 +121,11 @@ test-in-docker: sudo $(DOCKER) run --rm -it -v `pwd`/.test-results/:/test-results -v `pwd`:/lorax-ro:ro --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make test-in-copy docs-in-docker: - sudo $(DOCKER) run -it --rm -v `pwd`/docs/html/:/lorax/docs/html/ --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs + sudo $(DOCKER) run -it --rm -v `pwd`:/lorax-ro:ro \ + -v `pwd`/docs/:/lorax-ro/docs/ \ + --env LORAX_VERSION=$(DOCS_VERSION) \ + --env LOCAL_UID=`id -u` --env LOCAL_GID=`id -g` \ + --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs set-docs-owner ci: check test diff --git a/docs/conf.py b/docs/conf.py index ca6a36c1..c5905247 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -56,19 +56,32 @@ copyright = u'2018, Red Hat, Inc.' # pylint: disable=redefined-builtin # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. +# Pass in LORAX_VERSION to set a specific version +# Set LORAX_VERSION=next to bump it to the next release def read_version(): - """Read version from $LORAX_VERSION or ../lorax.spec""" + """Read version from $LORAX_VERSION or ../lorax.spec, or bump the version from lorax.spec""" # This allows the .spec version to be overridded. eg. when documenting an upcoming release - if "LORAX_VERSION" in os.environ: + if "LORAX_VERSION" in os.environ and "next" not in os.environ["LORAX_VERSION"]: return os.environ["LORAX_VERSION"] + doc_version = None import re version_re = re.compile(r"Version:\s+(.*)") with open("../lorax.spec", "rt") as f: for line in f: m = version_re.match(line) if m: - return m.group(1) + doc_version = m.group(1) + if not doc_version: + raise RuntimeError("Failed to find current version") + + # Make it easier to generate docs for the next release + if "next" in os.environ["LORAX_VERSION"]: + fields = doc_version.split(".") + fields[-1] = str(int(fields[-1]) + 1) + doc_version = ".".join(fields) + + return doc_version # # The short X.Y version.