From e2c8b4635005112699c9d7cb468f516dc9e3a1df Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Fri, 1 Mar 2024 23:09:43 -0600 Subject: [PATCH 01/17] fixed the header levels in the sprite doc changed doc subsection header renamed old subsection --- .python-version | 1 + doc/programming_guide/sprites/spritelists.rst | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..62b104567 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +arcade-dev diff --git a/doc/programming_guide/sprites/spritelists.rst b/doc/programming_guide/sprites/spritelists.rst index 72e8adfd2..df0fc4353 100644 --- a/doc/programming_guide/sprites/spritelists.rst +++ b/doc/programming_guide/sprites/spritelists.rst @@ -1,7 +1,10 @@ .. _pg_spritelists: +Drawing with Sprites and SpriteLists +------------------------------------ + What's a Sprite? ----------------- +^^^^^^^^^^^^^^^^ Each sprite describes where a game object is & how to draw it. This includes: @@ -16,12 +19,12 @@ sprites to the screen. .. _pg_spritelists_why: Why SpriteLists? ----------------- +^^^^^^^^^^^^^^^^ .. _pg_spritelists_why_hardware: They're How Hardware Works -^^^^^^^^^^^^^^^^^^^^^^^^^^ +"""""""""""""""""""""""""" Graphics hardware is designed to draw groups of objects at the same time. These groups are called **batches**. @@ -38,7 +41,7 @@ should avoid trying to draw sprites one at a time. .. _pg_spritelists_why_faster_dev: They Help Develop Games Faster -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +"""""""""""""""""""""""""""""" Sprite lists do more than just draw. They also have built-in features which save you time & effort, including: @@ -50,8 +53,8 @@ you time & effort, including: .. _pg_spritelists_minimal_sprite_drawing: -Drawing with Sprites and SpriteLists ------------------------------------- +Using Sprites and SpriteLists +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Let's get to the example code. From c2dcc0f39544e0c8528469f40eddd64f74557806 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Fri, 1 Mar 2024 23:17:09 -0600 Subject: [PATCH 02/17] Revert "fixed the header levels in the sprite doc" This reverts commit e2c8b4635005112699c9d7cb468f516dc9e3a1df. --- .python-version | 1 - doc/programming_guide/sprites/spritelists.rst | 15 ++++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 .python-version diff --git a/.python-version b/.python-version deleted file mode 100644 index 62b104567..000000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -arcade-dev diff --git a/doc/programming_guide/sprites/spritelists.rst b/doc/programming_guide/sprites/spritelists.rst index df0fc4353..72e8adfd2 100644 --- a/doc/programming_guide/sprites/spritelists.rst +++ b/doc/programming_guide/sprites/spritelists.rst @@ -1,10 +1,7 @@ .. _pg_spritelists: -Drawing with Sprites and SpriteLists ------------------------------------- - What's a Sprite? -^^^^^^^^^^^^^^^^ +---------------- Each sprite describes where a game object is & how to draw it. This includes: @@ -19,12 +16,12 @@ sprites to the screen. .. _pg_spritelists_why: Why SpriteLists? -^^^^^^^^^^^^^^^^ +---------------- .. _pg_spritelists_why_hardware: They're How Hardware Works -"""""""""""""""""""""""""" +^^^^^^^^^^^^^^^^^^^^^^^^^^ Graphics hardware is designed to draw groups of objects at the same time. These groups are called **batches**. @@ -41,7 +38,7 @@ should avoid trying to draw sprites one at a time. .. _pg_spritelists_why_faster_dev: They Help Develop Games Faster -"""""""""""""""""""""""""""""" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sprite lists do more than just draw. They also have built-in features which save you time & effort, including: @@ -53,8 +50,8 @@ you time & effort, including: .. _pg_spritelists_minimal_sprite_drawing: -Using Sprites and SpriteLists -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Drawing with Sprites and SpriteLists +------------------------------------ Let's get to the example code. From 78613efa823c5f259b9d41dfb94950961a95e459 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sat, 2 Mar 2024 21:17:38 -0600 Subject: [PATCH 03/17] fixed color tables and removed regex --- doc/conf.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index f8bc966eb..6f4f57525 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -219,31 +219,24 @@ def source_read(_app, docname, source): filename = "../arcade/csscolor/__init__.py" if filename: - # print(f" XXX Handling color file: {filename}") - import re - p = re.compile(r"^([A-Z_]+) = (\(.*\))") - original_text = source[0] append_text = "\n\n.. raw:: html\n\n" append_text += " \n" color_file = open(filename) for line in color_file: - match = p.match(line) - - if match: - color_variable_name = match.group(1) - color_tuple = tuple(int(num) for num in match.group(2).strip('()').split(',')) - color_rgb_string = ', '.join(str(i) for i in color_tuple[:3]) + if '= Color(' in line: + color_variable_name = line[:line.index('=')].strip() + color_rgba_string = line[line.index('('):].strip() append_text += " " append_text += f"" - append_text += f"" - append_text += f"" + append_text += f"" + append_text += f"" append_text += "\n" append_text += "
{color_variable_name}{color_tuple}
{color_rgba_string}
" - source[0] = original_text + append_text + source[0] += append_text def post_process(_app, _exception): From f963617be8029c34967be6be42088c7612a14144 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sat, 2 Mar 2024 21:21:18 -0600 Subject: [PATCH 04/17] removed second import of os module --- doc/conf.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6f4f57525..e20484ab2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -207,8 +207,6 @@ def warn_undocumented_members(_app, what, name, _obj, _options, lines): def source_read(_app, docname, source): - # print(f" XXX Reading {docname}") - import os file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) From b7feea6f1c685713fb2c1ea2c966c9a8e713a3a8 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 00:46:11 -0600 Subject: [PATCH 05/17] Added checkered background to color cells and added a custom css class for it --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5b1be3dc3..634007dac 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ temp/ *.tiled-session doc/api_docs/api/*.rst +.python-version From b357195276e158abf35dd4a26387471048a88222 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 00:46:45 -0600 Subject: [PATCH 06/17] Added checkered background to color cells and added a custom css class for it --- doc/_static/checkered.png | Bin 0 -> 744 bytes doc/_static/css/custom.css | 7 +++++++ doc/conf.py | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 doc/_static/checkered.png diff --git a/doc/_static/checkered.png b/doc/_static/checkered.png new file mode 100644 index 0000000000000000000000000000000000000000..6b0c66349d9f91ede223fadeb784141300eb1ee0 GIT binary patch literal 744 zcmeAS@N?(olHy`uVBq!ia0vp^Q9vBP!3HE}8YiVNFfg`cIy(n=Iy);A6y>L7=A<$( zXiTh~XzOv9d-FQJbxjICm><1)u;hi3YTa~^s3R4}3;EyIzCV4p++jmt;w(`qc9Xkimru6L zIJ>s%VK|40vqYPM@#z_pmx$CHzi!J^v%mYZ&i`HZ?(1i5mkOrM!}>xlG`%d@u~ ztekIg%4?HXjh{{0CDu;)o$D(89NYP#XhOQ%S)ZzT7G64H))6lg!i-EGX+D~<>g5#q zGgWJf?mb!)nzg3X|KA~xxcJCtR%;biHg>3b2rOLCW~8-2aCxlyQKwnwgzf%0Ue}-K ztr#xZBg4JIsrk*Xga03t=dV5Vq-DB@Cqt}$-)BRnmh#55yM_DuWtUenahyLe_1?E| z=>uofUw+*tX3g|#TVwa@ZOh&;PPaaAV6x)uP1>AWnp&AY)VbZC!u%`0ah~b={I$h% z>=-0pg}!35uwZfPp0fAd=XdYU?fV;j`PF^?M+!x`M`|Zz0;7d3$=lt9;Xep2*t>i( zP=vF(&aSW-r_4c|VAAk zpWV~Saza9P+}(TjfN+P}tPB~0UC}^AuNf}7{Fik;9l*1fPr!FeYKCOj!t0ESI=AuY zIvakmaxl3#ZJ`8A=%_bTl}23Bi_(USMY_%(g`C$jy9nn>c1@S4l2w?MaXMhn5wNMz wZI4vj;@CUXZW)Q_!;Grvgqn_Flzj@L@7ps8d8Zfd1^R`-)78&qol`;+03p{qbpQYW literal 0 HcmV?d00001 diff --git a/doc/_static/css/custom.css b/doc/_static/css/custom.css index 38ea33d70..c53e74ad1 100644 --- a/doc/_static/css/custom.css +++ b/doc/_static/css/custom.css @@ -174,3 +174,10 @@ body:not([data-theme="light"]) .highlight .c1 { .highlight .c1 { color: #007507; } + +.checkered { + background-image: url(../checkered.png); + background-repeat: repeat; + margin:0px; + padding: 0px; +} \ No newline at end of file diff --git a/doc/conf.py b/doc/conf.py index e20484ab2..0435eeb52 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -206,7 +206,8 @@ def warn_undocumented_members(_app, what, name, _obj, _options, lines): def source_read(_app, docname, source): - + """This function Generates the Color tables in the docs for color and csscolor packages""" + file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) @@ -223,14 +224,23 @@ def source_read(_app, docname, source): color_file = open(filename) for line in color_file: + + # This matches the line with a Color. It relies on properly formatted code. if '= Color(' in line: + + # Extract the Color Name and RGBA string color_variable_name = line[:line.index('=')].strip() color_rgba_string = line[line.index('('):].strip() + + # Generate the alpha for CSS color function + rgba_values = [x for x in color_rgba_string.strip('()').split(',')] + alpha = int( rgba_values[-1] ) / 255 + css_rgba = (", ").join(rgba_values[:-1]) + f', {str(alpha)}' append_text += " " append_text += f"{color_variable_name}" append_text += f"{color_rgba_string}" - append_text += f"
" + append_text += f"
 
" append_text += "\n" append_text += " " From c4c06401e14421b341be2e98f01e31de27eb43c0 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 09:08:19 -0600 Subject: [PATCH 07/17] remove gitignore file --- .gitignore | 64 ------------------------------------------------------ 1 file changed, 64 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 634007dac..000000000 --- a/.gitignore +++ /dev/null @@ -1,64 +0,0 @@ - -# IDEs -*.sublime-project -*.sublime-workspace -.idea/ -/.vscode/ -*.wpr -*.wpu - -# virualenvs -env -.env -.venv -ENV/ -env/ -venv*/ -.venv*/ - -# docs -/doc/api_docs/resources.rst -doc/build/ -doc/api_docs/quick_index.rst -doc/internal/blacklist.rst -doc/internal/build.rst -doc/source/quick_index.rst -doc/example_code/how_to_examples/thumbs/ - -# testing -.pytest_cache/ -.coveralls.yml -.tox/ -.mypy_cache/ -tests/test_examples/test.png -stress_test*.csv -arcade/examples/test.png -arcade/examples/stress*.csv -pylint.html - -# covereage -htmlcov/ -.coverage - -# build -.eggs/ -dist/ -build/ -arcade.egg-info/ -*.pyc -arcade/__pycache__/ -doc/_build - -# osx -.DS_Store - -# local testing/mocking -test.py -pip-wheel-metadata/ -temp/ - -# Tiled Session for project -*.tiled-session - -doc/api_docs/api/*.rst -.python-version From d282bf64cfc986eaec5c20bb06b4dc5ca1dfae27 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 09:12:53 -0600 Subject: [PATCH 08/17] updated gitignore with pyrnv python-version --- .gitignore | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..aff91edf2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ + +# IDEs +*.sublime-project +*.sublime-workspace +.idea/ +/.vscode/ +*.wpr +*.wpu + +# virualenvs +env +.env +.venv +ENV/ +env/ +venv*/ +.venv*/ + +# docs +/doc/api_docs/resources.rst +doc/build/ +doc/api_docs/quick_index.rst +doc/internal/blacklist.rst +doc/internal/build.rst +doc/source/quick_index.rst +doc/example_code/how_to_examples/thumbs/ + +# testing +.pytest_cache/ +.coveralls.yml +.tox/ +.mypy_cache/ +tests/test_examples/test.png +stress_test*.csv +arcade/examples/test.png +arcade/examples/stress*.csv +pylint.html + +# covereage +htmlcov/ +.coverage + +# build +.eggs/ +dist/ +build/ +arcade.egg-info/ +*.pyc +arcade/__pycache__/ +doc/_build + +# osx +.DS_Store + +# local testing/mocking +test.py +pip-wheel-metadata/ +temp/ + +# Tiled Session for project +*.tiled-session + +doc/api_docs/api/*.rst + +# Pyenv local +.python-version From 5826789aa1e55b5af69f6372ed2250e15da3c807 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 09:21:59 -0600 Subject: [PATCH 09/17] made checkered image smaller --- doc/_static/checkered.png | Bin 744 -> 4885 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/_static/checkered.png b/doc/_static/checkered.png index 6b0c66349d9f91ede223fadeb784141300eb1ee0..6f8f0bf9f6b4b581a93ef1d3b32c382fa59390cc 100644 GIT binary patch literal 4885 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 AjQ{`u delta 633 zcmbQL_JTFOGr-TCmrII^fq{Y7)59eQNJjy200$e8oN1ht!oa}TlIiRm;OXqFP*9Yg zmYI{vz@Ra)cA~AvVF!t}`({(SLS)`3D9u=C6)7NEctuNOq0>`{!G=HqI-|lgl4TN_5XLM-XktP@|o3IMU{;msvZIh7ql5^ zZ4g`@tA5mJ);VFje~#DnCweP}OZLccuW)L9^XuUM2j%%|4?Ss_F5<}$tKaw8kg27- zG3{>QzJA%|l}sGx4@|xHEnND*8TFT6w~1LZ{o2;p{d(K7H;mJ*4;+}RID3;e=a!~c zrVn*)_op!b%5T)1XSzOrZSfpC2FX{Uuh=XsSlqg&?0xt7-Me%9{zhMZb)Wx{LQ(FK z+6kGHtA&i&S=6k>xK!3o-YTR~f56klF{I+w+v|#a3<^9)FC09&eKvo;3d`ZubJj$B zc26tI2?^bCckkH)!X0X}GGq*PMFSPRX1M6`U)K3_0MA}N0pBgD8IoNKuQM*{+{UBp zZ1}~>!Q|q!g%U8Kqux+e8gWT4N*gj3={kQDa$e8uBAhGP6*gU>N>*W3#_51PN5IBL xw>?sAi(~IlyJaMz4>PNx6KXt$S@tQ6zHiSY Date: Sun, 3 Mar 2024 09:58:01 -0600 Subject: [PATCH 10/17] added regex line match and file closing --- doc/conf.py | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 0435eeb52..18fe89392 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -9,6 +9,7 @@ import sphinx.ext.autodoc import sphinx.transforms import docutils.nodes +import re # --- Pre-processing Tasks @@ -223,25 +224,29 @@ def source_read(_app, docname, source): append_text += " \n" color_file = open(filename) - for line in color_file: - - # This matches the line with a Color. It relies on properly formatted code. - if '= Color(' in line: - - # Extract the Color Name and RGBA string - color_variable_name = line[:line.index('=')].strip() - color_rgba_string = line[line.index('('):].strip() - - # Generate the alpha for CSS color function - rgba_values = [x for x in color_rgba_string.strip('()').split(',')] - alpha = int( rgba_values[-1] ) / 255 - css_rgba = (", ").join(rgba_values[:-1]) + f', {str(alpha)}' - - append_text += " " - append_text += f"" - append_text += f"" - append_text += f"" - append_text += "\n" + # Will match '=Color(', '= Color(', '=Color (', and '= Color (' + color_match = re.compile('=.?Color.?\(') + + with open(filename) as color_file: + for line in color_file: + + # Check if the line has a Color. + if color_match.search(line): + + # Extract the Color Name and RGBA string + color_variable_name = line[:line.index('=')].strip() + color_rgba_string = line[line.index('('):].strip() + + # Generate the alpha for CSS color function + rgba_values = [x for x in color_rgba_string[1:-1].split(',')] + alpha = int( rgba_values[-1] ) / 255 + css_rgba = f'{(", ").join(rgba_values[:-1])} , {str(alpha)}' + + append_text += " " + append_text += f"" + append_text += f"" + append_text += f"" + append_text += "\n" append_text += "
{color_variable_name}{color_rgba_string}
 
{color_variable_name}{color_rgba_string}
 
" source[0] += append_text From 355572d7529adb0087218c68c9bb31e87c774d74 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 10:02:30 -0600 Subject: [PATCH 11/17] added regex line match and file closing --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 18fe89392..984097902 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -226,7 +226,7 @@ def source_read(_app, docname, source): # Will match '=Color(', '= Color(', '=Color (', and '= Color (' color_match = re.compile('=.?Color.?\(') - + with open(filename) as color_file: for line in color_file: From a703a278df72e393b04877f33cc4ec960d777b35 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 10:04:08 -0600 Subject: [PATCH 12/17] alphabetized imports --- doc/conf.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 984097902..a6cdedf9a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -3,13 +3,14 @@ Generate HTML docs """ -import runpy -import sys +import docutils.nodes import os +import re +import runpy import sphinx.ext.autodoc import sphinx.transforms -import docutils.nodes -import re +import sys + # --- Pre-processing Tasks From 2f794dc4dcb5046af3a97ca541a9efcf51dd24cb Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 10:14:02 -0600 Subject: [PATCH 13/17] updated comments for regex --- doc/conf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a6cdedf9a..6d35da95a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -223,9 +223,12 @@ def source_read(_app, docname, source): append_text = "\n\n.. raw:: html\n\n" append_text += " \n" - color_file = open(filename) - # Will match '=Color(', '= Color(', '=Color (', and '= Color (' + # Will match a line containing: + # '=Color(' + # '=Color (' + # '= Color(' + # '= Color (' color_match = re.compile('=.?Color.?\(') with open(filename) as color_file: From 672a759d1f7b9f7be1b046227040615ecfee123a Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 10:43:36 -0600 Subject: [PATCH 14/17] added percision to alpha calculation --- doc/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6d35da95a..340d008d3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -242,9 +242,9 @@ def source_read(_app, docname, source): color_rgba_string = line[line.index('('):].strip() # Generate the alpha for CSS color function - rgba_values = [x for x in color_rgba_string[1:-1].split(',')] + rgba_values = [color_byte for color_byte in color_rgba_string[1:-1].split(',')] alpha = int( rgba_values[-1] ) / 255 - css_rgba = f'{(", ").join(rgba_values[:-1])} , {str(alpha)}' + css_rgba = f'{(", ").join(rgba_values[:-1])} , {alpha!s:.4}' append_text += " " append_text += f"" From cc3e4a8b285fde81e155ee4864c539ee723f42c2 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Sun, 3 Mar 2024 11:00:50 -0600 Subject: [PATCH 15/17] moved to its own function --- doc/conf.py | 84 +++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 340d008d3..ce6e0b059 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -207,53 +207,55 @@ def warn_undocumented_members(_app, what, name, _obj, _options, lines): )) -def source_read(_app, docname, source): +def generate_color_table(filename, source): """This function Generates the Color tables in the docs for color and csscolor packages""" - + + append_text = "\n\n.. raw:: html\n\n" + append_text += "
{color_variable_name}
\n" + + # Will match a line containing: + # '=Color(' + # '=Color (' + # '= Color(' + # '= Color (' + color_match = re.compile('=.?Color.?\(') + + with open(filename) as color_file: + for line in color_file: + + # Check if the line has a Color. + if color_match.search(line): + + # Extract the Color Name and RGBA string + color_variable_name = line[:line.index('=')].strip() + color_rgba_string = line[line.index('('):].strip() + + # Generate the alpha for CSS color function + rgba_values = [color_byte for color_byte in color_rgba_string[1:-1].split(',')] + alpha = int( rgba_values[-1] ) / 255 + css_rgba = f'{(", ").join(rgba_values[:-1])} , {alpha!s:.4}' + + append_text += " " + append_text += f"" + append_text += f"" + append_text += f"" + append_text += "\n" + + append_text += "
{color_variable_name}{color_rgba_string}
 
" + source[0] += append_text + + +def source_read(_app, docname, source): + """Event handler for source-read event""" + file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) - filename = None + # Transform source for arcade.color and arcade.csscolor if docname == "api_docs/arcade.color": - filename = "../arcade/color/__init__.py" + generate_color_table("../arcade/color/__init__.py", source) elif docname == "api_docs/arcade.csscolor": - filename = "../arcade/csscolor/__init__.py" - - if filename: - - append_text = "\n\n.. raw:: html\n\n" - append_text += " \n" - - # Will match a line containing: - # '=Color(' - # '=Color (' - # '= Color(' - # '= Color (' - color_match = re.compile('=.?Color.?\(') - - with open(filename) as color_file: - for line in color_file: - - # Check if the line has a Color. - if color_match.search(line): - - # Extract the Color Name and RGBA string - color_variable_name = line[:line.index('=')].strip() - color_rgba_string = line[line.index('('):].strip() - - # Generate the alpha for CSS color function - rgba_values = [color_byte for color_byte in color_rgba_string[1:-1].split(',')] - alpha = int( rgba_values[-1] ) / 255 - css_rgba = f'{(", ").join(rgba_values[:-1])} , {alpha!s:.4}' - - append_text += " " - append_text += f"" - append_text += f"" - append_text += f"" - append_text += "\n" - - append_text += "
{color_variable_name}{color_rgba_string}
 
" - source[0] += append_text + generate_color_table("../arcade/csscolor/__init__.py", source) def post_process(_app, _exception): From 62128c688f19f052de10e1ccf1dbbefd51876e05 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Tue, 5 Mar 2024 09:20:13 -0600 Subject: [PATCH 16/17] added named regex --- doc/conf.py | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index ce6e0b059..b9844ddf8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -214,32 +214,34 @@ def generate_color_table(filename, source): append_text += " \n" # Will match a line containing: - # '=Color(' - # '=Color (' - # '= Color(' - # '= Color (' - color_match = re.compile('=.?Color.?\(') + # name '(?P[a-z_A-Z]*)' + # a Color '(?: *= *Color *\( *)' + # red '(?P\d*)' + # green '(?P\d*)' + # blue '(?P\d*)' + # alpha '(?P\d*)' + color_match = re.compile(r'(?P[a-z_A-Z]*)(?: *= *Color *\( *)(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)') with open(filename) as color_file: for line in color_file: # Check if the line has a Color. - if color_match.search(line): - - # Extract the Color Name and RGBA string - color_variable_name = line[:line.index('=')].strip() - color_rgba_string = line[line.index('('):].strip() - - # Generate the alpha for CSS color function - rgba_values = [color_byte for color_byte in color_rgba_string[1:-1].split(',')] - alpha = int( rgba_values[-1] ) / 255 - css_rgba = f'{(", ").join(rgba_values[:-1])} , {alpha!s:.4}' - - append_text += " " - append_text += f"" - append_text += f"" - append_text += f"" - append_text += "\n" + matches = color_match.match(line) + if not matches: + continue + + color_rgba = f"({matches.group('red')}, {matches.group('green')}, {matches.group('blue')}, {matches.group('alpha')})" + + # Generate the alpha for CSS color function + alpha = int( matches.group('alpha') ) / 255 + css_rgba = f"({matches.group('red')}, {matches.group('green')}, {matches.group('blue')}, {alpha!s:.4})" + + + append_text += " " + append_text += f"" + append_text += f"" + append_text += f"" + append_text += "\n" append_text += "
{color_variable_name}{color_rgba_string}
 
{matches.group('name')}{color_rgba}
 
" source[0] += append_text From 3013bb981b4e4e2008409954a1e5b08dec040725 Mon Sep 17 00:00:00 2001 From: Rich Saupe Date: Tue, 5 Mar 2024 09:25:35 -0600 Subject: [PATCH 17/17] updated regex --- doc/conf.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index b9844ddf8..2d3b53715 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -214,13 +214,13 @@ def generate_color_table(filename, source): append_text += " \n" # Will match a line containing: - # name '(?P[a-z_A-Z]*)' - # a Color '(?: *= *Color *\( *)' - # red '(?P\d*)' - # green '(?P\d*)' - # blue '(?P\d*)' + # name '(?P[a-z_A-Z]*)' followed by + # a Color '(?: *= *Color *\( *)' followed by + # red '(?P\d*)' followed by + # green '(?P\d*)' followed by + # blue '(?P\d*)' followed by # alpha '(?P\d*)' - color_match = re.compile(r'(?P[a-z_A-Z]*)(?: *= *Color *\( *)(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)') + color_match = re.compile(r'(?P[a-z_A-Z]*)(?:[ =]*Color[ (]*)(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)[ ,]*(?P\d*)') with open(filename) as color_file: for line in color_file: