Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Add documentation for each template #2

Merged
merged 12 commits into from
May 7, 2017

Conversation

AliSoftware
Copy link
Collaborator

@AliSoftware AliSoftware commented Jan 4, 2017

As discussed in SwiftGen/SwiftGen#232

⚠️ WIP ⚠️

This template is the default template used by SwiftGen when parsing images in Asset Catalogs.
It generates Swift 3 code and is suitable for most needs.

## Customization
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should now actually separate that section to show both --param and ENV possible customizations (maybe in the same section, but find a way to make them both visible anyway)

Copy link
Member

Choose a reason for hiding this comment

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

I think the whole explanation about "customize using --param" and that we load ENV variables, should be in the SwiftGen documentation itself. Here we should only document what is accepted (and in some cases "why"), and link to the swiftgen docs on how to use it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed.

| Name | Description |
| --------- | ----------------- |
| File name | images-default.stencil |
| Invocation example | `swiftgen storyboard -t default …` |
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That should b swiftgen images … instead, obviously

## When to use it

This template is the default template used by SwiftGen when parsing images in Asset Catalogs.
It generates Swift 3 code and is suitable for most needs.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now that I think of it, when I thought about adding that section at first, is was more to say:

"This template is more suitable for when you name your images with underscores" or "This template is more suitable for when you use that "provides namespace" checkbox on the folders inside your xcasset catalog", and "this template supports multiple catalogs by creating a separate enum for each catalog", stuff like that

Copy link
Member

Choose a reason for hiding this comment

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

Aren't we getting rid of the flat images enum in 5.0? #11

I get the intention though, but think that quite a few recommendations won't be needed once we remove the old stuff. Some options will probably remain, like the flat strings version, and can provide recommendations for those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that PR was opened before we even decided to get rid of the "default" behavior even.

Again the idea behind this paragraph, which would be probably more useful for the strings templates especially, is to tell which template to use depending on which banking conventions you have as input (how you name your strings keys for example, are you the kind of people that use all-caps keys, or keys structured with dots or underscore to separate the key parts, etc… and what do you expect as output (structured, not structured…)

Might be less relevant for images template because the naming doesn't impact the structural split (the organisation of the assets catalog does), but you get the idea. Because not everyone has the same naming and organization conventions the aim is to help people choose the right template for them.

<summary>Full generated code</summary>

```swift
(the full code here)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(or a link to the "expected output" fixture)

Copy link
Member

Choose a reason for hiding this comment

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

As we have the output files for testing, and because they are prone to change, it might be best to just link to them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the full code I totally agree.

For the extract it would be nice if we could try to keep it here in that documentation and try to keep it uo to date, because it allows people to see it at a glance.

@djbe
Copy link
Member

djbe commented Apr 17, 2017

I wanted to work on the documentation today, but am not sure how much worth it is, as we'll be removing quite a few things once we work on 5.0. Do I only document the templates we want to keep for 5.0?

@AliSoftware
Copy link
Collaborator Author

I think it's only worth working on documenting templates we intend to keep. No need to document things (templates, tags, filters or anything) that we intend to drop in 5.0

@djbe djbe force-pushed the feature/templates-documentation branch from 1e18d17 to fbbedff Compare April 17, 2017 17:08
@djbe djbe force-pushed the feature/templates-documentation branch from a46d637 to 8d1999d Compare April 24, 2017 17:28
@djbe djbe force-pushed the feature/templates-documentation branch 2 times, most recently from a0aa747 to eaa66b8 Compare May 7, 2017 00:01
@djbe djbe removed the status: WIP label May 7, 2017
@djbe djbe mentioned this pull request May 7, 2017
18 tasks
@djbe djbe added this to the SwiftGen 4.2.1 milestone May 7, 2017
AliSoftware and others added 10 commits May 7, 2017 23:14
My view on those sections is to be a checklist for users to see if their situation or the way they use/write the input files matches what is expected by the templates.

For example for strings template, depending on if you're using dot-syntax in your Localizable.strings or not, you might want one template or the other, so that section is supposed to tell you which template to use depending on how you write your keys. In future other string templates we might add bullet points like "If you use underscores in your key names" or "if all your keys in your Localizable.strings are all full-uppercase", etc.
@djbe djbe force-pushed the feature/templates-documentation branch from ef345f3 to a076000 Compare May 7, 2017 21:25
## When to use it

- When you need to generate *Swift 2* code
- If you use unstructured keys for your strings, or a structure that we don't support (yet). If you use "dot-syntax" keys, please check out the [dot-syntax](dot-syntax.md) template.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"unstructured key names"?

@djbe djbe force-pushed the feature/templates-documentation branch from a076000 to 4208973 Compare May 7, 2017 21:30

## Customization

You can customise some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param <paramName> <newValue>`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

s/customise/customize/, right? (applies on every doc file)

@AliSoftware AliSoftware self-assigned this May 7, 2017
@AliSoftware AliSoftware merged commit 431f2f2 into master May 7, 2017
@AliSoftware AliSoftware deleted the feature/templates-documentation branch May 7, 2017 21:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants