Comments (11)
It's an interesting option to add, but I think we have much more things to add before we should consider implementing this.
When we start to mutate original Source then I start getting a little more worried about potential implications, FWIW. you wouldn't be able to use private
code in that case anyway, only fileprivate
.
Once we get to more stable feature set then we can explore this feature, does that make sense?
from sourcery.
Sure, not even for 1.0 maybe.
from sourcery.
I'll probably consider how to implement this next because it would be convenient for things like NSCoding etc
from sourcery.
How do we feel about this syntax for both code and template:
// sourcery:inline:Type.AutoCoding
// sourcery:end
It would:
- Remove the body of that generated pattern while parsing (to avoid chicken-egg problem)
- Find the same pattern in one of the template generated code
- Replace the source code with generated code
- [Question] Comment out or Remove the Template fragment?
from sourcery.
What do you mean by "comment or remove the template fragment"? Do you mean these annotations for source code?
from sourcery.
I wonder what should happen inside the output swift file (because there might be more code than just the inline fragments, whether we comment it out, or remove it completely when we put it inside the project source code.
e.g. currently NSCoding has commented out code, that the replacePlaceholders
script uses, we won't do it like that obviously, but I wonder if having commented out code that we replace wouldn't be helpful, especially in watcher mode
from sourcery.
You mean having this in template:
something else
// sourcery:inline:Type.AutoCoding
...
// sourcery:end
something else
should we remove what is generated by everything outside annotated block? I would say yes. Otherwise it may be just easier to put the name of the template in the annotation and just put everything generated by it in the source file. And in the end templates as everything else should do one thing only.
Why do you think we would need to keep it commented?
from sourcery.
this is what I mean:
e.g. Template.stencil
some common code needed for the template
{% for type in types.implementing.AutoCoding %}
// sourcery:inline:{{ type.name }}.NSCoding
required init?(coder aDecoder: NSCoder) {
...
}
// sourcery:end
e.g. source code:
class Foo: NSObject, AutoCoding {
// sourcery:inline:Foo.NSCoding
This is where the code would be injected
// sourcery:end
}
What happens in Template.generated.swift
?
a) the code between sourcery:inline disappear completely
b) the code between sourcery:inline is commented out but there (same as injected into source)
from sourcery.
Now I get it =) I would go for "a" but will maybe add a comment saying "generated code inlined in file ..."
from sourcery.
Ok, just to confirm something
I use the inline approach for all of the generated code in my project.
The following file demands I have an output
key.
while reading .yml 'some/path/.sourcery.yml'. 'Invalid output. 'output' key is missing or is not a string or object.'
The presence of an output key in the following file seems to generate an empty file called someName.generated.swift
sources:
- some/path
templates:
- some/path
output:
./
There is currently no option to stop this file from being generated, right?
It's not the end of the world as I can just exclude it from compile sources & git.
from sourcery.
@rob-nash the output path is required, as well as sources and templates paths. The empty generated files are supposed to be removed. If not - that's a bug, you may want to create a new issue with a reproducible example.
from sourcery.
Related Issues (20)
- Malformed generated mocks HOT 1
- Missing bin folder with 2.1.3 HOT 5
- Missing bin folder with 2.1.4 HOT 5
- Homebrew does not include latest version (2.1.4) HOT 3
- The platform of the target `MyApp` (iOS 16.0) is not compatible with `Sourcery (2.1.4)`, which does not support `iOS` HOT 18
- AutoMockable stencil does not support inout parameters HOT 3
- Generated Automockable compilation issue due to malformed generated variable name HOT 2
- Generated AutoMockable compilation issue due to variadic parameters HOT 11
- [BUG] Generated AutoMockable compilation issues HOT 1
- Windows Support
- Sourcery doesn't properly work when using protocols with primary associated types HOT 2
- Add whitespace trimming configuration for Stencil templates
- [QUESTION] Thread-Safe Mocks HOT 1
- [Bug] Failed to resolve dependencies (SPM issue) HOT 5
- Watch mode only watches sources from last configuration file when passing multiple paths to configuration files using `--config` command line options
- Getting generic requirements from methods HOT 1
- Possible to generate asset catalog constants? HOT 1
- Detecting if a variable is an Enum works if enum is declared in the file but doesn't otherwise. HOT 4
- AutoMockable does not generate valid Swift code during method generic requirement parsing HOT 2
- Swift macros and method bodies HOT 1
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 sourcery.