packages feed

haddocset 0.3.1 → 0.3.2

raw patch · 2 files changed

+26/−22 lines, 2 files

Files

Documentation/Haddocset.hs view
@@ -130,16 +130,24 @@   where     mapFunc tag         | Ts.tagOpenLit "a" (Ts.anyAttrNameLit "href") tag =-            let url    = Ts.fromAttrib "href" tag-                absp p = P.collapse $ docBaseDir doc P.</> P.fromText p+            let absp p = P.collapse $ docBaseDir doc P.</> P.fromText p                 attr   = filter (\(n,_) -> n /= "href") (getAttr tag)-            in case url of-                _ | "http://"  `T.isPrefixOf` url -> tag-                  | "https://" `T.isPrefixOf` url -> tag-                  | "file:///" `T.isPrefixOf` url -> Ts.TagOpen "a" (toAttr "href" (rebase . P.fromText $ T.drop 7 url) attr)-                  | otherwise                     -> Ts.TagOpen "a" (toAttr "href" (rebase . absp       $          url) attr)+            in case Ts.fromAttrib "href" tag of+                url | "http://"  `T.isPrefixOf` url -> tag+                    | "https://" `T.isPrefixOf` url -> tag+                    | "file:///" `T.isPrefixOf` url -> Ts.TagOpen "a" (toAttr "href" (rebase . P.fromText $ T.drop 7 url) attr)+                    | "#"        `T.isPrefixOf` url -> Ts.TagOpen "a" (toAttr "href" (rebase $ addHash url dst) attr)+                    | otherwise                     -> Ts.TagOpen "a" (toAttr "href" (rebase . absp       $          url) attr)+        | Ts.tagOpenLit "a" (Ts.anyAttrNameLit "name") tag =+            let Ts.TagOpen _ attr = tag+                hash = '#' `T.cons` Ts.fromAttrib "name" tag+            in Ts.TagOpen "a" (toAttr "href" (rebase $ addHash hash dst) attr)         | otherwise = tag +    addHash h file = P.dirname file P.</> case P.toText $ P.filename file of+        Right r -> P.fromText $ r `T.append` h+        Left  _ -> ""+     getAttr (TagOpen _ a) = a     getAttr _             = error "copyHtml: call attr to !TagOpen." @@ -148,14 +156,17 @@         Left  _ -> id      both a = case a of-        Left l -> l+        Left  l -> l         Right r -> r -    rebase p = let fil  = P.filename p-                   pkgs = filter packageLike . reverse $ P.splitDirectories (P.parent p)-               in case pkgs of-                   []    -> fil-                   pkg:_ -> relativize (P.decodeString . display . packageName $ docPackage doc) $ pkg P.</> fil+    rebase p =+        let file    = P.filename p+            isSrc   = "src" `elem` P.splitDirectories (P.parent p)+            srcNize = if isSrc then ("src" P.</>) else id+            pkgs    = filter packageLike . reverse $ P.splitDirectories (P.parent p)+        in case pkgs of+            []    -> file+            pkg:_ -> ".." P.</> pkg P.</> srcNize file      packageLike p = let t = both $ P.toText p                         in T.any (== '-') t && (T.all (`elem` "0123456789.") . T.takeWhile (/= '-') $ T.reverse t)@@ -166,13 +177,6 @@   loop f _  [] = f []   loop f (a:as) (b:bs) | a == b    = loop (f . (a:)) as bs                        | otherwise = f []--relativize :: P.FilePath -> P.FilePath -> P.FilePath-relativize base path = up P.</> p-    where pfx = commonPrefix base path-          up  = P.concat . flip replicate ".." . length . P.splitDirectories . fromMaybe err $ P.stripPrefix pfx base-          p   = fromMaybe err $ P.stripPrefix pfx path-          err = error $ "relativize: " ++ show base ++ " -> " ++ show path  data DocFile = DocFile     { docPackage     :: PackageId
haddocset.cabal view
@@ -1,5 +1,5 @@ name:                haddocset-version:             0.3.1+version:             0.3.2 synopsis:            Generate docset of Dash by Haddock haskell documentation tool description:         please read README.md <https://github.com/philopon/haddocset/blob/master/README.md> license:             BSD3@@ -8,7 +8,7 @@ maintainer:          HirotomoMoriwaki<philopon.dependence@gmail.com> Homepage:            https://github.com/philopon/haddocset Bug-reports:         https://github.com/philopon/haddocset/issues-copyright:           (c) 2014 Hirotomo Moriwaki+copyright:           (c) 2014-2015 Hirotomo Moriwaki category:            Distribution build-type:          Simple cabal-version:       >=1.10