Comments (5)
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 all
swiftgen` 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.
Hello added #34
Please check it,
Have several comments:
- did not add to colors command, as not sure that it is required for this.
- 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.
- 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
- 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 thecase
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.
@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 asnakeToCamelCase
filter for example, which converts a string fromsnake_case
tocamelCase
, 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.
0.6.0 has just been submitted to Homebrew, and will be available for brew install
soon!
from swiftgen.
Related Issues (20)
- FatalError when trying to set Asset.color as foregroundColor into NSMutableAttributedString attribute HOT 2
- Unprintable ASCII character found in Swift Source Code HOT 1
- SVG images being ignored in assets HOT 1
- The SwiftGen configuration automatically substitutes fileprivate in the initialization of ColorAsset HOT 1
- Adding Extra parameter when running SwiftGen through Xcode HOT 1
- Error: `swiftgen.yml` is not a config file HOT 4
- String template is not able to generate a function with a string parameter and a plural int HOT 2
- Make `SwiftUI` types the default and not `UIKit` types. HOT 1
- Color Generated with SwiftUI HOT 2
- disable Font typealias? HOT 1
- Addition of .string file changes all previous strings usage HOT 1
- Ability to change Locale HOT 6
- Feature Request: Public access to either the fallback string or the ability to specify locale HOT 2
- Add ability to refer file name of JSON HOT 3
- Support for visionOS HOT 2
- Is this repo deprecated? HOT 4
- Add an XcodeBuiltToolPlugin for swiftgen HOT 5
- [Homebrew] Error: swiftgen has been disabled because it does not build! HOT 10
- Apple privacy manifest support HOT 2
- SwiftGen Errors on Swift 6 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftgen.