Improved makefile, formatting
This commit is contained in:
parent
ad0dafa841
commit
9db8fd3957
5 changed files with 94 additions and 55 deletions
41
Makefile
41
Makefile
|
|
@ -1,9 +1,44 @@
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help: ## Show this help.
|
help: ## Show this help
|
||||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
||||||
.PHONY: format
|
.PHONY: build
|
||||||
format:
|
build: ## Build the project
|
||||||
|
cabal build
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: ## Run tests
|
||||||
|
cabal test --test-show-details=direct
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean: ## Clean build artifacts
|
||||||
|
cabal clean
|
||||||
|
|
||||||
|
.PHONY: fourmolu
|
||||||
|
fourmolu: ## Format Haskell code
|
||||||
find . -type f -name "*.hs" ! -path "./dist-newstyle/*" -exec fourmolu -i {} +
|
find . -type f -name "*.hs" ! -path "./dist-newstyle/*" -exec fourmolu -i {} +
|
||||||
|
|
||||||
|
.PHONY: fourmolu-check
|
||||||
|
fourmolu-check: ## Check if code is formatted
|
||||||
|
find . -type f -name "*.hs" ! -path "./dist-newstyle/*" -exec fourmolu --mode check {} \;
|
||||||
|
|
||||||
|
.PHONY: lint
|
||||||
|
lint: ## Run hlint
|
||||||
|
hlint src test app
|
||||||
|
|
||||||
|
.PHONY: cabal-gild
|
||||||
|
cabal-gild: ## Format cabal file
|
||||||
cabal-gild --io=haddock2.cabal
|
cabal-gild --io=haddock2.cabal
|
||||||
|
|
||||||
|
.PHONY: format
|
||||||
|
format: fourmolu cabal-gild ## Run all formatters
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check: fourmolu-check lint ## Run all checks (CI-style)
|
||||||
|
|
||||||
|
.PHONY: ci
|
||||||
|
ci: build test check ## Run full CI pipeline locally
|
||||||
|
|
||||||
|
.PHONY: docs
|
||||||
|
docs: ## Generate documentation
|
||||||
|
cabal haddock --haddock-hyperlink-source
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ located :: Parser a -> Parser (SourcePos, a)
|
||||||
located p = (,) <$> getPosition <*> p
|
located p = (,) <$> getPosition <*> p
|
||||||
|
|
||||||
tokenise :: [Parser a] -> Parser [(SourcePos, a)]
|
tokenise :: [Parser a] -> Parser [(SourcePos, a)]
|
||||||
tokenise = sequence . map located
|
tokenise = mapM located
|
||||||
|
|
||||||
lexer :: String -> Either ParseError [LocatedToken]
|
lexer :: String -> Either ParseError [LocatedToken]
|
||||||
lexer = Parsec.runParser lexText initialParserState "input" . Text.pack
|
lexer = Parsec.runParser lexText initialParserState "input" . Text.pack
|
||||||
|
|
@ -146,7 +146,7 @@ delimitedNoTrailing openP closeP openTok = asList <$> delimitedAsTuple (openTok
|
||||||
asList (a, tok, _) = [a, tok]
|
asList (a, tok, _) = [a, tok]
|
||||||
|
|
||||||
delimitedSymmetric :: Parser a -> Token -> Token -> Parser [LocatedToken]
|
delimitedSymmetric :: Parser a -> Token -> Token -> Parser [LocatedToken]
|
||||||
delimitedSymmetric s t1 t2 = delimited s s t1 t2
|
delimitedSymmetric s = delimited s s
|
||||||
|
|
||||||
eol :: Parser ()
|
eol :: Parser ()
|
||||||
eol = void "\n" <|> void "\r\n" <|> Parsec.eof
|
eol = void "\n" <|> void "\r\n" <|> Parsec.eof
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ import Text.Parsec.Pos (updatePosChar)
|
||||||
Return everything consumed except for the end pattern itself.
|
Return everything consumed except for the end pattern itself.
|
||||||
-}
|
-}
|
||||||
takeUntil :: Text -> Parser Text
|
takeUntil :: Text -> Parser Text
|
||||||
takeUntil end_ = Text.dropEnd (Text.length end_) <$> requireEnd (scan p (False, end)) >>= gotSome
|
takeUntil end_ =
|
||||||
|
requireEnd (scan p (False, end))
|
||||||
|
>>= gotSome . Text.dropEnd (Text.length end_)
|
||||||
where
|
where
|
||||||
end = Text.unpack end_
|
end = Text.unpack end_
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ module Types (
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
import Data.Foldable (fold)
|
||||||
|
|
||||||
newtype Document = Document
|
newtype Document = Document
|
||||||
{ meta :: Meta
|
{ meta :: Meta
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +30,7 @@ data Since = Since
|
||||||
|
|
||||||
-- Could have a better type?
|
-- Could have a better type?
|
||||||
type Version = [Int]
|
type Version = [Int]
|
||||||
|
|
||||||
type Package = String
|
type Package = String
|
||||||
|
|
||||||
data DocMarkup mod id
|
data DocMarkup mod id
|
||||||
|
|
@ -136,7 +139,7 @@ instance Semigroup (DocMarkup mod id) where
|
||||||
|
|
||||||
instance Monoid (DocMarkup mod id) where
|
instance Monoid (DocMarkup mod id) where
|
||||||
mempty = DocEmpty
|
mempty = DocEmpty
|
||||||
mconcat = foldr (<>) mempty
|
mconcat = fold
|
||||||
|
|
||||||
data ModuleLink id = ModuleLink
|
data ModuleLink id = ModuleLink
|
||||||
{ name :: String
|
{ name :: String
|
||||||
|
|
|
||||||
17
test/Spec.hs
17
test/Spec.hs
|
|
@ -1,17 +1,15 @@
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
|
|
||||||
import Test.Hspec
|
|
||||||
|
|
||||||
import Identifier (Identifier)
|
|
||||||
import Lexer
|
|
||||||
import Parser
|
|
||||||
import Types
|
|
||||||
|
|
||||||
import Data.String (IsString (..))
|
import Data.String (IsString (..))
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
|
import Identifier (Identifier)
|
||||||
|
import Lexer
|
||||||
|
import Parser
|
||||||
|
import Test.Hspec
|
||||||
import Text.Parsec.Pos
|
import Text.Parsec.Pos
|
||||||
|
import Types
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspec $ do
|
main = hspec $ do
|
||||||
|
|
@ -34,9 +32,9 @@ main = hspec $ do
|
||||||
|
|
||||||
describe "Parser" do
|
describe "Parser" do
|
||||||
it "Bold" do
|
it "Bold" do
|
||||||
"__bold__" `shouldParseTo` (DocBold (DocString "bold"))
|
"__bold__" `shouldParseTo` DocBold (DocString "bold")
|
||||||
it "Emphasis" do
|
it "Emphasis" do
|
||||||
"/emphasis/" `shouldParseTo` (DocEmphasis (DocString "emphasis"))
|
"/emphasis/" `shouldParseTo` DocEmphasis (DocString "emphasis")
|
||||||
|
|
||||||
------------
|
------------
|
||||||
-- Tests
|
-- Tests
|
||||||
|
|
@ -57,6 +55,7 @@ modules = do
|
||||||
`shouldLexTo` [ (1, 2, Module "OtherModule.Name")
|
`shouldLexTo` [ (1, 2, Module "OtherModule.Name")
|
||||||
, (1, 18, Anchor "myAnchor")
|
, (1, 18, Anchor "myAnchor")
|
||||||
]
|
]
|
||||||
|
|
||||||
link :: Expectation
|
link :: Expectation
|
||||||
link =
|
link =
|
||||||
"[link to](http://some.website)"
|
"[link to](http://some.website)"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue