Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement method documentation tags. #10

Closed

Conversation

sjames-iberis
Copy link

A documentation tag defines a JSON representation of a map that is available to a template via the Docs property of a Method node.
There are no constraints on how it is used but, for example, it could define hints about how/if parameters/results should be logged.

A documentation tag defines a JSON representation of a map that is available to a template via the Docs property of a Method node.
There are no constraints on how it is used but, for example, it could define hints about how/if parameters/results should be logged.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 25

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.262%

Totals Coverage Status
Change from base Build 24: 0.0%
Covered Lines: 230
Relevant Lines: 244

💛 - Coveralls

Interface methods can be preceded by documentation comments with gowrap tags to define a map that a template can use to modify its code generation.
For example, this might be used to indicate to a template generating logging decorators that password values should not be logged:
```
//+gowrap: {"Log":{"pass":"xxxxx"}}
Copy link
Owner

Choose a reason for hiding this comment

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

@sjames-iberis I don't really like JSON annotations in Go code.
I think in most of the cases it's enough to just use multiple annotations for that. Just an example:

//+gowrap: pass skip-loging
//+gowrap: pass some-other-option
//+gowrap: ctx skip-logging

Or alternatively:

//+gowrap: pass skip-loging, some-other-option
//+gowrap: ctx skip-logging

In this case such annotations can be placed in a map:

map[string][]string{
  "pass": []string{"skip-logging", "some-other-option"},
}

So you can access it from the code.

Also I recently implemented template vars that can be passed from the command line via -v flag maybe it can work better for you so there will be no need to spoil the methods' comments in the code?
Instead you can just pass any number of variables from the command line:
gowrap gen -p io -i Writer -t log -o writer_with_log.go -v pass=skip-logging

Copy link
Owner

Choose a reason for hiding this comment

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

Also take a look at this issue #9
There's similar problem but the solution is more generic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants