1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-19 20:57:53 +02:00
Carlos Alexandro Becker 09be848e1a
feat(build): initial support for zig ()
Continuing on  and , this finally adds Zig support to
GoReleaser!

Things are very raw still, plenty of use cases to test (please do test
on your project if you can), but it does work at least for simple
projects!

A release done by this:
https://github.com/goreleaser/example-zig/releases/tag/v0.1.0

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-11-28 08:47:20 -03:00

62 lines
2.2 KiB
Python

from __future__ import annotations
import posixpath
import re
from mkdocs.config.defaults import MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.pages import Page
from re import Match
# very much stolen/based on https://github.com/squidfunk/mkdocs-material/blob/master/src/overrides/hooks/shortcodes.py
def on_page_markdown(markdown: str, *, page: Page, config: MkDocsConfig, files: Files):
# Replace callback
def replace(match: Match):
type, args = match.groups()
args = args.strip()
if type == "version": return _version_block(args)
elif type == "pro": return _pro_ad(page, files)
elif type == "featpro": return _pro_feat_ad(page, files)
elif type == "templates": return _templates_ad()
elif type == "alpha": return _alpha_block()
# Otherwise, raise an error
raise RuntimeError(f"Unknown shortcode: {type}")
# Find and replace all external asset URLs in current page
return re.sub(
r"<!-- md:(\w+)(.*?) -->",
replace, markdown, flags = re.I | re.M
)
def _pro_feat_ad(page: Page, files: Files):
return "".join([
f"<div class=\"admonition example\">",
f"<p class=\"admonition-title\">GoReleaser Pro</p>",
f"<p>This feature is exclusively available with <a href=\"/pro/\">GoReleaser Pro</a>.</p>",
f"</div>"
])
def _pro_ad(page: Page, files: Files):
return "".join([
f"<div class=\"admonition example\">",
f"<p class=\"admonition-title\">GoReleaser Pro</p>",
f"<p>One or more features are exclusively available with <a href=\"/pro/\">GoReleaser Pro</a>.</p>",
f"</div>"
])
def _version_block(text: str):
return f"> Since :material-tag-outline: <a href=\"/blog/goreleaser-{text}\">{text}</a>."
def _alpha_block():
return f"> :material-flask-outline: This feature is in alpha, and your feedback is very welcome!"
def _templates_ad():
return "".join([
f"<div class=\"admonition tip\">",
f"<p class=\"admonition-title\">Tip</p>",
f"<p>Discover more about the <a href=\"/customization/templates/\">name template engine</a>.</p>",
f"</div>"
])