22"""Sphinx configuration file"""
33from __future__ import annotations
44
5+ import os
56from functools import cache
67import logging
78from pathlib import Path
2728for i in range (2 ):
2829 log .info (f" { i } : { sys .path [i ]!r} " )
2930
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+
3045from util .doc_helpers .real_filesystem import copy_media
3146
47+
3248# As of pyglet==2.1.dev7, this is no longer set in pyglet/__init__.py
3349# because Jupyter / IPython always load Sphinx into sys.modules. See
3450# the following for more info:
4460log .info (f"Absolute path for the arcade module : { str (REPO_LOCAL_ROOT )!r} " )
4561log .info (f"Absolute path for the util dir : { str (UTIL_DIR )!r} " )
4662
63+ print ()
64+ for k , v in ENV .items ():
65+ log .info (f"Env variable { k :{col_width }} : { v !r} " )
66+
4767# _temp_version = (REPO_LOCAL_ROOT / "arcade" / "VERSION").read_text().replace("-",'')
4868
4969# Don't change to
5272from version import VERSION # pyright: ignore [reportMissingImports]
5373log .info (f" Got version { VERSION !r} " )
5474
55-
5675# Check whether the version ends in an all-digit string
57- VERSION_PARTS = []
76+ ARCADE_VERSION_PARTS = []
5877for part in VERSION .split ('.' ):
5978 if part .isdigit ():
60- VERSION_PARTS .append (int ( part ) )
79+ ARCADE_VERSION_PARTS .append (part )
6180 else :
62- VERSION_PARTS .append (part )
81+ ARCADE_VERSION_PARTS .append (part )
6382
6483print ()
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 +++++" )
6890else :
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 +++++" )
7592print ()
7693
7794
8097FMT_URL_REF_BASE = f"{ REPO_URL_BASE } /blob/{ GIT_REF } "
8198
8299RESOURCE_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
84103 BASE_URL_REPO = REPO_URL_BASE ,
85104 # This double-bracket escapes brackets in f-strings
86105 FMT_URL_REF_PAGE = f"{ FMT_URL_REF_BASE } /{{}}" ,
87106 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
88108)
89109
90110def run_util (filename , run_name = "__main__" , init_globals = None ):
@@ -119,6 +139,8 @@ def run_util(filename, run_name="__main__", init_globals=None):
119139run_util ('../util/update_quick_index.py' )
120140
121141
142+ OUT_STATIC = REPO_LOCAL_ROOT / 'build/html/_static/'
143+
122144src_res_dir = ARCADE_MODULE / 'resources/assets'
123145out_res_dir = REPO_LOCAL_ROOT / 'build/html/_static/assets'
124146
@@ -133,6 +155,25 @@ def run_util(filename, run_name="__main__", init_globals=None):
133155}
134156copy_media (src_res_dir , out_res_dir , copy_what )
135157
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+
136177
137178autodoc_inherit_docstrings = False
138179autodoc_default_options = {
0 commit comments