Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer for devicon.json and icon directories #1623

Closed
wants to merge 6 commits into from
Closed

Analyzer for devicon.json and icon directories #1623

wants to merge 6 commits into from

Conversation

ConX
Copy link
Contributor

@ConX ConX commented Jan 9, 2023

This script is based on https://gist.github.com/lunatic-fox/60e5eb541b299812b3c123fdc0cf4668 by @lunatic-fox

Double-check these details before you open a PR

  • PR does not match another non-stale PR currently opened

Features

This is a modified version of the analyzer.py script by @lunatic-fox with the following improvements:

  • Modes:
    • Can generate a JSON/dictionary list of all the modifications
    • Can generate a Markdown report using the JSON
    • Can update the devicon.json based on all the changes
      • It sorts the dictionary before updating it
  • Command line interface to control the above modes (see the "Help" subsection below)
  • The script can run against the complete icons/ directory for fixing the current state or per technology later during PRs
  • Organized in functions for better maintainability and extensibility
  • Added a check if a font-version reference corresponds to a multicolor SVG
  • Will add a check for the view_port

Help

Usage: devicon_json_analyzer.py [OPTIONS] [ICONS_DIR]

  Analyze devicon.json file.

  The default ICONS_DIR is `icons/` which contains all icons. When running for
  a PR, a single-technology directory can be selected instead.

Options:
  -d, --devicon-json-path TEXT  Path to devicon.json file.
  -g, --generate-report         Generate markdown report.
  -p, --print-issues            Print issues.
  -u, --update-json             Update devicon.json file.
  --help                        Show this message and exit.

Example report when ran in the current develop branch

## akka
  - missing_svg_versions
    - plain
    - plain-wordmark

## alpinejs
  - multicolor_font_version
    - original-wordmark

## appwrite
  - redundant_aliases
    - {'base': 'plain', 'alias': 'original'}
    - {'base': 'plain-wordmark', 'alias': 'original-wordmark'}
[...]

Corresponding devicon.json diff

--- a/devicon.json
+++ b/devicon.json
@@ -78,29 +78,31 @@
     {
         "name": "akka",
         "altnames": [
             "akka-framework"
         ],
         "tags": [
             "framework",
             "java",
             "scala",
             "open-source"
         ],
         "versions": {
             "svg": [
                 "original",
-                "original-wordmark"
+                "original-wordmark",
+                "plain",
+                "plain-wordmark"
             ],
             "font": [
                 "plain",
                 "plain-wordmark"
             ]
         },
         "color": "#15a9ce",
         "aliases": []
     },
@@ -518,46 +520,37 @@
         "tags": [
             "cloud",
             "platform",
             "server"
         ],
         "versions": {
             "svg": [
                 "original",
                 "original-wordmark",
                 "plain",
                 "plain-wordmark"
             ],
             "font": [
                 "plain",
                 "plain-wordmark"
             ]
         },
         "color": "#f02e65",
-        "aliases": [
-            {
-                "base": "plain",
-                "alias": "original"
-            },
-            {
-                "base": "plain-wordmark",
-                "alias": "original-wordmark"
-            }
-        ]
+        "aliases": []

This PR closes NONE

Notes

This is an early PR to get feedback if this is useful and if it fits with all other scripts and plans of the dev team. The script likely needs more testing before being used for repo changes.

Comment on lines 143 to 144
# TODO: Ask the team if theses versions should be removed.
# icon["versions"]["font"].remove(version)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the icons listed under ["versions"]["font"] but aren't monochromatic be removed, or is it ok since the Icomoon build can remove them?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo they should ideally be removed if they aren't monochromatic. But note that any version can be monochromatic, so you'll have to check the file content to find out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function does that; I just have commented out the line that removes it from the devicon.json. The function simply checks how many fill colors there are, and if it's more than one, it marks it as "non-monochromatic." Moreover, it also checks if there is the word "gradient" in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a data point, looking at the output from the current develop branch 30 icons will be removed from the font version references.

@lunatic-fox
Copy link
Contributor

Seriously @ConX, you made a really great job here.
Loved it, just by looking quickly to your code! 🤩🚀
As soon as I have more spare time I'll be reviewing it properly.😁
Can't wait to see it merged! 🤩

 - Implemented bounding box check using Selenium, since I couldn't find
   a good python implementation. Due to this it's slow, taking about 15
   minutes for the whole `icons/` directory in develop. This check is
   disabled by default and requires the `-b` flag.
 - Improved code organization. Later we might need to split into multiple
   files. Extracted a few more utility functions.
This will need to be moved or merged depending on how we plan to use the
script and organize the `.github/` directory.
@ConX
Copy link
Contributor Author

ConX commented Jan 11, 2023

Thanks a lot for the kind words @lunatic-fox! 🚀

I just pushed a couple of commits, the major change them being the following:

Implemented bounding box check using Selenium, since I couldn't find
a good python implementation. Due to this it's slow, taking about 15
minutes for the whole icons/ directory in develop. This check is
disabled by default and requires the -b flag.

The good news is that the view box must be correct for all icons in develop. On the other hand, there are several violations of the bounding box size rule. Given that @Snailedlt mentioned that the padding rule wasn't there from the beginning, it makes sense why there are several icons that have both dimensions smaller than 128. What is more surprising is that there are some icons that go outside the view box. Since this the script takes a while to run that check, here is the list:

{
 "apl": ["plain"],
 "bash": ["plain"],
 "blender": ["original-wordmark"],
 "capacitor": ["original", "plain", "plain-wordmark"],
 "cassandra": ["plain-wordmark"],
 "clarity": ["original-wordmark", "plain-wordmark"],
 "codepen": ["plain"],
 "composer": ["original"],
 "cplusplus": ["line"],
 "crystal": ["original-wordmark"],
 "discordjs": ["original", "original-wordmark", "plain", "plain-wordmark"],
 "embeddedc": ["plain"],
 "fastapi": ["original", "plain"],
 "faunadb": ["line", "line-wordmark", "original", "original-wordmark"],
 "figma": ["original", "plain"],
 "fortran": ["original"],
 "hadoop": ["original-wordmark", "plain-wordmark"],
 "hardhat": ["original-wordmark", "plain-wordmark"],
 "jeet": ["original", "original-wordmark"],
 "julia": ["original-wordmark", "plain-wordmark"],
 "kaggle": ["original"],
 "labview": ["original", "original-wordmark"],
 "laravel": ["original"],
 "materializecss": ["original", "plain"],
 "mobx": ["original", "plain"],
 "nestjs": ["plain"],
 "nuxtjs": ["original-wordmark", "plain-wordmark"],
 "packer": ["original"],
 "perl": ["original", "plain"],
 "pfsense": ["original"],
 "phoenix": ["original-wordmark"],
 "photonengine": ["original", "plain"],
 "processing": ["original", "original-wordmark"],
 "qodana": ["original", "plain"],
 "qt": ["original"],
 "rails": ["plain-wordmark"],
 "rspec": ["original"],
 "socketio": ["original-wordmark"],
 "solidity": ["original"],
 "spring": ["original", "plain"],
 "spss": ["plain"],
 "sqlalchemy": ["original-wordmark"],
 "sqlite": ["original-wordmark", "plain", "plain-wordmark"],
 "stata": ["original-wordmark"],
 "svelte": ["original"],
 "tauri": ["original"],
 "tensorflow": ["line-wordmark", "original-wordmark"],
 "twitter": ["original"],
 "vercel": ["original-wordmark"],
 "vertx": ["original"],
 "vscode": ["original", "original-wordmark", "plain", "plain-wordmark"],
 "vuejs": ["line-wordmark", "original-wordmark", "plain", "plain-wordmark"],
 "weblate": ["original", "plain"],
 "woocommerce": ["original", "plain"],
 "yii": ["original-wordmark", "plain-wordmark"],
 "yunohost": ["original"]
}

This is a much faster implementation than the previous with Selenium.
@Snailedlt Snailedlt added devops Use this label for devops related enhancements enhancement labels Jan 18, 2023
@Panquesito7 Panquesito7 linked an issue Feb 8, 2023 that may be closed by this pull request
1 task
Copy link
Member

@Panquesito7 Panquesito7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no Python expert, but from what can I see, this is looking great!
Thank you so much for your contributions. 🚀

@Snailedlt
Copy link
Collaborator

@ConX great work on this! I've started reviewing it a bit, but I don't have much time for devicons lately, so it might take some time before the full review comes out.

Also thank you for providing the list of icons that extend past the viewbox. I'm looking forward to checking out how you check it :D

@ConX ConX closed this by deleting the head repository May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops Use this label for devops related enhancements enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Incorrect references in devicon.json
4 participants