From 44c2b38cdef0a2f8bda14df36717bec2c4aae0cd Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 31 Jan 2015 06:01:52 +0100 Subject: [PATCH] use version from package init also for sphinx docs, insert toplevel dir into sys.path --- docs/conf.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index fbcd61065..dce5e21d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,13 +12,28 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys +import codecs import os +import re +import sys + + +def read_file(filename, encoding='utf8'): + """Read unicode from given file.""" + with codecs.open(filename, encoding=encoding) as fd: + return fd.read() + + +here = os.path.abspath(os.path.dirname(__file__)) + +# read version number (and other metadata) from package init +init_fn = os.path.join(here, '..', 'letsencrypt', '__init__.py') +meta = dict(re.findall(r"""__([a-z]+)__ = "([^"]+)""", read_file(init_fn))) # 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 # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath(os.path.join(here, '..'))) # -- General configuration ------------------------------------------------ @@ -58,9 +73,9 @@ copyright = u'2014, Let\'s Encrypt Project' # built documents. # # The short X.Y version. -version = '0.1' +version = '.'.join(meta['version'].split('.')[:2]) # The full version, including alpha/beta/rc tags. -release = '0.1' +release = meta['version'] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.