2
2
"""Sphinx configuration file"""
3
3
from __future__ import annotations
4
4
5
+ import os
5
6
from functools import cache
6
7
import logging
7
8
from pathlib import Path
27
28
for i in range (2 ):
28
29
log .info (f" { i } : { sys .path [i ]!r} " )
29
30
31
+
32
+ # Grab readthedocs env variables for logging + use
33
+ # https://docs.readthedocs.com/platform/stable/reference/environment-variables.html
34
+ # Their GH comments suggest they want to move away from "magic" injection as
35
+ # part of the readthedocs theme, so this seems like the best option for us.
36
+ log .info (" Env variables..." )
37
+ col_width = max (map (len , os .environ .keys ()))
38
+ READTHEDOCS = dict ()
39
+ ENV = dict ()
40
+ for k , v in os .environ .items ():
41
+ if k .startswith ('READTHEDOCS_' ):
42
+ READTHEDOCS [k .removeprefix ('READTHEDOCS_' )] = v
43
+ ENV [k ] = v
44
+
30
45
from util .doc_helpers .real_filesystem import copy_media
31
46
47
+
32
48
# As of pyglet==2.1.dev7, this is no longer set in pyglet/__init__.py
33
49
# because Jupyter / IPython always load Sphinx into sys.modules. See
34
50
# the following for more info:
44
60
log .info (f"Absolute path for the arcade module : { str (REPO_LOCAL_ROOT )!r} " )
45
61
log .info (f"Absolute path for the util dir : { str (UTIL_DIR )!r} " )
46
62
63
+ print ()
64
+ for k , v in ENV .items ():
65
+ log .info (f"Env variable { k :{col_width }} : { v !r} " )
66
+
47
67
# _temp_version = (REPO_LOCAL_ROOT / "arcade" / "VERSION").read_text().replace("-",'')
48
68
49
69
# Don't change to
52
72
from version import VERSION # pyright: ignore [reportMissingImports]
53
73
log .info (f" Got version { VERSION !r} " )
54
74
55
-
56
75
# Check whether the version ends in an all-digit string
57
- VERSION_PARTS = []
76
+ ARCADE_VERSION_PARTS = []
58
77
for part in VERSION .split ('.' ):
59
78
if part .isdigit ():
60
- VERSION_PARTS .append (int ( part ) )
79
+ ARCADE_VERSION_PARTS .append (part )
61
80
else :
62
- VERSION_PARTS .append (part )
81
+ ARCADE_VERSION_PARTS .append (part )
63
82
64
83
print ()
65
- if VERSION_PARTS [- 1 ].isdigit ():
66
- GIT_REF = VERSION
67
- log .info (" !!!!! APPEARS TO BE A REAL RELEASE !!!!!" )
84
+ GIT_REF = 'development'
85
+ if READTHEDOCS :
86
+ if READTHEDOCS .get ('VERSION' ) in ('latest' , 'stable' ):
87
+ log .info (" !!!!! APPEARS TO BE A REAL RELEASE !!!!!" )
88
+ else :
89
+ log .info (" +++++ Building a PR or development +++++" )
68
90
else :
69
- GIT_REF = 'development'
70
- log .info (" - - - Building as a dev release - - -" )
71
-
72
- print ()
73
- print (f" { GIT_REF = !r} " )
74
- print (f" { VERSION = !r} " )
91
+ log .info (" - - - Building outside readthedocs +++++" )
75
92
print ()
76
93
77
94
80
97
FMT_URL_REF_BASE = f"{ REPO_URL_BASE } /blob/{ GIT_REF } "
81
98
82
99
RESOURCE_GLOBALS = dict (
83
- GIT_REF = GIT_REF ,
100
+ GIT_REF = GIT_REF , # pending: post-3.0 clean-up, not sure if things use it now?
101
+ # This may be more useful according to some doc? (It's unclear)
102
+ # https://docs.readthedocs.com/platform/stable/reference/environment-variables.html#envvar-READTHEDOCS_GIT_COMMIT_HASH
84
103
BASE_URL_REPO = REPO_URL_BASE ,
85
104
# This double-bracket escapes brackets in f-strings
86
105
FMT_URL_REF_PAGE = f"{ FMT_URL_REF_BASE } /{{}}" ,
87
106
FMT_URL_REF_EMBED = f"{ FMT_URL_REF_BASE } /{{}}?raw=true" ,
107
+ RTD_EVIL = READTHEDOCS ['CANONICAL_URL' ] if READTHEDOCS else "" # pending: post-3.0 cleanup
88
108
)
89
109
90
110
def run_util (filename , run_name = "__main__" , init_globals = None ):
@@ -119,6 +139,8 @@ def run_util(filename, run_name="__main__", init_globals=None):
119
139
run_util ('../util/update_quick_index.py' )
120
140
121
141
142
+ OUT_STATIC = REPO_LOCAL_ROOT / 'build/html/_static/'
143
+
122
144
src_res_dir = ARCADE_MODULE / 'resources/assets'
123
145
out_res_dir = REPO_LOCAL_ROOT / 'build/html/_static/assets'
124
146
@@ -133,6 +155,25 @@ def run_util(filename, run_name="__main__", init_globals=None):
133
155
}
134
156
copy_media (src_res_dir , out_res_dir , copy_what )
135
157
158
+ # We are no longer asking. We are copying.
159
+ copy_media (
160
+ REPO_LOCAL_ROOT / "doc/_static/icons" ,
161
+ OUT_STATIC / "icons" ,
162
+ {
163
+ 'tabler' : ("*.svg" ,)
164
+ }
165
+ )
166
+ copy_media (
167
+ REPO_LOCAL_ROOT / "doc/_static/" ,
168
+ OUT_STATIC ,
169
+ {
170
+ 'filetiles' : ("*.png" ,)
171
+ }
172
+ )
173
+ #copy_media(
174
+ # REP / ""
175
+ #)
176
+
136
177
137
178
autodoc_inherit_docstrings = False
138
179
autodoc_default_options = {
0 commit comments