Skip to content

Commit

Permalink
Clean up and CONTRIBUTING upgrade (devicons#595)
Browse files Browse the repository at this point in the history
* Updated CONTRIBUTING

* Clean up various scripts (no functional changes)

* Update CONTRIBUTING.md

Co-authored-by: Clemens Bastian <[email protected]>

* Change icons to use devicon in README and CONTRIBUTING

* Add optimize-bot into CONTRIBUTING.md

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update README.md

Co-authored-by: David Leal <[email protected]>

* Update README.md

Co-authored-by: David Leal <[email protected]>

* Change release message step name

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: David Leal <[email protected]>

* Changed all 'svg' to "SVG"

Co-authored-by: Clemens Bastian <[email protected]>
Co-authored-by: David Leal <[email protected]>
  • Loading branch information
3 people authored May 12, 2021
1 parent 2c8345b commit 77f868c
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 289 deletions.
26 changes: 0 additions & 26 deletions .github/drafts/check_svgs_monthly.py

This file was deleted.

42 changes: 0 additions & 42 deletions .github/drafts/check_svgs_monthly.yml

This file was deleted.

109 changes: 0 additions & 109 deletions .github/drafts/peek_icons imgur.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/scripts/build_assets/arg_getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ def get_check_svgs_on_pr_args():
return parser.parse_args()


def get_check_svgs_monthly_args():
"""
Get the commandline arguments for the check_svgs_monthly.py.
"""
parser = ArgumentParser(description="Check the SVGs to ensure their attributes are correct. Run monthly.")
parser.add_argument("devicon_json_path",
help="The path to the devicon.json",
action=PathResolverAction)

parser.add_argument("icons_folder_path",
help="The path to the icons folder",
action=PathResolverAction)
return parser.parse_args()


def get_release_message_args():
"""
Get the commandline arguments for get_release_message.py.
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/build_assets/filehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_added_modified_svgs(files_added_json_path: str,

def write_to_file(path: str, value: any):
"""
Write the value to a JSON file.
Write the value to a file.
"""
with open(path, "w") as file:
file.write(value)
51 changes: 27 additions & 24 deletions .github/scripts/check_svgs_on_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,42 @@ def check_svgs(svg_file_paths: List[Path]):
# batch err messages together so user can fix everything at once
err_msgs = []
for svg_path in svg_file_paths:
tree = et.parse(svg_path)
root = tree.getroot()
namespace = "{http://www.w3.org/2000/svg}"
err_msg = [f"{svg_path}:"]
try:
tree = et.parse(svg_path)
root = tree.getroot()
namespace = "{http://www.w3.org/2000/svg}"
err_msg = [f"{svg_path}:"]

if root.tag != f"{namespace}svg":
err_msg.append(f"-root is '{root.tag}'. Root must be an 'svg' element")
if root.tag != f"{namespace}svg":
err_msg.append(f"-root is '{root.tag}'. Root must be an 'svg' element")

if root.get("viewBox") != "0 0 128 128":
err_msg.append("-'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg")
if root.get("viewBox") != "0 0 128 128":
err_msg.append("-'viewBox' is not '0 0 128 128' -> Set it or scale the file using https://www.iloveimg.com/resize-image/resize-svg")

acceptable_size = [None, "128px", "128"]
if root.get("height") not in acceptable_size:
err_msg.append("-'height' is present in svg element but is not '128' or '128px' -> Remove it or set it to '128' or '128px'")
acceptable_size = [None, "128px", "128"]
if root.get("height") not in acceptable_size:
err_msg.append("-'height' is present in svg element but is not '128' or '128px' -> Remove it or set it to '128' or '128px'")

if root.get("width") not in acceptable_size:
err_msg.append("-'width' is present in svg element but is not '128' or '128px' -> Remove it or set it to '128' or '128px'")
if root.get("width") not in acceptable_size:
err_msg.append("-'width' is present in svg element but is not '128' or '128px' -> Remove it or set it to '128' or '128px'")

if root.get("style") is not None and "enable-background" in root.get("style"):
err_msg.append("-deprecated 'enable-background' in style attribute -> Remove it")
if root.get("style") is not None and "enable-background" in root.get("style"):
err_msg.append("-deprecated 'enable-background' in style attribute -> Remove it")

if root.get("x") is not None:
err_msg.append("-unneccessary 'x' attribute in svg element -> Remove it")
if root.get("x") is not None:
err_msg.append("-unneccessary 'x' attribute in svg element -> Remove it")

if root.get("y") is not None:
err_msg.append("-unneccessary 'y' attribute in svg element -> Remove it")
if root.get("y") is not None:
err_msg.append("-unneccessary 'y' attribute in svg element -> Remove it")

style = root.findtext(f".//{namespace}style")
if style != None and "fill" in style:
err_msg.append("-contains style declaration using 'fill' -> Replace classes with the 'fill' attribute instead")
style = root.findtext(f".//{namespace}style")
if style != None and "fill" in style:
err_msg.append("-contains style declaration using 'fill' -> Replace classes with the 'fill' attribute instead")

if len(err_msg) > 1:
err_msgs.append("\n".join(err_msg))
if len(err_msg) > 1:
err_msgs.append("\n".join(err_msg))
except et.ParseError as e:
raise Exception(f"SVG Error in file: {svg_path}. Full Error: \n" + str(e))

if len(err_msgs) > 0:
return "\n\n".join(err_msgs)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get_release_message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Get Release Message
on: workflow_dispatch
jobs:
build:
name: Get Fonts From Icomoon
name: Get features since last release
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
Expand Down
Loading

0 comments on commit 77f868c

Please sign in to comment.