[Git][ghc/ghc][wip/test] Drop compare-flags

Ben Gamari gitlab at gitlab.haskell.org
Wed Mar 18 22:09:34 UTC 2020



Ben Gamari pushed to branch wip/test at Glasgow Haskell Compiler / GHC


Commits:
8769077b by Ben Gamari at 2020-03-18T22:09:25Z
Drop compare-flags

- - - - -


2 changed files:

- − docs/users_guide/compare-flags.py
- hadrian/src/Rules/Documentation.hs


Changes:

=====================================
docs/users_guide/compare-flags.py deleted
=====================================
@@ -1,93 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-Linter to verify that all flags reported by GHC's --show-options mode
-are documented in the user's guide.
-"""
-
-import sys
-import subprocess
-from typing import Set
-from pathlib import Path
-
-# A list of known-undocumented flags. This should be considered to be a to-do
-# list of flags that need to be documented.
-EXPECTED_UNDOCUMENTED_PATH = \
-    Path(__file__).parent / 'expected-undocumented-flags.txt'
-
-EXPECTED_UNDOCUMENTED = \
-    {line for line in open(EXPECTED_UNDOCUMENTED_PATH).read().split()}
-
-def expected_undocumented(flag: str) -> bool:
-    if flag in EXPECTED_UNDOCUMENTED:
-        return True
-    if flag.startswith('-Werror'):
-        return True
-    if flag.startswith('-Wno-') \
-            or flag.startswith('-dno') \
-            or flag.startswith('-fno') \
-            or flag.startswith('-XNo'):
-        return True
-    if flag.startswith('-Wwarn=') \
-            or flag.startswith('-Wno-warn='):
-        return True
-
-    return False
-
-def read_documented_flags(doc_flags) -> Set[str]:
-    # Map characters that mark the end of a flag
-    # to whitespace.
-    trans = str.maketrans({
-        '=': ' ',
-        '[': ' ',
-        '⟨': ' ',
-    })
-    return {line.translate(trans).split()[0]
-            for line in doc_flags.read().split('\n')
-            if line != ''}
-
-def read_ghc_flags(ghc_path: str) -> Set[str]:
-    ghc_output = subprocess.check_output([ghc_path, '--show-options'])
-    return {flag
-            for flag in ghc_output.decode('UTF-8').split('\n')
-            if not expected_undocumented(flag)
-            if flag != ''}
-
-def error(s: str):
-    print(s, file=sys.stderr)
-
-def main() -> None:
-    import argparse
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--ghc', type=argparse.FileType('r'),
-                        help='path of GHC executable')
-    parser.add_argument('--doc-flags', type=argparse.FileType('r'),
-                        help='path of ghc-flags.txt output from Sphinx')
-    args = parser.parse_args()
-
-    doc_flags = read_documented_flags(args.doc_flags)
-    ghc_flags = read_ghc_flags(args.ghc.name)
-
-    failed = False
-
-    undocumented = ghc_flags - doc_flags
-    if len(undocumented) > 0:
-        error('Found {len_undoc} flags not documented in the users guide:'.format(len_undoc=len(undocumented)), )
-        error('\n'.join('  {}'.format(flag) for flag in sorted(undocumented)))
-        error('')
-        failed = True
-
-    now_documented = EXPECTED_UNDOCUMENTED.intersection(doc_flags)
-    if len(now_documented) > 0:
-        error('Found flags that are documented yet listed in {}:'.format(EXPECTED_UNDOCUMENTED_PATH))
-        error('\n'.join('  {}'.format(flag) for flag in sorted(now_documented)))
-        error('')
-        failed = True
-
-    if failed:
-        sys.exit(1)
-
-
-if __name__ == '__main__':
-    main()


=====================================
hadrian/src/Rules/Documentation.hs
=====================================
@@ -111,11 +111,6 @@ documentationRules = do
 
         need $ map (root -/-) targets
 
-        when (SphinxPDFs `Set.member` doctargets)
-          $ checkUserGuideFlags $ pdfRoot -/- "users_guide" -/- "ghc-flags.txt"
-        when (SphinxHTML `Set.member` doctargets)
-          $ checkUserGuideFlags $ root -/- htmlRoot -/- "users_guide" -/- "ghc-flags.txt"
-
     where archiveTarget "libraries"   = Haddocks
           archiveTarget _             = SphinxHTML
 
@@ -129,17 +124,6 @@ checkSphinxWarnings out = do
     when ("reference target not found" `isInfixOf` log)
       $ fail "Undefined reference targets found in Sphinx log."
 
--- | Check that all GHC flags are documented in the users guide.
-checkUserGuideFlags :: FilePath -> Action ()
-checkUserGuideFlags documentedFlagList = do
-    scriptPath <- (</> "docs/users_guide/compare-flags.py") <$> topDirectory
-    ghcPath <- (</>) <$> topDirectory <*> programPath (vanillaContext Stage1 ghc)
-    runBuilder Python
-      [ scriptPath
-      , "--doc-flags", documentedFlagList
-      , "--ghc", ghcPath
-      ] [documentedFlagList] []
-
 
 ------------------------------------- HTML -------------------------------------
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/8769077b67cae02e09583bf99168da0cb646a08c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/8769077b67cae02e09583bf99168da0cb646a08c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200318/286f804b/attachment-0001.html>


More information about the ghc-commits mailing list