packages feed

haskdogs (empty) → 0.1

raw patch · 5 files changed

+172/−0 lines, 5 filesdep +Cabaldep +HSHdep +basesetup-changed

Dependencies added: Cabal, HSH, base, filepath

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2011, Sergey Mironov++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Sergey Mironov nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README view
@@ -0,0 +1,38 @@+INFO+====++haskdogs is a small shellscript-like tool which creates tag file for entire+haskell project directory. It takes into account first-level dependencies by+recursively scanning imports and adding matching packages to the final+tag list.++As a result, programmer can use his/her text editor supporting tags (vim, for+example) to jump directly to definition of any standard or foreign function+he/she uses.++Note, that haskdogs calls some Unix shell commands like 'test' or 'mkdir'+so this tool will run, but probably fail to work on pure Windows platforms.++INSTALL+=======++0. cabal install hasktags+1. git clone https://github.com/ierton/haskdogs+2. cd haskdogs+3. cabal install+4. export PATH="$HOME/.cabal/bin:$PATH"++RUNNING+=======++1. Make sure yoy have installed hasktags and put it in PATH. Hasktags is being+called by haskdogs by name.  +2. Make shure that $HOME/.cabal/var/haskdogs does exist.+3. cd to your Haskell project dir+4. run haskdogs++--+Sergey +<ierton@gmail.com>++
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ haskdogs.cabal view
@@ -0,0 +1,40 @@+-- haskdogs.cabal auto-generated by cabal init. For additional+-- options, see+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.+-- The name of the package.+Name:                haskdogs+Version:             0.1+Synopsis:            Generate ctags file for haskell project directory and it's deps+Homepage:            http://github.com/ierton/haskdogs+License:             BSD3+License-file:        LICENSE+Author:              Sergey Mironov+Maintainer:          ierton@gmail.com+Category:            Development+Build-type:          Simple+Cabal-version:       >=1.6+extra-source-files:  README+Description:+    haskdogs is a small shellscript-like tool which creates tag file for entire+    haskell project directory. It takes into account first-level dependencies by+    recursively scanning imports and adding matching packages to the final+    tag list.++    As a result, programmer can use his/her text editor supporting tags (vim, for+    example) to jump directly to definition of any standard or foreign function+    he/she uses.++    Note, that haskdogs calls some Unix shell commands like 'test' or 'mkdir'+    so this tool will likely fail to work on pure Windows platforms.++Executable haskdogs+  Hs-source-dirs:       src+  Main-is:              haskdogs.hs+  Build-depends:        base >= 3 && < 5, Cabal >= 1.6, HSH >= 2.0.3, filepath >= 1.1.0.3+  Ghc-options:          -fwarn-tabs -Wall+  Build-tools:          hasktags+  +Source-repository head+  Type:     git+  Location: http://github.com/ierton/haskdogs+
+ src/haskdogs.hs view
@@ -0,0 +1,62 @@+-- #!/usr/bin/runhaskell++import HSH+import Data.List+import Control.Monad+import System.Exit+import System.FilePath++p :: String -> (String, [String])+p s = let ws = words s in (head ws, tail ws)++find_in_dirs dirs p = ("find", dirs ++ ["-name", p])++ghc_pkg_find m = ("ghc-pkg", ["find-module", m])++cabal_unpack p = ("cabal", ["unpack", p])++findSources :: [String] -> IO [String]+findSources d = run $ find_in_dirs d "*hs"++findImports :: [String] -> IO [String]+findImports s = run $ catFrom s -|- extractImports++extractImports = nub . sort . filter (/=[]) . map (grepImports . words)++grepImports ("import":"qualified":x:_) = x+grepImports ("import":x:_) = x+grepImports _ = []++iname2module :: String -> IO String+iname2module m = run $ ghc_pkg_find m -|- egrep "^ +[a-zA-Z]" -|- map (head . words) -|- highver+    where highver [] = []+          highver s = last (lines s)++inames2modules :: [String] -> IO [String]+inames2modules is = forM is (iname2module) >>= return . nub . sort . filter (/=[])++unpackModule p = do+    srcdir <- glob "~" >>= return . (</> ".cabal/var/haskdogs/") . head+    let fullpath = srcdir </> p+    ret <- run ("test",["-d", fullpath])+    case ret of+        ExitSuccess -> do+            putStrLn $ "Already unpacked " ++ p+            return fullpath+        _ -> do+            cd srcdir+            ec <- tryEC (runIO (cabal_unpack p))+            case ec of+                Left _ -> return []+                Right _ -> return fullpath++unpackModules ms = mapM unpackModule ms >>= return . filter (/=[])++main = do+    cwd <- run "pwd" >>= return . head+    ss_local <- findSources ["."]+    ss_l1deps <- findImports ss_local >>= inames2modules >>= unpackModules >>= findSources+    cd cwd+    runIO $ ("hasktags", ["-c"] ++ ss_local ++ ss_l1deps)++