File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1212# serve to show the default.
1313
1414import sys , os
15+ import pathlib
16+ import re
1517
1618# If extensions (or modules to document with autodoc) are in another directory,
1719# add these directories to sys.path here. If the directory is relative to the
1820# documentation root, use os.path.abspath to make it absolute, like shown here.
1921#sys.path.append(os.path.abspath('.'))
2022
23+ def find_version (path : pathlib .Path ):
24+ """
25+ Search the file for a version string.
26+
27+ file_path contain string path components.
28+
29+ Reads the supplied Python module as text without importing it.
30+ """
31+ version_file = path .read_text ()
32+ version_match = re .search (r"^__version__ = ['\"]([^'\"]*)['\"]" ,
33+ version_file , re .M )
34+ if version_match :
35+ return version_match .group (1 )
36+ raise RuntimeError ("Unable to find version string." )
37+
38+
2139# -- General configuration -----------------------------------------------------
2240
2341# Add any Sphinx extension module names here, as strings. They can be extensions
4866# built documents.
4967#
5068# The short X.Y version.
51- version = '0.5'
69+ version = find_version ( pathlib . Path ( __file__ ). parent . parent / 'serial_asyncio' / '__init__.py' )
5270# The full version, including alpha/beta/rc tags.
53- release = '0.5'
71+ release = version
5472
5573# The language for content autogenerated by Sphinx. Refer to documentation
5674# for a list of supported languages.
You can’t perform that action at this time.
0 commit comments