Skip to content

Commit

Permalink
Merge pull request #9573 from cabalism/fix/gen-buildinfo-9186
Browse files Browse the repository at this point in the history
Generate doc/buildinfo-fields-reference.rst
  • Loading branch information
mergify[bot] authored Jan 1, 2024
2 parents fe705cf + 5f1c443 commit 12223d7
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 69 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/quick-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,36 @@ jobs:
run: make doctest-install
- name: Doctest
run: make doctest
buildinfo:
name: Check Field Syntax Reference
runs-on: ubuntu-latest
steps:
- name: Set PATH
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
- uses: actions/cache@v3
with:
path: ~/.cabal/store
key: linux-store-buildinfo-doc-diff
# See https://github.com/haskell/cabal/pull/8739
- name: Sudo chmod to permit ghcup to update its cache
run: |
if [[ "${{ runner.os }}" == "Linux" ]]; then
sudo ls -lah /usr/local/.ghcup/cache
sudo mkdir -p /usr/local/.ghcup/cache
sudo ls -lah /usr/local/.ghcup/cache
sudo chown -R $USER /usr/local/.ghcup
sudo chmod -R 777 /usr/local/.ghcup
fi
- name: ghcup
run: |
ghcup --version
ghcup config set cache true
ghcup install ghc --set recommended
ghcup install cabal --set latest
- name: Update Hackage index
run: cabal v2-update
- uses: actions/checkout@v4
- name: Are buildinfo docs up to date?
run: make doc/buildinfo-fields-reference.rst

17 changes: 16 additions & 1 deletion Cabal-described/src/Distribution/Described.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.Described (
Expand Down Expand Up @@ -65,6 +66,7 @@ import Distribution.Utils.GrammarRegex
-- Types
import Distribution.Compat.Newtype
import Distribution.Compiler (CompilerFlavor, CompilerId, knownCompilerFlavors)
import Distribution.PackageDescription.FieldGrammar (CompatFilePath, CompatLicenseFile)
import Distribution.FieldGrammar.Newtypes
import Distribution.ModuleName (ModuleName)
import Distribution.System (Arch, OS, knownArches, knownOSs)
Expand Down Expand Up @@ -95,6 +97,7 @@ import Distribution.Types.SourceRepo (RepoType)
import Distribution.Types.TestType (TestType)
import Distribution.Types.UnitId (UnitId)
import Distribution.Types.UnqualComponentName (UnqualComponentName)
import Distribution.Utils.Path (LicenseFile, PackageDir, SourceDir, SymbolicPath)
import Distribution.Verbosity (Verbosity)
import Distribution.Version (Version, VersionRange)
import Language.Haskell.Extension (Extension, Language)
Expand Down Expand Up @@ -419,7 +422,7 @@ instance Described IncludeRenaming where
mr = describe (Proxy :: Proxy ModuleRenaming)

instance Described Language where
describe _ = REUnion ["Haskell98", "Haskell2010"]
describe _ = REUnion ["GHC2021", "Haskell2010", "Haskell98"]

instance Described LegacyExeDependency where
describe _ = RETodo
Expand Down Expand Up @@ -575,3 +578,15 @@ instance Described TestedWith where

instance Described FilePathNT where
describe _ = describe ([] :: [Token])

instance Described (SymbolicPath PackageDir SourceDir) where
describe _ = describe ([] :: [Token])

instance Described (SymbolicPath PackageDir LicenseFile) where
describe _ = describe ([] :: [Token])

instance Described CompatLicenseFile where
describe _ = describe ([] :: [Token])

instance Described CompatFilePath where
describe _ = describe ([] :: [Token])
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPat
cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-paths-module -- $< $@

# generated docs

buildinfo-fields-reference : phony
cabal build --builddir=dist-newstyle-bi --project-file=cabal.project.buildinfo buildinfo-reference-generator
$$(cabal list-bin --builddir=dist-newstyle-bi buildinfo-reference-generator) buildinfo-reference-generator/template.zinza | tee $@
# Use cabal build before cabal run to avoid output of the build on stdout when running
doc/buildinfo-fields-reference.rst : \
$(wildcard Cabal-syntax/src/*/*.hs Cabal-syntax/src/*/*/*.hs Cabal-syntax/src/*/*/*/*.hs) \
$(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
buildinfo-reference-generator/src/Main.hs \
buildinfo-reference-generator/template.zinza
cabal build --project-file=cabal.project.buildinfo buildinfo-reference-generator
cabal run --project-file=cabal.project.buildinfo buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
git diff --exit-code $@

# analyse-imports
analyse-imports : phony
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ executable buildinfo-reference-generator
ghc-options: -Wall
main-is: Main.hs
build-depends:
, base ^>=4.12 || ^>=4.13
, base >=4.11 && <4.20
, Cabal
, Cabal-described
, containers
Expand Down
2 changes: 1 addition & 1 deletion buildinfo-reference-generator/template.zinza
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Build info fields
{# We show documentation link only for non deprecated fields #}
{% if null field.deprecatedSince.fst %}
{% if null field.removedIn.fst %}
* Documentation of :pkg-field:`{{field.name}}`
* Documentation of :pkg-field:`library:{{field.name}}`
{% endif %}
{% endif %}
{% if notNull field.syntax %}
Expand Down
1 change: 0 additions & 1 deletion cabal.project.buildinfo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ packages: Cabal-described
packages: buildinfo-reference-generator/
tests: False
optimization: False
with-compiler: ghc-8.8.3

-- avoiding extra dependencies
constraints: rere -rere-cfg
Expand Down
Loading

0 comments on commit 12223d7

Please sign in to comment.