Skip to content

Commit 56eff4d

Browse files
committed
Merge branch 'PYT-916' into 'develop'
PYT-916: Create SDK documentation for the production See merge request SOLO-band/python-sdk!117
2 parents dd1c39f + 5d339e6 commit 56eff4d

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

docs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COPY docs/docs /app/docs
1111

1212
COPY src /app/src
1313

14-
RUN sphinx-build -b html /app/docs /app/syntax_folder
14+
RUN sphinx-build -a -E -b html /app/docs /app/syntax_folder
1515

1616
FROM public.ecr.aws/rogii/nginx:mainline
1717

docs/docs/_static/theme-init.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
3+
});

docs/docs/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66

77
from custom_stuff.navigation_settings import sidebar_settings
8-
from custom_stuff.skip_methods import skip_methods
8+
from custom_stuff.skip_methods import skip_inline_theme_script, skip_methods
99

1010
# -- Project information -----------------------------------------------------
1111
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -35,7 +35,7 @@
3535
html_favicon = '_static/favicon.svg'
3636
html_logo = '_static/logo.svg'
3737
html_css_files = ['custom.css']
38-
html_js_files = ['replace_logo.js']
38+
html_js_files = ['replace_logo.js', 'theme-init.js']
3939
html_title = project_name
4040
html_show_sourcelink = False
4141
html_show_sphinx = False
@@ -84,5 +84,6 @@
8484

8585

8686
def setup(sphinx):
87+
sphinx.connect('build-finished', skip_inline_theme_script)
8788
sphinx.connect('html-page-context', sidebar_settings)
8889
sphinx.connect('autoapi-skip-member', skip_methods)

docs/docs/custom_stuff/skip_methods.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import os
2+
import re
3+
4+
THEME_SCRIPT = re.compile(
5+
r'<script>\s*document\.body\.dataset\.theme\s*=\s*localStorage\.getItem\("theme"\)\s*\|\|\s*"auto";\s*</script>',
6+
re.DOTALL,
7+
)
8+
9+
110
def skip_methods(app, what, name, obj, skip, options):
211
if what in ('method', 'attribute', 'data', 'attributes'):
312
method_name = name.rsplit('.', 1)[-1]
@@ -12,3 +21,26 @@ def skip_methods(app, what, name, obj, skip, options):
1221
return True
1322

1423
return None
24+
25+
26+
def skip_inline_theme_script(app, exception):
27+
if exception or app.builder.name != 'html':
28+
return
29+
30+
outdir = app.builder.outdir
31+
32+
for root, _, files in os.walk(outdir):
33+
for fname in files:
34+
if not fname.endswith('.html'):
35+
continue
36+
37+
path = os.path.join(root, fname)
38+
39+
with open(path, 'r', encoding='utf-8') as f:
40+
text = f.read()
41+
42+
new_text = THEME_SCRIPT.sub('', text)
43+
44+
if text != new_text:
45+
with open(path, 'w', encoding='utf-8') as f:
46+
f.write(new_text)

0 commit comments

Comments
 (0)