[dts] [PATCH] dts: add version file and enable it in doc conf.py

Marvin Liu yong.liu at intel.com
Tue Aug 29 17:06:51 CEST 2017


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 at 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



More information about the dts mailing list