|
16 | 16 | # add these directories to sys.path here. If the directory is relative to the |
17 | 17 | # documentation root, use os.path.abspath to make it absolute, like shown here. |
18 | 18 | # |
| 19 | +import codecs |
19 | 20 | import os |
| 21 | +import re |
20 | 22 | import sys |
21 | 23 |
|
22 | 24 | sys.path.insert(0, os.path.abspath("../src/")) |
| 25 | +# from semver import __version__ # noqa: E402 |
23 | 26 |
|
24 | | -from semver import __version__ # noqa: E402 |
| 27 | + |
| 28 | +def read(*parts): |
| 29 | + """ |
| 30 | + Build an absolute path from *parts* and and return the contents of the |
| 31 | + resulting file. Assume UTF-8 encoding. |
| 32 | + """ |
| 33 | + here = os.path.abspath(os.path.dirname(__file__)) |
| 34 | + with codecs.open(os.path.join(here, *parts), "rb", "utf-8") as f: |
| 35 | + return f.read() |
| 36 | + |
| 37 | + |
| 38 | +def find_version(*file_paths): |
| 39 | + """ |
| 40 | + Build a path from *file_paths* and search for a ``__version__`` |
| 41 | + string inside. |
| 42 | + """ |
| 43 | + version_file = read(*file_paths) |
| 44 | + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) |
| 45 | + if version_match: |
| 46 | + return version_match.group(1) |
| 47 | + raise RuntimeError("Unable to find version string.") |
25 | 48 |
|
26 | 49 |
|
27 | 50 | # -- General configuration ------------------------------------------------ |
|
35 | 58 | # ones. |
36 | 59 | extensions = [ |
37 | 60 | "sphinx.ext.autodoc", |
| 61 | + "sphinx.ext.autosummary", |
38 | 62 | "sphinx_autodoc_typehints", |
39 | 63 | "sphinx.ext.intersphinx", |
40 | | - "sphinx.ext.napoleon", |
41 | 64 | "sphinx.ext.extlinks", |
42 | 65 | ] |
43 | 66 |
|
| 67 | +autoclass_content = "class" |
| 68 | +autodoc_default_options = {} |
| 69 | + |
| 70 | + |
44 | 71 | # Add any paths that contain templates here, relative to this directory. |
45 | 72 | templates_path = ["_templates"] |
46 | 73 |
|
|
62 | 89 | # built documents. |
63 | 90 | # |
64 | 91 | # The short X.Y version. |
65 | | -version = __version__ |
| 92 | +release = find_version("../src/semver/__about__.py") |
66 | 93 | # The full version, including alpha/beta/rc tags. |
67 | | -release = version |
| 94 | +version = release # .rsplit(u".", 1)[0] |
68 | 95 |
|
69 | 96 | # The language for content autogenerated by Sphinx. Refer to documentation |
70 | 97 | # for a list of supported languages. |
71 | 98 | # |
72 | 99 | # This is also used if you do content translation via gettext catalogs. |
73 | 100 | # Usually you set "language" from the command line for these cases. |
74 | | -language = None |
| 101 | +language = "en" |
75 | 102 |
|
76 | 103 | # List of patterns, relative to source directory, that match files and |
77 | 104 | # directories to ignore when looking for source files. |
|
0 commit comments