Skip to content

Commit

Permalink
Add restylers-docs, generates _docs/restylers.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Jan 11, 2025
1 parent af79b99 commit c99bfc5
Show file tree
Hide file tree
Showing 16 changed files with 412 additions and 6 deletions.
37 changes: 36 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: tools
path: ${{ steps.stack.outputs.local-install-root }}/bin/restylers
path: "${{ steps.stack.outputs.local-install-root }}/bin/*"
if-no-files-found: error

changes:
Expand Down Expand Up @@ -148,6 +148,41 @@ jobs:
manifest: ./restylers.yaml
dry-run: true

update-docs:
if: ${{ github.event_name == 'pull_request' }}
needs:
- tools
- restylers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: actions/download-artifact@v4
with: {name: tools}

- uses: actions/download-artifact@v4
with: {name: manifest}

- name: Update and commit _docs
run: |
chmod +x ./restylers-docs
./restylers-docs "$GH_SHA" restylers.yaml > _docs/restylers.md
git config user.name "github-actions[bot]"
git config user.email "[email protected]"
if ! git commit -m "Update docs" _docs/restylers.md; then
echo "No documentation changes"
exit 0
fi
git push
env:
GH_SHA: ${{ github.sha }}

release:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [restylers]
Expand Down
3 changes: 3 additions & 0 deletions .headroom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ source-paths:
- _tools/restylers/app
- _tools/restylers/src
- _tools/restylers/test
- _tools/restylers-docs/app
- _tools/restylers-docs/src
- _tools/restylers-docs/test


## If set to 'true', Headroom tries to detect whether any VCS (like GIT) is used
Expand Down
Empty file added _docs/restylers.md
Empty file.
11 changes: 11 additions & 0 deletions _tools/restylers-docs/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- |
--
-- Module : Main
-- Copyright : (c) 2025 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : POSIX
module Main (main) where

import Restylers.Docs.Main
54 changes: 54 additions & 0 deletions _tools/restylers-docs/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: restylers-docs
version: 0.0.0.0
license: AGPL-3

language: GHC2021

default-extensions:
- DataKinds
- DeriveAnyClass
- DerivingStrategies
- DerivingVia
- DuplicateRecordFields
- GADTs
- LambdaCase
- NamedFieldPuns
- NoFieldSelectors
- NoImplicitPrelude
- NoMonomorphismRestriction
- NoPostfixOperators
- OverloadedRecordDot
- OverloadedStrings
- QuasiQuotes
- TypeFamilies

ghc-options:
- -fignore-optim-changes
- -fwrite-ide-info
- -Weverything
- -Wno-all-missed-specialisations
- -Wno-missed-specialisations
- -Wno-missing-import-lists
- -Wno-missing-kind-signatures
- -Wno-missing-safe-haskell-mode
- -Wno-prepositive-qualified-module
- -Wno-unsafe

dependencies:
- base

library:
source-dirs: src
dependencies:
- aeson
- restylers
- shakespeare
- text
- yaml

executables:
restylers-docs:
main: Main.hs
source-dirs: app
dependencies:
- restylers-docs
75 changes: 75 additions & 0 deletions _tools/restylers-docs/restylers-docs.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.37.0.
--
-- see: https://github.com/sol/hpack

name: restylers-docs
version: 0.0.0.0
license: AGPL-3
build-type: Simple

library
exposed-modules:
Restylers.Docs.Main
Restylers.Docs.Prelude
Restylers.Docs.Render
other-modules:
Paths_restylers_docs
hs-source-dirs:
src
default-extensions:
DataKinds
DeriveAnyClass
DerivingStrategies
DerivingVia
DuplicateRecordFields
GADTs
LambdaCase
NamedFieldPuns
NoFieldSelectors
NoImplicitPrelude
NoMonomorphismRestriction
NoPostfixOperators
OverloadedRecordDot
OverloadedStrings
QuasiQuotes
TypeFamilies
ghc-options: -fignore-optim-changes -fwrite-ide-info -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-import-lists -Wno-missing-kind-signatures -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -Wno-unsafe
build-depends:
aeson
, base
, restylers
, shakespeare
, text
, yaml
default-language: GHC2021

executable restylers-docs
main-is: Main.hs
other-modules:
Paths_restylers_docs
hs-source-dirs:
app
default-extensions:
DataKinds
DeriveAnyClass
DerivingStrategies
DerivingVia
DuplicateRecordFields
GADTs
LambdaCase
NamedFieldPuns
NoFieldSelectors
NoImplicitPrelude
NoMonomorphismRestriction
NoPostfixOperators
OverloadedRecordDot
OverloadedStrings
QuasiQuotes
TypeFamilies
ghc-options: -fignore-optim-changes -fwrite-ide-info -Weverything -Wno-all-missed-specialisations -Wno-missed-specialisations -Wno-missing-import-lists -Wno-missing-kind-signatures -Wno-missing-safe-haskell-mode -Wno-prepositive-qualified-module -Wno-unsafe
build-depends:
base
, restylers-docs
default-language: GHC2021
31 changes: 31 additions & 0 deletions _tools/restylers-docs/src/Restylers/Docs/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- |
--
-- Module : Restylers.Docs.Main
-- Copyright : (c) 2025 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : POSIX
module Restylers.Docs.Main
( main
) where

import Restylers.Docs.Prelude

import Data.Text.IO qualified as T
import Data.Yaml qualified as Yaml
import Restylers.Docs.Render
import System.Environment (getArgs)
import System.Exit (ExitCode (..), exitWith)
import System.IO (hPutStrLn, stderr)

main :: IO ()
main = do
args <- getArgs
case args of
[ref, path] -> do
restylers <- Yaml.decodeFileThrow path
T.putStrLn $ renderDocs (pack ref) restylers
_ -> do
hPutStrLn stderr "Usage: restyler-docs <ref> <manifest>"
exitWith $ ExitFailure 64
14 changes: 14 additions & 0 deletions _tools/restylers-docs/src/Restylers/Docs/Prelude.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- |
--
-- Module : Restylers.Docs.Prelude
-- Copyright : (c) 2025 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : [email protected]
-- Stability : experimental
-- Portability : POSIX
module Restylers.Docs.Prelude
( module X
) where

import Data.Text as X (Text, pack, unpack)
import Prelude as X
Loading

0 comments on commit c99bfc5

Please sign in to comment.