Fix video embeds, columns, and resource link breakage by pushfoo · Pull Request #2410 · pythonarcade/arcade · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified arcade/resources/assets/images/cybercity_background/foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 73 additions & 12 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
"""Sphinx configuration file"""
from __future__ import annotations
from functools import cache
import logging
from pathlib import Path
from textwrap import dedent
from typing import Any, NamedTuple
import docutils.nodes
Expand All @@ -20,12 +23,78 @@

# --- Pre-processing Tasks

log = logging.getLogger('conf.py')
logging.basicConfig(level=logging.INFO)

HERE = Path(__file__).resolve()
REPO_LOCAL_ROOT = HERE.parent.parent
ARCADE_MODULE = REPO_LOCAL_ROOT / "arcade"
UTIL_DIR = REPO_LOCAL_ROOT / "util"

log.info(f"Absolute path for our conf.py : {str(HERE)!r}")
log.info(f"Absolute path for the repo root : {str(REPO_LOCAL_ROOT)!r}")
log.info(f"Absolute path for the arcade module : {str(REPO_LOCAL_ROOT)!r}")
log.info(f"Absolute path for the util dir : {str(UTIL_DIR)!r}")

# _temp_version = (REPO_LOCAL_ROOT / "arcade" / "VERSION").read_text().replace("-",'')

sys.path.insert(0, str(REPO_LOCAL_ROOT))
sys.path.insert(0, str(ARCADE_MODULE))
log.info(f"Inserted elements in system path: First two are now:")
for i in range(2):
log.info(f" {i}: {sys.path[i]!r}")

# Don't change to
# from arcade.version import VERSION
# or read the docs build will fail.
from version import VERSION # pyright: ignore [reportMissingImports]
log.info(f"Got version {VERSION!r}")

REPO_URL_BASE="https://github.com/pythonarcade/arcade"
if 'dev' in VERSION:
GIT_REF = 'development'
log.info(f"Got .dev release: using {GIT_REF!r}")
else:
GIT_REF = VERSION
log.info(f"Got real release: using {GIT_REF!r}")


# We'll pass this to our generation scripts to initialize their globals
RESOURCE_GLOBALS = dict(
GIT_REF=GIT_REF,
BASE_URL_REPO=REPO_URL_BASE,
# This double-bracket escapes brackets in f-strings
FMT_URL_REF_PAGE=f"{REPO_URL_BASE}/blob/{GIT_REF}/{{}}",
FMT_URL_REF_EMBED=f"{REPO_URL_BASE}/blob/{GIT_REF}/{{}}?raw=true",
)

def run_util(filename, run_name="__main__", init_globals=None):

full_absolute_path = UTIL_DIR / filename
full_str = str(full_absolute_path)

log.info(f"Running {full_str!r} with:")
log.info(f" run_name={run_name!r}")
kwargs = dict(run_name=run_name)
if init_globals is not None:
kwargs['init_globals'] = init_globals
log.info(f" init_globals={{")
num_left = len(init_globals)
for k, v in init_globals.items():
end = "," if num_left else ""
log.info(f" {k!r} : {v!r}{end}")
num_left -= num_left
log.info(f" }}")

runpy.run_path(full_str, **kwargs)

# Make thumbnails for the example code screenshots
runpy.run_path('../util/generate_example_thumbnails.py', run_name='__main__')
# Create a listing of the resources
runpy.run_path('../util/create_resources_listing.py', run_name='__main__')
run_util("generate_example_thumbnails.py")
# Create a tabular representation of the resources with embeds
run_util("create_resources_listing.py", init_globals=RESOURCE_GLOBALS)
# Run the generate quick API index script
runpy.run_path('../util/update_quick_index.py', run_name='__main__')
run_util('../util/update_quick_index.py')


autodoc_inherit_docstrings = False
autodoc_default_options = {
Expand All @@ -39,16 +108,8 @@
# Special methods in api docs gets a special prefix emoji
prettyspecialmethods_signature_prefix = '🧙'

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../arcade'))

# Don't change to
# from arcade.version import VERSION
# or read the docs build will fail.
from version import VERSION # pyright: ignore [reportMissingImports]

RELEASE = VERSION

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down
142 changes: 108 additions & 34 deletions util/create_resources_listing.py