test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] dts: add version file and enable it in doc conf.py
@ 2017-08-29 15:06 Marvin Liu
  0 siblings, 0 replies; only message in thread
From: Marvin Liu @ 2017-08-29 15:06 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

When Sphinx building doc, version of DTS can be stripped from source
code and inserted to html header.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/doc/dts_gsg/conf.py b/doc/dts_gsg/conf.py
index 568150e..fa5f0e4 100644
--- a/doc/dts_gsg/conf.py
+++ b/doc/dts_gsg/conf.py
@@ -27,6 +27,7 @@
 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import subprocess
 
 try:
     import sphinx_rtd_theme
@@ -38,4 +39,10 @@ except:
 
 project = 'DPDK Test Suite'
 copyright = '2017, dpdk.org'
+
+strip_version_cmd = 'import sys;sys.path.append(\'../..\');import version; print version.dts_version()'
+version = subprocess.check_output(['python', '-c', strip_version_cmd])
+version = version.decode('utf-8').rstrip()
+release = version
+
 master_doc = 'index'
diff --git a/version.py b/version.py
new file mode 100755
index 0000000..f657133
--- /dev/null
+++ b/version.py
@@ -0,0 +1,19 @@
+# <COPYRIGHT_TAG>
+
+VERSION_MAJOR = "17"
+VERSION_MINOR = "08"
+VERSION_PATCH = "0"
+VERSION_EXTRA = ""
+
+__version__ = '%s.%s.%s' % (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
+
+if VERSION_EXTRA:
+    __version__ = "%s-%s" % (__version__, VERSION_EXTRA)
+
+def dts_version():
+    """
+    Return the version of dts package
+    """
+    return __version__
+
+__all__ = ['dts_version', '__version__']
-- 
1.9.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-08-29 15:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 15:06 [dts] [PATCH] dts: add version file and enable it in doc conf.py Marvin Liu

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).