Skip to content

Commit

Permalink
final fix for readthedoc for Single-sourcing the package version.
Browse files Browse the repository at this point in the history
Add a commented command line in tox conf file to test like readthedoc.
  • Loading branch information
alainivars committed Jun 17, 2019
1 parent 73fed54 commit 3794d38
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
27 changes: 20 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,25 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import re
import sys

sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath('..')) # add fot next line
from docs import version # noqa: E402 pylint: disable=unidiomatic-typecheck
the_version = str(version.__version__)
sys.path.pop() # remove it now because it kill sphinx on readthedoc !!!


def read(f): # from DRF setup
return open(f, 'r', encoding='utf-8').read()


def get_version(package): # from DRF setup
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, 'version.py')).read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)


version = get_version('.')


# -- Project information -----------------------------------------------------
Expand All @@ -27,7 +39,7 @@
author = 'Alain Ivars'

# The full version, including alpha/beta/rc tags
release = the_version
release = version


# -- General configuration ---------------------------------------------------
Expand All @@ -39,7 +51,7 @@
"pygments_pytest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
# "sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
]
Expand All @@ -53,8 +65,9 @@
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
'conf.py',
'links.inc',
'_build',
'_build',
'Thumbs.db',
'.DS_Store'
]
Expand Down
3 changes: 3 additions & 0 deletions docs/releases_notes.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

.. include:: links.inc

Releases Notes
==============
- 0.7.1: doc modular & less duplicated, the docker config file
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ deps =
-r{toxinidir}/requirements_test.txt
commands=
sphinx-build -b html -c {envtmpdir}/../../.. -d {envtmpdir}/doctrees . {envtmpdir}/html
# to check like readthedoc before to commit and push
; sphinx-build -T -E -d _build/doctrees-readthedocs -D language=en . _build/html

[testenv:pep8]
skip_install = True
Expand Down

0 comments on commit 3794d38

Please sign in to comment.