Skip to content

Major updates to Caddyfile lexer#932

Merged
alecthomas merged 3 commits intoalecthomas:masterfrom
francislavoie:caddyfile-updates
Feb 20, 2024
Merged

Major updates to Caddyfile lexer#932
alecthomas merged 3 commits intoalecthomas:masterfrom
francislavoie:caddyfile-updates

Conversation

@francislavoie
Copy link
Copy Markdown
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
Copy Markdown
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
@alecthomas
Copy link
Copy Markdown
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.

2 participants