Skip to content

Commit

Permalink
Haddock attributes of a module to determine the visibility (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos authored Dec 6, 2024
1 parent 2845a44 commit 59aaf29
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 84 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches: ['main']

jobs:

generate-matrix:
name: 'Generate matrix from cabal'
outputs:
Expand Down Expand Up @@ -184,6 +185,7 @@ jobs:
done
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
echo "REPORT_NAME=report-${{ env.KERNEL }}-static-ghc-${{ matrix.ghc }}" >> $GITHUB_ENV
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
- name: Test
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/${REPORT_NAME}.xml" all
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ jobs:
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "report.xml"
cp ${bin} distribution/print-api
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"

- name: Test
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report.xml" all

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "report.xml"

- name: File type
run: file distribution/*
Expand Down Expand Up @@ -180,6 +191,17 @@ jobs:
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "report.xml"
cp ${bin} distribution/print-api
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"

- name: Test
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report.xml" all

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: "report.xml"

- name: File type
run: file distribution/*
Expand Down
13 changes: 13 additions & 0 deletions app/print-api/Main.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{-# LANGUAGE CPP #-}

module Main where

import Data.ByteString.Lazy.Char8 qualified as ByteString
import Data.List.Extra qualified as List
import Options.Applicative
import PrintApi.Utils
import System.IO

import PrintApi.CLI.Cmd.Dump (run)
import PrintApi.CLI.Types

main :: IO ()
main = do
hSetBuffering stdout LineBuffering
parseResult <- execParser (parseOptions `withInfo` "Export the declarations of a Haskell package")
runOptions parseResult

runOptions
:: Options
-> IO ()
runOptions (Options packageName mIgnoreList usePublicOnly) = do
stdOut <- readCabalizedProcess (Just TOOL_VERSION_ghc) "ghc" ["--print-libdir"]
run (List.trimEnd $ ByteString.unpack stdOut) mIgnoreList usePublicOnly packageName
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ tests: True

write-ghc-environment-files: always

package print-api
ghc-options: -haddock

documentation: True

allow-newer:
tasty-test-reporter:mtl
, tasty-test-reporter:ansi-terminal
Expand Down
2 changes: 1 addition & 1 deletion compat/9.8.2/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module GHC.Compat where

import GHC (ModuleInfo)
import GHC.Iface.Syntax (AltPpr (..), ShowForAllFlag (..), ShowHowMuch (..), ShowSub (..))
import PrintApi.IgnoredDeclarations
import PrintApi.IgnoredDeclarations ()

mkShowSub :: ModuleInfo -> ShowSub
mkShowSub _ =
Expand Down
7 changes: 6 additions & 1 deletion print-api.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cabal-version: 2.4
name: print-api

-- For the purpose of release and pre-release versioning, we use the following scheme:
-- EPOCH.MAJOR.MINOR.PATCH
-- with the MINOR member being even for releases and odd for pre-releases
Expand Down Expand Up @@ -54,12 +55,14 @@ common print-api-common
-- main-is: Main.hs
build-depends:
, base
, bytestring
, extra
, ghc
, ghc-paths
, optparse-applicative
, print-api

default-language: Haskell2010
default-language: GHC2021

library
import: extensions
Expand Down Expand Up @@ -89,11 +92,13 @@ library
build-depends:
, base
, bytestring
, containers
, extra
, filepath
, ghc
, ghc-boot
, ghc-paths
, haddock-library
, optparse-applicative
, process
, text
Expand Down
Loading

0 comments on commit 59aaf29

Please sign in to comment.