BirjuVachhani / spider

A small dart library to generate Assets dart code from assets folder.
https://spider.birju.dev/
Apache License 2.0
190 stars 19 forks source link

Allow nested class / sub class #75

Open hbock-42 opened 1 year ago

hbock-42 commented 1 year ago

Is your feature request related to a problem? Please describe. This is not really a problem as I am able to use the package without trouble, this is more a quality-of-life feature request. Let's say I have images under different folders (maybe because they will be used in different features inside the application, or because they are of different types):

- images 
      |---svgs
            |---sgv1
            |---svg2
            |---.....
      |---png
            |---png1
            |---.....

Right now with spider I can create 2 classes, Svgs and Pngs, or create 1 class containing every Svgs and Pngs. I can add a prefix to the Pngs and a prefix to the Svgs, but when using it I will have to do: Images.pngName1 for a png named Name1 and Images.svgName2 for a svg named Name2.

Describe the solution you'd like I would like to do: Images.png.name1 and Images.svg.name2

I think we could add a parameter to the spider.yaml or spider.json file when creating a class called sub_classes (like the sub_groups param works). It would look something like that:

groups:
  - class_name: Images
    sub_classes:
      - path: assets/images/svgs
        class_name: svg
        types: [ .svg ]

      - path: assets/images/pngs
        class_name: png
        types: [ .png ]