From 594d9bb4bac6a16d2c88c9b5bc6ff4b767013460 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sat, 11 Jan 2025 11:22:39 -0500 Subject: [PATCH] Add header, track build ref --- .github/workflows/ci.yml | 4 +++- _tools/restylers-docs/src/Restylers/Docs/Main.hs | 6 +++--- .../restylers-docs/src/Restylers/Docs/Render.hs | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5e7d6aa..92d3b5d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,7 +169,7 @@ jobs: run: | chmod +x ./restylers-docs - ./restylers-docs restylers.yaml > _docs/restylers.md + ./restylers-docs $GH_REF restylers.yaml > _docs/restylers.md git config user.name "github-actions[bot]" git config user.email "commits@restyled.io" @@ -180,6 +180,8 @@ jobs: fi git push + env: + GH_REF: ${{ github.ref }} release: if: ${{ github.ref == 'refs/heads/main' }} diff --git a/_tools/restylers-docs/src/Restylers/Docs/Main.hs b/_tools/restylers-docs/src/Restylers/Docs/Main.hs index cf38ee47..8a1c2580 100644 --- a/_tools/restylers-docs/src/Restylers/Docs/Main.hs +++ b/_tools/restylers-docs/src/Restylers/Docs/Main.hs @@ -15,9 +15,9 @@ main :: IO () main = do args <- getArgs case args of - [path] -> do + [ref, path] -> do restylers <- Yaml.decodeFileThrow path - T.putStrLn $ renderDocs restylers + T.putStrLn $ renderDocs (pack ref) restylers _ -> do - hPutStrLn stderr "Usage: restyler-docs " + hPutStrLn stderr "Usage: restyler-docs " exitWith $ ExitFailure 64 diff --git a/_tools/restylers-docs/src/Restylers/Docs/Render.hs b/_tools/restylers-docs/src/Restylers/Docs/Render.hs index 2d0fb6d0..74c6fa5c 100644 --- a/_tools/restylers-docs/src/Restylers/Docs/Render.hs +++ b/_tools/restylers-docs/src/Restylers/Docs/Render.hs @@ -19,13 +19,22 @@ import Restylers.Manifest (Restyler (..)) import Restylers.Name (RestylerName (..)) import Text.Shakespeare.Text (st) -renderDocs :: [Restyler] -> Text -renderDocs restylers = +renderDocs :: Text -> [Restyler] -> Text +renderDocs ref restylers = T.unlines - $ restylersTable restylers + $ [header ref] + <> restylersTable restylers <> ["---"] <> map restylerSection restylers +header :: Text -> Text +header ref = + [st| +# Restylers + +Built from `#{ref}` +|] + restylersTable :: [Restyler] -> [Text] restylersTable restylers = headerRows <> map restylerTableRow restylers where