Skip to content

Commit

Permalink
Auto-version docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arnavm committed Aug 7, 2020
1 parent 626a359 commit 28aaa85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# 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.
#
import codecs
import os
import os.path
import sys
sys.path.insert(0, os.path.abspath('../../lib'))

Expand All @@ -21,8 +23,24 @@
copyright = '2019-2020, Arnav Moudgil'
author = 'Arnav Moudgil'


def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()


def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")


# The full version, including alpha/beta/rc tags
release = '0.2.0'
release = get_version("../../lib/blockify/__init__.py")


# -- General configuration ---------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import os.path
import setuptools


def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()


def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
Expand All @@ -15,6 +17,7 @@ def get_version(rel_path):
else:
raise RuntimeError("Unable to find version string.")


with open("README.md", "r") as fh:
long_description = fh.read()

Expand Down

0 comments on commit 28aaa85

Please sign in to comment.