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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major updates to Caddyfile lexer #932

Merged
merged 3 commits into from Feb 20, 2024

Conversation

francislavoie
Copy link
Contributor

Since I've last touched the lexer in #363 #365 we've had plenty of minor syntax adjustments to the Caddyfile. Took me a long time to get in the headspace to want to tackle updating the lexer, it's quite complicated!

We use this lexer for the official Caddy docs https://caddyserver.com/docs/caddyfile/concepts where Caddy itself serves its own syntax via Markdown. It's awesome that Caddy can highlight its own code 馃榿

I went through every page in the docs we have to find all the edgecases that were broken in one way or another. I used a go.mod replace in Caddy to point to my checkout of Chroma which I was editing, and used https://github.com/cespare/reflex to watch for my file changes and rebuild+restart Caddy so I could just refresh my browser to see effect of my changes to the lexer. I used this crazy command to do this (had to cross through 3 different git repos with cd 馃槀)

$ (cd ../../../chroma/ && reflex -s -g 'lexers/caddyfile.go' -- sh -c 'cd ../caddy/cmd/caddy && go build && cd ../../../website/ && ../caddy/cmd/caddy/caddy run')

Added lots more contrived config examples to the caddyfile.actual test to cover most of the changes I've made.

I'm not satisfied with the heredoc (see #929) because I'd like to be able to parse the placeholders (LiteralStringEscape) inside the heredoc text, but I'd probably need to write a custom Mutator to do that and that felt daunting. But good enough for now I think.

@francislavoie
Copy link
Contributor Author

francislavoie commented Feb 20, 2024

lexers/caddyfile.go:11:5: G101: Potential hardcoded credentials (gosec)

馃槀 what the heck, I guess I'll throw a // nolint on that

@alecthomas alecthomas merged commit 381050b into alecthomas:master Feb 20, 2024
2 checks passed
@alecthomas
Copy link
Owner

Go home linter, you're drunk.

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