Coder Social home page Coder Social logo

Comments (5)

AliSoftware avatar AliSoftware commented on May 22, 2024

This is the line (+ this one) that makes your _ disappear.

I agree that not allowing _ was a arbitrary choice. I'm ok with just getting rid of that forbiddenChars: _ parameter in all the calls to asSwiftIdentifier() (probably for all 4 subcommands, for consistency's sake).

Note that now that #30 is merged, it would also be easy to add a command-line option like --excludechars to allswiftgen` subcommands, that would allow the user to define a list of forbidden chars (defaulting to en empty list probably).

Could you maybe make a PR to fix that?

from swiftgen.

Igor-Palaguta avatar Igor-Palaguta commented on May 22, 2024

Hello added #34

Please check it,

Have several comments:

  1. did not add to colors command, as not sure that it is required for this.
  2. Also not sure where is better to exclude this characters during storyboard generation
    I used excludechars everywhere where you forbid "_", but as a result we have following ugly names like validate_PasswordViewController
case Validate_Password = "Validate_Password"
            static func validate_PasswordViewController() -> UIViewController {
                return Wizard.Validate_Password.viewController()
            }

I think underscore can be left just for cases, what do you think?
3) For compatibility with previous version, had to set "_" by default

from swiftgen.

AliSoftware avatar AliSoftware commented on May 22, 2024
  1. I think it could be useful to make the same for colors.
  • In the current version of SwiftGen, the colors are generated from a .txt file that the user manually typed, so there is probably no need for excluding chars (the user would just not put them in the first place).
  • But in future versions (see #15) the input could be something else, like an XML coming from an Android project. And in such cases, it would make sense to be able to choose which chars to exclude
  1. Yeah maybe you shouldn't use the same excludes everywhere in the code, like for the func validate_Password excluding the _ would be nicer even if the user didn't exclude it for the case names…

This could be different options from the CLI, but honestly I wouldn't bother much about it (and avoid adding too much options), because once #24 will be done, that won't even matter, as everyone would be able to use their own templates and exclude whatever chars they want for each part of the generated output.

from swiftgen.

AliSoftware avatar AliSoftware commented on May 22, 2024

@Igor-Palaguta now that the master branch of SwiftGen uses templates (via Stencil), the identifiers are generated using a "filter", which doesn't exclude _ anymore.

For this reason, I've removed the --excludeChars flag you added in #34 from the CLI, because:

  • If one wants to exclude _ they could create a custom template that fits their need instead, which is way more flexible.
  • For now Stencil filters can't have parameters (even if it might come very soon) so there is no way to pass characters to exclude to those filters;
  • But if someone doesn't want _ in the identifiers of their generated code, we could imagine creating a snakeToCamelCase filter for example, which converts a string from snake_case to camelCase, so that people wanting that could use it in their custom templates.

Could you please test the master branch (clone this repo + use rake install like explained in the README) and close this issue if you're ok with the new current behavior?

Thanks! πŸ‘

from swiftgen.

AliSoftware avatar AliSoftware commented on May 22, 2024

0.6.0 has just been submitted to Homebrew, and will be available for brew install soon!

from swiftgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.