devicetree-spec.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Extract document version from git tag
@ 2017-12-07 16:33 Grant Likely
       [not found] ` <20171207163306.24679-1-grant.likely-5wv7dgnIgG8@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Grant Likely @ 2017-12-07 16:33 UTC (permalink / raw)
  To: robh-DgEjT+Ai2ygdnm+yROfE0A,
	devicetree-spec-u79uwXL29TY76Z2rM5mHXA
  Cc: Grant Likely

Instead of hard coding the document version in the config file, use
'git describe' to get the version number from the tags and use that.
Just like before, if the version string contains a '-', then it is not
an official release and a watermark will be added to the PDF. This
catches prereleases "-pre*", untagged revisions "-g<hash>", and
uncommitted changes "-dirty".

Signed-off-by: Grant Likely <grant.likely-5wv7dgnIgG8@public.gmane.org>
---
 source/conf.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source/conf.py b/source/conf.py
index 54b87ef..6bb639c 100644
--- a/source/conf.py
+++ b/source/conf.py
@@ -15,6 +15,7 @@
 import sys
 import os
 import time
+import subprocess
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -64,7 +65,10 @@ author = u'devicetree.org'
 # built documents.
 #
 # The short X.Y version.
-version = u'0.2-pre2'
+try:
+    version = subprocess.check_output(["git", "describe", "--dirty"]).strip()
+except:
+    version = "unknown-rev"
 # The full version, including alpha/beta/rc tags.
 release = version
 
@@ -79,7 +83,7 @@ language = None
 # non-false value, then it is used:
 #today = ''
 # Else, today_fmt is used as the format for a strftime call.
-today_fmt = '%d %B %Y'
+today_fmt = '%d %b %Y'
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
@@ -253,7 +257,7 @@ latex_elements = {
 
 # Release numbers with a qualifier (ex. '-rc', '-pre') get a watermark.
 if '-' in release:
-    latex_elements['preamble'] = '\\usepackage{draftwatermark}\\SetWatermarkScale{.45}\\SetWatermarkText{DRAFT v%s %s}' % (release, time.strftime(today_fmt))
+    latex_elements['preamble'] = '\\usepackage{draftwatermark}\\SetWatermarkScale{.45}\\SetWatermarkText{%s}' % (release)
 
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-07 17:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-07 16:33 [PATCH] Extract document version from git tag Grant Likely
     [not found] ` <20171207163306.24679-1-grant.likely-5wv7dgnIgG8@public.gmane.org>
2017-12-07 17:01   ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).