Skip to content

Commit 59aaf29

Browse files
authored
Haddock attributes of a module to determine the visibility (#20)
1 parent 2845a44 commit 59aaf29

File tree

9 files changed

+225
-84
lines changed

9 files changed

+225
-84
lines changed

.github/workflows/ci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches: ['main']
77

88
jobs:
9+
910
generate-matrix:
1011
name: 'Generate matrix from cabal'
1112
outputs:
@@ -184,6 +185,7 @@ jobs:
184185
done
185186
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
186187
echo "REPORT_NAME=report-${{ env.KERNEL }}-static-ghc-${{ matrix.ghc }}" >> $GITHUB_ENV
188+
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
187189
188190
- name: Test
189191
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/${REPORT_NAME}.xml" all

.github/workflows/release.yml

+22
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ jobs:
9393
if: success() || failure() # always run even if the previous step fails
9494
with:
9595
report_paths: "report.xml"
96+
cp ${bin} distribution/print-api
97+
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
98+
99+
- name: Test
100+
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report.xml" all
101+
102+
- name: Publish Test Report
103+
uses: mikepenz/action-junit-report@v4
104+
if: success() || failure() # always run even if the previous step fails
105+
with:
106+
report_paths: "report.xml"
96107

97108
- name: File type
98109
run: file distribution/*
@@ -180,6 +191,17 @@ jobs:
180191
if: success() || failure() # always run even if the previous step fails
181192
with:
182193
report_paths: "report.xml"
194+
cp ${bin} distribution/print-api
195+
echo "$GITHUB_WORKSPACE/distribution" >> "$GITHUB_PATH"
196+
197+
- name: Test
198+
run: cabal test --project-file=cabal.static.project --test-options "--xml=../print-api/report.xml" all
199+
200+
- name: Publish Test Report
201+
uses: mikepenz/action-junit-report@v4
202+
if: success() || failure() # always run even if the previous step fails
203+
with:
204+
report_paths: "report.xml"
183205

184206
- name: File type
185207
run: file distribution/*

app/print-api/Main.hs

+13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
{-# LANGUAGE CPP #-}
2+
13
module Main where
24

5+
import Data.ByteString.Lazy.Char8 qualified as ByteString
6+
import Data.List.Extra qualified as List
37
import Options.Applicative
8+
import PrintApi.Utils
49
import System.IO
510

11+
import PrintApi.CLI.Cmd.Dump (run)
612
import PrintApi.CLI.Types
713

814
main :: IO ()
915
main = do
1016
hSetBuffering stdout LineBuffering
1117
parseResult <- execParser (parseOptions `withInfo` "Export the declarations of a Haskell package")
1218
runOptions parseResult
19+
20+
runOptions
21+
:: Options
22+
-> IO ()
23+
runOptions (Options packageName mIgnoreList usePublicOnly) = do
24+
stdOut <- readCabalizedProcess (Just TOOL_VERSION_ghc) "ghc" ["--print-libdir"]
25+
run (List.trimEnd $ ByteString.unpack stdOut) mIgnoreList usePublicOnly packageName

cabal.project

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ tests: True
44

55
write-ghc-environment-files: always
66

7+
package print-api
8+
ghc-options: -haddock
9+
10+
documentation: True
11+
712
allow-newer:
813
tasty-test-reporter:mtl
914
, tasty-test-reporter:ansi-terminal

compat/9.8.2/GHC/Compat.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module GHC.Compat where
33

44
import GHC (ModuleInfo)
55
import GHC.Iface.Syntax (AltPpr (..), ShowForAllFlag (..), ShowHowMuch (..), ShowSub (..))
6-
import PrintApi.IgnoredDeclarations
6+
import PrintApi.IgnoredDeclarations ()
77

88
mkShowSub :: ModuleInfo -> ShowSub
99
mkShowSub _ =

print-api.cabal

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cabal-version: 2.4
22
name: print-api
3+
34
-- For the purpose of release and pre-release versioning, we use the following scheme:
45
-- EPOCH.MAJOR.MINOR.PATCH
56
-- with the MINOR member being even for releases and odd for pre-releases
@@ -54,12 +55,14 @@ common print-api-common
5455
-- main-is: Main.hs
5556
build-depends:
5657
, base
58+
, bytestring
59+
, extra
5760
, ghc
5861
, ghc-paths
5962
, optparse-applicative
6063
, print-api
6164

62-
default-language: Haskell2010
65+
default-language: GHC2021
6366

6467
library
6568
import: extensions
@@ -89,11 +92,13 @@ library
8992
build-depends:
9093
, base
9194
, bytestring
95+
, containers
9296
, extra
9397
, filepath
9498
, ghc
9599
, ghc-boot
96100
, ghc-paths
101+
, haddock-library
97102
, optparse-applicative
98103
, process
99104
, text

0 commit comments

Comments
 (0)