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

Attempted fix for same func and var names #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MSalopek
Copy link

This should enable the user to choose whether or not they want all code to be generated or just the code that returns a map of all available methods -> by using the flag "skip-defaults".
Also, Headers and Footers get renamed: HeaderFileName and FooterFileName so every file would have different header and footer names.
Please review.

@awalterschulze
Copy link
Member

Is it possible to only give each file unique Header and Footer names, to avoid same func and var names?
That way we won't need another flag?

@MSalopek
Copy link
Author

I'm sorry, would you please elaborate your idea? Thanks!

@awalterschulze
Copy link
Member

awalterschulze commented Mar 19, 2018 via email

@MSalopek
Copy link
Author

MSalopek commented Mar 19, 2018

It is possible, yes. But the name func NewHandler will remain the same for all the files, that is something you would like to keep?

@@ -100,6 +101,15 @@ func (p *html) generateFormFunc(servName string, method *descriptor.MethodDescri
</div>`
p.P(`var Form`, servName, "_", generator.CamelCase(method.GetName()), " string = `", s, "`")
}
func processFileName (inStr string) string {
reg, err := regexp.Compile("[^a-zA-Z0-9]+")
Copy link
Member

Choose a reason for hiding this comment

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

regexp.MustCompile and then it could rather be done as part of init or a var.

var alphaNum = regexp.MustCompile("[^a-zA-Z0-9]+")

s := strings.TrimSuffix(inStr, ".proto")
processed := strings.Replace(strings.Title(reg.ReplaceAllString(s," ")), " ", "", -1)
return processed
}

func (p *html) Generate(file *generator.FileDescriptor) {
Copy link
Member

Choose a reason for hiding this comment

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

Technically the html struct has state.
So it can remember to only generate some things once itself per package, without using a flag.
What do you think about that proposal?

Sorry for pushing this, but I want to try and keep things as simple as possible.

Copy link
Member

Choose a reason for hiding this comment

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

Then we also don't need custom HeaderFooterName

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

2 participants