From 0fcb1e4839e1313af0a386098996549eeed29890 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 14 Jul 2019 12:24:45 -0700 Subject: [PATCH] Sphinx docs now pull version info from git tag Based on http://dreamiurg.net/2011/10/03/using-git-to-get-version-information/ --- docs/conf.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 90aed1d..33c4153 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# + +from subprocess import Popen, PIPE + # This file is execfile()d with the current directory set to its # containing dir. # @@ -52,9 +54,15 @@ author = "Simon Willison" # built documents. # # The short X.Y version. -version = "" -# The full version, including alpha/beta/rc tags. -release = "" +pipe = Popen("git describe --tags --always", stdout=PIPE, shell=True) +git_version = pipe.stdout.read().decode("utf8") + +if git_version: + version = git_version + release = git_version +else: + version = "" + release = "" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.