|
12 | 12 | # serve to show the default.
|
13 | 13 |
|
14 | 14 | import sys, os
|
| 15 | +import pathlib |
| 16 | +import re |
15 | 17 |
|
16 | 18 | # If extensions (or modules to document with autodoc) are in another directory,
|
17 | 19 | # add these directories to sys.path here. If the directory is relative to the
|
18 | 20 | # documentation root, use os.path.abspath to make it absolute, like shown here.
|
19 | 21 | #sys.path.append(os.path.abspath('.'))
|
20 | 22 |
|
| 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 | + |
21 | 39 | # -- General configuration -----------------------------------------------------
|
22 | 40 |
|
23 | 41 | # Add any Sphinx extension module names here, as strings. They can be extensions
|
|
41 | 59 |
|
42 | 60 | # General information about the project.
|
43 | 61 | project = u'pySerial-asyncio'
|
44 |
| -copyright = u'2015-2020, pySerial-team' |
| 62 | +copyright = u'2015-2021, pySerial-team' |
45 | 63 |
|
46 | 64 | # The version info for the project you're documenting, acts as replacement for
|
47 | 65 | # |version| and |release|, also used in various other places throughout the
|
48 | 66 | # built documents.
|
49 | 67 | #
|
50 | 68 | # The short X.Y version.
|
51 |
| -version = '0.5' |
| 69 | +version = find_version(pathlib.Path(__file__).parent.parent / 'serial_asyncio' / '__init__.py') |
52 | 70 | # The full version, including alpha/beta/rc tags.
|
53 |
| -release = '0.5' |
| 71 | +release = version |
54 | 72 |
|
55 | 73 | # The language for content autogenerated by Sphinx. Refer to documentation
|
56 | 74 | # for a list of supported languages.
|
|
0 commit comments