From 622c45d56e0ccb11e3b8b0832654cb30c8369ba8 Mon Sep 17 00:00:00 2001 From: Alec Theriault Date: Wed, 23 May 2018 02:29:05 -0700 Subject: Use `ClassOpSig` instead of `TypeSig` for class methods (#835) * Fix minimal pragma handling Class declarations contain 'ClassOpSig' not 'Typesig'. This should fix #834. * Accept html-test output --- haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 8 ++-- html-test/ref/Bug26.html | 14 +++---- html-test/ref/Bug613.html | 14 +++---- html-test/ref/Bug647.html | 8 ---- html-test/ref/Bug679.html | 8 ---- html-test/ref/DeprecatedClass.html | 28 +++++-------- html-test/ref/Hash.html | 16 ++++--- html-test/ref/Instances.html | 24 +++++++++++ html-test/ref/Minimal.html | 36 +++++++++++----- html-test/ref/Operators.html | 34 +++++++-------- html-test/ref/OrphanInstancesClass.html | 8 ---- html-test/ref/Test.html | 58 ++++++++++++-------------- html-test/ref/Ticket61.html | 8 ---- 13 files changed, 124 insertions(+), 140 deletions(-) diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs index d4f6db0e..819c9aa6 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs @@ -523,9 +523,9 @@ ppShortClassDecl summary links (ClassDecl { tcdCtxt = lctxt, tcdLName = lname, t -- ToDo: add associated type defaults - [ ppFunSig summary links loc doc names (hsSigWcType typ) + [ ppFunSig summary links loc doc names (hsSigType typ) [] splice unicode pkg qual - | L _ (TypeSig _ lnames typ) <- sigs + | L _ (ClassOpSig _ False lnames typ) <- sigs , let doc = lookupAnySubdoc (head names) subdocs names = map unLoc lnames ] -- FIXME: is taking just the first name ok? Is it possible that @@ -585,12 +585,12 @@ ppClassDecl summary links instances fixities loc d subdocs minimalBit = case [ s | MinimalSig _ _ (L _ s) <- sigs ] of -- Miminal complete definition = every shown method And xs : _ | sort [getName n | L _ (Var (L _ n)) <- xs] == - sort [getName n | TypeSig _ ns _ <- sigs, L _ n <- ns] + sort [getName n | ClassOpSig _ _ ns _ <- sigs, L _ n <- ns] -> noHtml -- Minimal complete definition = the only shown method Var (L _ n) : _ | [getName n] == - [getName n' | L _ (TypeSig _ ns _) <- lsigs, L _ n' <- ns] + [getName n' | L _ (ClassOpSig _ _ ns _) <- lsigs, L _ n' <- ns] -> noHtml -- Minimal complete definition = nothing diff --git a/html-test/ref/Bug26.html b/html-test/ref/Bug26.html index e50169ba..a363fef3 100644 --- a/html-test/ref/Bug26.html +++ b/html-test/ref/Bug26.html @@ -71,7 +71,11 @@ > a where
  • c_f :: a
  • Since: 1.0

    Minimal complete definition

    c_f

    Methods

    f where
  • fmap :: (a -> b) -> f a -> f b
  • #

    Minimal complete definition

    fmap

    Methods

    #

    Minimal complete definition

    f

    Methods

    #

    Minimal complete definition

    foo

    Methods

    a where
    • foo :: a -> a
    • a where
      • bar :: a -> a
      • some class

        Minimal complete definition

        foo

        Methods

        Deprecated: SomeOtherClass

        Minimal complete definition

        bar

        Methods

        a where
      • hash :: a -> Int
      • A class of types which can be hashed.

        Minimal complete definition

        hash

        Methods

        #

        Minimal complete definition

        Nothing

        Methods

        #

        Minimal complete definition

        Nothing

        Methods

        #

        Minimal complete definition

        Nothing

        Methods

        #

        Minimal complete definition

        Nothing

        Associated Types

        #

        Minimal complete definition

        (a, b, c | (d | e, (f | g)))

        Methods

        #

        Minimal complete definition

        aaa, bbb

        Methods

        #

        Minimal complete definition

        Nothing

        Methods

        a ><< b
      • (>><), (<<>) :: a -> b -> ()
      • (**>), (**<), (>**), (<**) :: a -> a -> ()
      • Class with fixity, including associated types

      • Minimal complete definition

        (>><), (<<>), (**>), (**<), (>**), (<**)

        Associated Types

        #

        Minimal complete definition

        aClass

        Methods

        a where
        • a :: IO a
        • b :: [a]
        • a where
          • d :: T a b
          • e :: (a, a)
          • a where
            • ff :: a
            • class)

            • Methods

              This is a class declaration with no separate docs for the methods

              Minimal complete definition

              d, e

              Methods

              #

              Minimal complete definition

              ff

              Methods

              #

              Minimal complete definition

              f

              Methods