amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.94k stars 560 forks source link

docs: mention `options.className` for `ios-swift/*` formats #1330

Closed julien-deramond closed 2 months ago

julien-deramond commented 2 months ago

Context

I was testing the ios-swift/enum.swift format and found out that there's a options.className available. However, it's not mentioned in the documentation (parameters table), and it's mentioned for Kotlin.

{
  "source": [
    "tests/tokens.json"
  ],
  "platforms": {
    "ios-swift": {
      "transforms": ["attribute/cti", "name/camel", "content/swift/literal", "asset/swift/literal", "size/swift/remToCGFloat"],
      "files": [{
        "destination": "tests/build/TokensEnum.swift",
        "format": "ios-swift/enum.swift",
        "options": {
          "className": "StyleDictionaryEnum"
        }
      },{
        "destination": "tests/build/TokensClass.swift",
        "format": "ios-swift/class.swift",
        "options": {
          "className": "StyleDictionaryClass"
        }
      },{
        "destination": "tests/build/TokensAny.swift",
        "format": "ios-swift/any.swift",
        "options": {
          "className": "StyleDictionaryAny"
        }
      }]
    }
  }
}

Description

So, this PR suggests adding options.className that isn't mentioned for ios-swift/any.swift and ios-swift/enum.swift:

On top of that, I suppose it must also be added in lib/common/formats.js (but not enough familiar with the repo yet to be 100% sure).

⚠️ Same thing here, only ios-swift/any.swift is mentioned in the migration Markdown file here. Maybe ios-swift/enum.swift and ios-swift/class.swift should be there too?

https://github.com/amzn/style-dictionary/blob/ed64beec9a1fffa5c6df5a89ab0e70123e1eca13/docs/src/content/docs/version-4/migration.md?plain=1#L528-L538


Feel free to drop this PR if the quality is not enough, or if you had done it differently :) I'm not that familiar with the repository, so I might have modified the wrong files or missed some things

aws-amplify-us-west-1[bot] commented 2 months ago

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1330.d16eby4ekpss5y.amplifyapp.com

jorenbroekema commented 2 months ago

Hey, thanks for contributing, this looks good to me!

Can you add it to the migration docs as you mentioned?

Maybe ios-swift/enum.swift and ios-swift/class.swift should be there too?

I think you're correct on that one ^.

Also, since you did a small type change in the source code, could you run npx changeset locally in the root of the project and create a changeset (patch) with a small description of the change, so it ends up nicely in the patch notes?

julien-deramond commented 2 months ago

Thanks for the quick review, the required modifications are pushed. Everything is in the same commit. If necessary, I can split it to separate the "doc" and the "lib" content.