|
8 | 8 | import sphinx_rtd_theme |
9 | 9 | from sphinx.ext.apidoc import main |
10 | 10 |
|
| 11 | +web_docs = False |
| 12 | +if 'PSIJ_WEB_DOCS' in os.environ: |
| 13 | + web_docs = True |
| 14 | + |
11 | 15 | needs_sphinx = '1.6' |
12 | 16 |
|
13 | 17 | # Set Sphinx variables |
14 | 18 | master_doc = 'index' |
15 | 19 |
|
16 | 20 | project = u'PSI/J' |
17 | 21 | copyright = u'The ExaWorks Team' |
18 | | - |
19 | | -html_theme = 'sphinx_rtd_theme' |
20 | | -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
| 22 | +if web_docs: |
| 23 | + html_theme = 'cloud' |
| 24 | +else: |
| 25 | + html_theme = 'sphinx_rtd_theme' |
| 26 | + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
21 | 27 | html_favicon = 'favicon.ico' |
22 | 28 | autoclass_content = 'both' |
23 | 29 | add_module_names = False |
|
28 | 34 | ('py:class', 'distutils.version.Version') |
29 | 35 | ] |
30 | 36 |
|
| 37 | +if web_docs: |
| 38 | + templates_path = ['_templates'] |
| 39 | + # Multi-version |
| 40 | + smv_branch_whitelist = '^mathcmeifyoucan$' |
| 41 | + smv_remote_whitelist = None |
| 42 | + smv_released_pattern = r'^\d+\.\d+\.\d+(\..*)?$' |
| 43 | + smv_outputdir_format = 'v/{ref.name}' |
| 44 | + |
| 45 | + |
31 | 46 | html_sidebars = {'**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html']} |
| 47 | +if web_docs: |
| 48 | + html_sidebars['**'].insert(0, 'versioning.html') |
32 | 49 |
|
33 | 50 | # These are needed for the dhtml trickery |
34 | 51 | html_static_path = ["_static"] |
|
44 | 61 | 'sphinx.ext.viewcode', |
45 | 62 | ] |
46 | 63 |
|
| 64 | +if web_docs: |
| 65 | + extensions.append('sphinx_multiversion') |
| 66 | + |
47 | 67 | autodoc_typehints = "description" |
48 | 68 | autodoc_typehints_format = "short" |
49 | 69 |
|
|
69 | 89 | # Copied from https://github.com/readthedocs/readthedocs.org/issues/1139 |
70 | 90 |
|
71 | 91 | # run api doc |
72 | | -def run_apidoc(_): |
73 | | - output_path = os.path.join(script_dir, '.generated') |
74 | | - print(f"OUTPUT PATH = {output_path}") |
75 | | - #exclusions = [os.path.join(src_dir, 'setup.py'),] |
| 92 | +def run_apidoc(sphinx): |
| 93 | + output_path = os.path.join(sphinx.srcdir, '.generated') |
76 | 94 | main(['-f', '-o', output_path, src_dir]) |
77 | 95 |
|
78 | 96 | # launch setup |
|
0 commit comments