diff --git a/README.md b/README.md index 297a317..c6f605d 100644 --- a/README.md +++ b/README.md @@ -11,26 +11,49 @@ Mermaid code blocks (```mermaid) will be rendered to SVG and embedded. ## Installation -### Build and install to PATH +### Prerequisites - cabal install --installdir=$HOME/.local/bin +First install the required system dependencies: + +```bash +./install-deps.sh +``` + +### Install Haskell toolchain + +Install ghcup (Haskell toolchain installer): + +```bash +curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh +source ~/.ghcup/env +``` + +Install specific GHC and Cabal versions: + +```bash +ghcup install ghc 9.12.2 +ghcup install cabal 3.16.0.0 +ghcup set ghc 9.12.2 +ghcup set cabal 3.16.0.0 +``` + +### Install Mermaid CLI + +```bash +npm install -g @mermaid-js/mermaid-cli +``` + +### Build and install docster + +```bash +cabal install --installdir=$HOME/.local/bin +``` Make sure `~/.local/bin` is in your PATH. Add to your shell config if needed: - export PATH="$HOME/.local/bin:$PATH" - -## Requirements - -- GHC + Cabal (via ghcup) -- Pandoc -- TeX Live (for PDF) -- Mermaid CLI (`npm install -g @mermaid-js/mermaid-cli`) - -### specific versions - -source ~/.ghcup/env && ghcup install ghc 9.12.2 -source ~/.ghcup/env && ghcup install cabal 3.16.0.0 -source ~/.ghcup/env && ghcup install hls 2.11.0.0 +```bash +export PATH="$HOME/.local/bin:$PATH" +``` ## Development diff --git a/docster.cabal b/docster.cabal index 8d0d20d..2207fe0 100644 --- a/docster.cabal +++ b/docster.cabal @@ -34,7 +34,7 @@ library Docster.Compiler hs-source-dirs: src build-depends: - base >=4.21 && <5, + base >=4.18 && <5, text >=2.0 && <2.2, filepath >=1.4 && <1.6, directory >=1.3 && <1.4, @@ -52,7 +52,7 @@ executable docster main-is: Main.hs hs-source-dirs: app build-depends: - base >=4.21 && <5, + base >=4.18 && <5, text >=2.0 && <2.2, docster default-language: Haskell2010 diff --git a/install-deps.sh b/install-deps.sh new file mode 100644 index 0000000..e3930c9 --- /dev/null +++ b/install-deps.sh @@ -0,0 +1,2 @@ +sudo apt update +sudo apt install -y build-essential libgmp-dev libffi-dev zlib1g-dev texlive-latex-base texlive-fonts-recommended texlive-latex-extra texlive-xetex diff --git a/puppeteer-config.json b/puppeteer-config.json new file mode 100644 index 0000000..411c0e7 --- /dev/null +++ b/puppeteer-config.json @@ -0,0 +1,3 @@ +{ + "args": ["--no-sandbox", "--disable-setuid-sandbox"] +} \ No newline at end of file diff --git a/src/Docster/Mermaid.hs b/src/Docster/Mermaid.hs index dc78720..22fb880 100644 --- a/src/Docster/Mermaid.hs +++ b/src/Docster/Mermaid.hs @@ -80,9 +80,10 @@ generateDiagramPaths (DiagramConfig (SourceDir sourceDir) format) (DiagramId dia -- | Call mermaid CLI process with appropriate arguments callMermaidProcess :: OutputFormat -> FilePath -> FilePath -> IO (Either DocsterError ()) callMermaidProcess format mmdFile outputFile = do - let args = case format of + let baseArgs = case format of HTML -> ["-i", mmdFile, "-o", outputFile] PDF -> ["-i", mmdFile, "-o", outputFile, "--scale", "3"] + args = baseArgs ++ ["--puppeteerConfigFile", "puppeteer-config.json"] result <- catch (callProcess (T.unpack mermaidCommand) args >> return (Right ()))