|
14 | 14 | # |
15 | 15 | import os |
16 | 16 | import sys |
17 | | -import econml |
| 17 | +import re |
| 18 | + |
18 | 19 | sys.path.insert(0, os.path.abspath('econml')) |
19 | 20 |
|
20 | 21 |
|
|
23 | 24 | project = 'econml' |
24 | 25 | copyright = '2019, Microsoft Research' |
25 | 26 | author = 'Microsoft Research' |
26 | | -version = econml.__version__ |
27 | | -release = econml.__version__ |
| 27 | + |
| 28 | +# TODO: this seems much hackier than if we could just import econml and access the version directly |
| 29 | +# but with sphinx-multiversion we can't do that |
| 30 | +with open(os.path.join(os.path.dirname(__file__), '..', "econml", "_version.py")) as file: |
| 31 | + for line in file: |
| 32 | + m = re.fullmatch("__version__ = '([^']+)'\n", line) |
| 33 | + if m: |
| 34 | + version = m.group(1) |
| 35 | + release = version |
28 | 36 |
|
29 | 37 | # -- General configuration --------------------------------------------------- |
30 | 38 |
|
|
46 | 54 | 'sphinx.ext.mathjax', |
47 | 55 | 'sphinx.ext.viewcode', |
48 | 56 | 'sphinx.ext.inheritance_diagram', |
| 57 | + "sphinx_multiversion" |
49 | 58 | ] |
50 | 59 | inheritance_graph_attrs = dict(rankdir="TB", size='"7.0, 10.0"', |
51 | 60 | fontsize=12, ratio='auto', |
|
99 | 108 | # The name of the Pygments (syntax highlighting) style to use. |
100 | 109 | pygments_style = None |
101 | 110 |
|
| 111 | +# sphinx_multiversion configuration |
| 112 | +smv_tag_whitelist = r'^v0\.(12\.0|13\.0)$' |
| 113 | +smv_branch_whitelist = '^main$' |
| 114 | +smv_latest_version = 'v0.13.0' |
| 115 | +smv_released_pattern = '^refs/tags/.+$' |
102 | 116 |
|
103 | 117 | # -- Options for HTML output ------------------------------------------------- |
104 | 118 |
|
|
215 | 229 |
|
216 | 230 | # Example configuration for intersphinx: refer to the Python standard library. |
217 | 231 | intersphinx_mapping = {'python': ('https://docs.python.org/3', None), |
218 | | - 'numpy': ('https://docs.scipy.org/doc/numpy/', None), |
| 232 | + 'numpy': ('https://numpy.org/doc/stable/', None), |
219 | 233 | 'sklearn': ('https://scikit-learn.org/stable/', None), |
220 | 234 | 'matplotlib': ('https://matplotlib.org/', None), |
221 | 235 | 'shap': ('https://shap.readthedocs.io/en/stable/', None), |
@@ -244,5 +258,13 @@ def exclude_entity(app, what, name, obj, skip, opts): |
244 | 258 |
|
245 | 259 |
|
246 | 260 | def setup(app): |
| 261 | + # HACK: ensure that we build extensions in place first |
| 262 | + # Will not be necessary if one of the PRs addressing https://github.com/Holzhaus/sphinx-multiversion/issues/45 |
| 263 | + # is merged into sphinx-multiversion |
| 264 | + import subprocess |
| 265 | + print("Building extensions") |
| 266 | + subprocess.call(["python", "setup.py", "build_ext", "-i"]) |
| 267 | + |
| 268 | + # Hook up our method for skipping entities |
247 | 269 | app.connect('autodoc-skip-member', exclude_entity) |
248 | 270 | () |
0 commit comments