Skip to content

Commit cdd6f66

Browse files
authored
Fix GitHub stars on the home page, our pyglet intersphinx config, and small issues on resources (#2524)
* Edit front page text * Fix alignment of GH button. * Swap to pyglet's latest build for interpshinx to match build changes * Fix styles and redundant information on resources page * Fix video heading doubling
1 parent 255d0b1 commit cdd6f66

File tree

6 files changed

+63
-62
lines changed

6 files changed

+63
-62
lines changed
Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This logo of the snake doubles as a quick way to test Arcade's resource handles.
1+
The Arcade logo doubles as a quick way to test :ref:`resource handles <resource_handles>`.
22

33
.. raw:: html
44

@@ -7,19 +7,6 @@ This logo of the snake doubles as a quick way to test Arcade's resource handles.
77
<li>Look to the right edge of the file name (<code class="docutils literal notranslate"><span class="pre">'logo.png'</span></code>)</li>
88
<li>There should be a copy button (<div class="arcade-ezcopy doc-ui-example-dummy" style="display: inline-block;">
99
<img src="https://api.arcade.academy/en/development/_static/icons/tabler/copy.svg"></div>) </li>
10-
<li>Click or tap it.</li>
10+
<li>Click or tap it to copy the string</li>
11+
<li>Try pasting it in your favorite text editor!</li>
1112
</ol>
12-
13-
Click the button or tap it if you're on mobile. Then try pasting in your favorite text editor. It
14-
should look like this::
15-
16-
':resources:/logo.png'
17-
18-
This string is what Arcade calls a **:ref:`resource handle <resource_handles>`**. They let you load
19-
images, sound, and other data without worrying about where exactly data is on a computer. To learn
20-
more, including how to define your own handle prefix, see :ref:`resource_handles`.
21-
22-
To get started with game code right away, please see the following:
23-
24-
* :ref:`example-code`
25-
* :ref:`main-page-tutorials`

doc/_includes/resources_Video.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
.. _resources_video:
2-
3-
Video
4-
-----
5-
61
Arcade offers experimental support for video playback through :py:mod:`pyglet` and other libraries.
72

83
.. warning:: These features are works-in-progress!

doc/_static/css/custom.css

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ title + list appear like other categories */
5757
width: 100%;
5858
}
5959

60-
/* Wrappers and formatting for sprinter, START HERE, github star button
61-
to align them neatly */
60+
/* Align the GitHub stars button since Sphinx doesn't offer us great control over headings */
6261
.main-page-item-wrapper-header {
6362
align-items: center;
64-
display: flex;
65-
margin: 10px;
63+
float: right;
64+
display: relative;
65+
}
66+
/* IMPORTANT: unlike flex, you have to clear float! */
67+
.main-page-item-wrapper-header::after {
68+
float: clear;
6669
}
6770
.main-page-box {
6871
width: 100%;
@@ -97,7 +100,8 @@ to align them neatly */
97100
width: 100%;
98101
display: flex;
99102
} */
100-
.main-page-box > .main-page-box-gh {
103+
104+
.main-page-box-gh {
101105
display: flex;
102106
align-items: center;
103107
margin-right: 0px;
@@ -342,6 +346,9 @@ table.resource-table td > .resource-thumb.file-icon {
342346
li .arcade-ezcopy.doc-ui-example-dummy {
343347
margin-left: 0.2em;
344348
margin-right: 0.2em;
349+
/* Override 12 px bottom margin */
350+
margin-top: inherit !important;
351+
margin-bottom: inherit !important;
345352
}
346353

347354
table.colorTable {

doc/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,9 @@ def run_util(filename, run_name="__main__", init_globals=None):
323323
# Configuration for intersphinx enabling linking other projects
324324
intersphinx_mapping = {
325325
'python': ('https://docs.python.org/3', None),
326-
'pyglet': ('https://pyglet.readthedocs.io/en/development/', None),
326+
# As of January 25th, pyglet's 2.1.X branch is on this URL and their
327+
# development build on readthedocs is for their in-progress 3.0.0 alpha.
328+
'pyglet': ('https://pyglet.readthedocs.io/en/latest/', None),
327329
'PIL': ('https://pillow.readthedocs.io/en/stable', None),
328330
'pymunk': ('https://www.pymunk.org/en/latest/', None),
329331
}

doc/index.rst

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
:hide-toc:
22

3+
.. container:: main-page-item-wrapper-header
4+
5+
.. raw:: html
6+
7+
<div class="main-page-box-gh">
8+
<iframe id="github-stars" style="align-self: center; margin: 0 auto; display: block;"
9+
src="https://ghbtns.com/github-btn.html?user=pythonarcade&repo=arcade&type=star&count=true&size=large"
10+
frameborder="0"
11+
scrolling="0"
12+
title="GitHub">
13+
</iframe>
14+
</div>
315

416
.. _main_page:
517

618
The Python Arcade Library
719
=========================
820

9-
10-
.. container:: main-page-item-wrapper-header
11-
12-
.. raw:: html
13-
14-
<div class="main-page-box">
15-
<div class="main-page-link">
16-
</div>
17-
<div class="main-page-box-gh">
18-
<iframe id="github-stars" style="align-self: center; margin: 0 auto; display: block;"
19-
src="https://ghbtns.com/github-btn.html?user=pythonarcade&repo=arcade&type=star&count=true&size=large"
20-
frameborder="0"
21-
scrolling="0"
22-
title="GitHub">
23-
</iframe>
24-
</div>
25-
</div>
26-
2721
Arcade is an easy-to-learn Python library for creating 2D games and more. The
28-
friendly API caters to both beginners and experts alike. Do you want to make
29-
something small, or explore the full power of shaders? It's up to you.
22+
friendly API caters to both beginners and experts alike. Do you want to craft
23+
craft your take on a 2D classic, or explore the full power of shaders? It's up to you.
3024

3125
What will you make?
3226

util/create_resources_listing.py

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class TableConfigDict(TypedDict):
143143

144144

145145
class HeadingConfigDict(TypedDict):
146-
ref_target: NotRequired[str | bool]
146+
ref_target: NotRequired[str]
147147
skip: NotRequired[bool]
148148
value: NotRequired[str]
149149
level: NotRequired[int]
@@ -169,6 +169,7 @@ class HandleLevelConfigDict(TypedDict):
169169
":resources:/": {
170170
"heading": {
171171
"value": "Top-Level Resources",
172+
"ref_target": "resources-top-level-resources",
172173
"level": 1
173174
},
174175
"include": "resources_Top-Level_Resources.rst"
@@ -208,10 +209,10 @@ class HandleLevelConfigDict(TypedDict):
208209
},
209210
":resources:/video/": {
210211
# pending: post-3.0 cleanup # trains are hats
211-
# "heading:": {
212-
# "value": "Video",
213-
# "ref_target": "resources_video"
214-
# },
212+
"heading:": {
213+
"value": "Video",
214+
"ref_target": "resources_video"
215+
},
215216
"include": "resources_Video.rst"
216217
}
217218
}
@@ -273,6 +274,7 @@ def do_heading(
273274
if ref_target is True:
274275
ref_target = f"resources-{heading_text}.rst"
275276
if ref_target:
277+
print(f" writing ref target {repr(heading_text)}")
276278
out.write(f".. _{ref_target.lower()}:\n\n")
277279

278280
if relative_heading_level >= num_headings:
@@ -427,19 +429,24 @@ def process_resource_directory(out, dir: Path):
427429
local_config = RESOURCE_HANDLE_CONFIGS.get(handle_step_whole, {})
428430
local_heading_config = local_config.get('heading', {})
429431

430-
# print("proceeding...",
431-
# "\n config ", local_config,
432-
# "\n heading_config ", local_heading_config, sep = "")
432+
print("proceeding...",
433+
"\n config ", local_config,
434+
"\n heading_config ", local_heading_config, sep = "")
433435

434436
# Heading config fetch and write
435437
use_level = local_heading_config.get('level', heading_level)
436438
use_value = local_heading_config.get('value', None)
439+
use_target = local_heading_config.get('ref_target', None)
437440
if use_value is None:
438441
use_value = format_title_part(handle_steps_parts[heading_level])
439-
use_target = local_heading_config.get('ref_target', None)
440-
if isinstance(use_target, bool) and use_target:
441-
use_target = f"resources_{use_value.lower()}"
442+
if use_target is None:
443+
use_target = f"resources-{use_value.lower()}"
444+
445+
for k, v in locals().items():
446+
if k.startswith("use_"):
447+
print(repr(k), ":", repr(v))
442448

449+
print(f" got target: {use_target!r}")
443450
do_heading(out, use_level, use_value, ref_target=use_target)
444451
out.write(f"\n.. comment `{handle_step_whole!r}``\n\n")
445452

@@ -788,7 +795,7 @@ def resources():
788795
"convenience, or visit `Kenney.nl`_ for more permissively licensed game assets.\n"
789796
"\n"
790797
"The one feature which may require additional software is Arcade's experimental video playback\n"
791-
"support. The :ref:`resources_video` section below will explain further.\n")
798+
"support. The :ref:`resources-video` section below will explain further.\n")
792799

793800
do_heading(out, 1, "Do I have to credit anyone?")
794801
# Injecting the links.rst doesn't seem to be working?
@@ -814,9 +821,18 @@ def resources():
814821
f"<img src=\"{src_kludge('/_static/icons/tabler/copy.svg')}\"></div>)</li>\n"
815822
f" </ol>\n\n"
816823
+
817-
"Click the button above a preview to copy the **resource handle** string for loading the asset.\n"
818-
"Any image or sound on this page should work after installing Arcade with zero additional dependencies.\n"
819-
"Full example code and manual sections for any relevant functions are linked below."
824+
"Click the button above a preview to copy the **resource handle** string for loading the asset. It should\n"
825+
"look something like this::\n\n"
826+
" ':resources:/logo.png'\n"
827+
"\n"
828+
"Each resource preview on this page has a button which copies a corresponding string. These\n"
829+
"resource handle strings allow using Arcade's built-in assets without worrying where a file is\n"
830+
"on a computer.\n\n"
831+
"To learn more, please see:\n\n"
832+
"* The :ref:`resources-top-level-resources` section for a short tutorial on resource handles\n"
833+
"* :ref:`example-code` for runnable example code\n"
834+
"* :ref:`main-page-tutorials` for a step-by-step introduction to Arcade\n"
835+
"* :ref:`resource_handles` for in-depth explanations of resource handles\n\n"
820836
)
821837

822838
out.write("\n")

0 commit comments

Comments
 (0)