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

Looking for call chaining including line-feeds #87

Closed
mcrawfo2 opened this issue Feb 16, 2022 · 7 comments
Closed

Looking for call chaining including line-feeds #87

mcrawfo2 opened this issue Feb 16, 2022 · 7 comments

Comments

@mcrawfo2
Copy link

I am trying to generate a multi-line call chain but go requires the newline between the Dot and the Id, such as:

cfg := NewConfigBuilder().
       WithValue("k", "v").
       WithValue("a", "b").
       Build()

Currently Dot does not appear to support such a mechanism. I've added a DotLine method to Statement (below) but was wondering if there was some canonical way to do this already. If not, can a solution be added?

// DotLine renders a period followed by an newline and an identifier. Use for call chaining.
func (s *Statement) DotLine(name string) *Statement {
	d := token{
		typ:     delimiterToken,
		content: ".\n",
	}
	t := token{
		typ:     identifierToken,
		content: name,
	}
	*s = append(*s, d, t)
	return s
}
@dave
Copy link
Owner

dave commented Feb 16, 2022

Aah unfortunately Jennifer is intentionally simplified... it's more concerned with outputting correct code rather than good looking code.

@thieman
Copy link

thieman commented Aug 2, 2023

@dave could you clarify whether you're saying "I won't accept a PR that implements this" or just "I won't do this myself"?

@dave
Copy link
Owner

dave commented Aug 2, 2023

It's the "I won't accept a PR that implements this". The API is already complex and cluttered... there's hundreds of tweaks I could add if we were concerned with improving the exact formatting of code. I've tried to keep it as simple as possible while still allowing you to output correct, compilable code.

@thieman
Copy link

thieman commented Aug 2, 2023

Thanks for clarifying! Should this issue be closed then?

@dave
Copy link
Owner

dave commented Aug 2, 2023

Sure feel free to close it.

@thieman
Copy link

thieman commented Aug 2, 2023

Not my issue or I would 😂

@dave
Copy link
Owner

dave commented Aug 2, 2023

😂 sorry I'm half asleep today

@dave dave closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
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

No branches or pull requests

3 participants