cabal2doap 0.1 → 0.2
raw patch · 2 files changed
+36/−7 lines, 2 filesdep ~base
Dependency ranges changed: base
Files
- cabal2doap.cabal +2/−2
- cabal2doap.hs +34/−5
cabal2doap.cabal view
@@ -1,5 +1,5 @@ Name: cabal2doap-Version: 0.1+Version: 0.2 License: BSD3 License-file: LICENSE Cabal-Version: >= 1.6@@ -21,5 +21,5 @@ location: http://gregheartsfield.com/repos/cabal2doap/ Executable cabal2doap- build-depends: base, hxt, Cabal >= 1.6, parsec, hsemail >= 1.1, process+ build-depends: base >= 3 && < 4, hxt, Cabal >= 1.6, parsec, hsemail >= 1.1, process main-is: cabal2doap.hs
cabal2doap.hs view
@@ -1,3 +1,16 @@+-----------------------------------------------------------------------------+-- |+-- Module : cabal2doap+-- Copyright : (c) Greg Heartsfield 2009+-- License : BSD3+--+-- Generate description-of-a-project (DOAP) files from cabal packages.+-- Usage: execute in the project root, RDF-XML is generated on standard+-- output. If the project is a darcs repository, commit records+-- will be scanned and used to publish developer information.+--+-----------------------------------------------------------------------------+ import Distribution.PackageDescription (PackageDescription,SourceRepo,RepoKind(RepoHead),RepoType(..),repoLocation,repoKind, repoType,package,homepage,synopsis,buildDepends,maintainer,licenseFile,@@ -52,6 +65,13 @@ programminglangQ = mkQName "doap" "programming-language" doap_ns repoRelQ = mkQName "doap" "repository" doap_ns repoQ = mkQName "doap" "Repository" doap_ns+darcsRepoQ = mkQName "doap" "DarcsRepository" doap_ns+gitRepoQ = mkQName "doap" "GitRepository" doap_ns+svnRepoQ = mkQName "doap" "SVNRepository" doap_ns+cvsRepoQ = mkQName "doap" "CVSRepository" doap_ns+hgRepoQ = mkQName "doap" "HgRepository" doap_ns+bzrRepoQ = mkQName "doap" "BazaarBranch" doap_ns+archRepoQ = mkQName "doap" "ArchRepository" doap_ns locationQ = mkQName "doap" "location" doap_ns -- FOAF QNames personQ = mkQName "foaf" "Person" foaf_ns@@ -117,18 +137,27 @@ UnknownLicense n -> Nothing -- Find a "HEAD" source repository, if one exists, and reference the location.--- Note: An active ticket on the DOAP Trac has a proposal for Darcs as--- a subclass of Repository. We should use that as soon as it becomes--- official.+-- This only finds the first HEAD repo. TODO: find and reference all repos. sourceRepoElement :: ArrowXml a => [SourceRepo] -> Maybe (a XmlTree XmlTree) sourceRepoElement repos = fmap (\r -> mkqelem repoRelQ [] [- mkqelem repoQ [] [+ mkqelem repoTypeQ [] [ mkqelem locationQ [sqattr rdfresQ r] [] ]]) source_repo where head_repos = filter (\r -> repoKind r == RepoHead) repos- source_repo = listToMaybe head_repos >>= repoLocation+ head_repo = listToMaybe head_repos+ source_repo = head_repo >>= repoLocation+ repo_type = head_repo >>= repoType+ repoTypeQ = case repo_type of+ Just Darcs -> darcsRepoQ+ Just Git -> gitRepoQ+ Just SVN -> svnRepoQ+ Just CVS -> cvsRepoQ+ Just Mercurial -> hgRepoQ+ Just GnuArch -> archRepoQ+ Just Bazaar -> bzrRepoQ+ _ -> repoQ developerElements :: ArrowXml a => [NameAddr] -> [a XmlTree XmlTree] developerElements = map (personElementFromAddr developerQ)