Permalink
Browse files

Add keywords field to package metadata

  • Loading branch information...
earlbread committed Sep 19, 2017
1 parent 42ef125 commit 9009ab39e2801353f8541075367239ac6bbb63e6
View
@@ -44,6 +44,7 @@ is an example:
version = "1.0.0" # (required)
description = "Short description on the package"
license = "MIT"
keywords = "sample example nirum"
[[authors]]
name = "John Doe" # (required)
@@ -61,6 +62,9 @@ It consists of the following fields (*emphasized fields* are required):
`license` (string)
: An optional license of the package.
`keywords` (string)
: An optional keywords of the package.
`authors` (array of tables)
: The list of authors. Note that it can be empty, but `name` field is
required if any author is provided. Each author table consists of
@@ -7,6 +7,7 @@ module Nirum.Package.Metadata ( Author (Author, email, name, uri)
, version
, description
, license
, packageKeywords
)
, MetadataError ( FieldError
, FieldTypeError
@@ -103,6 +104,7 @@ data Metadata t =
Metadata { version :: SV.Version
, description :: Maybe Text
, license :: Maybe Text
, packageKeywords :: Maybe Text
, authors :: [Author]
, target :: (Eq t, Ord t, Show t, Target t) => t
}
@@ -184,6 +186,7 @@ parseMetadata metadataPath' tomlText = do
authors' <- authorsField "authors" table
description' <- optional $ stringField "description" table
license' <- optional $ stringField "license" table
keywords' <- optional $ stringField "keywords" table
targets <- case tableField "targets" table of
Left (FieldError _) -> Right HM.empty
otherwise' -> otherwise'
@@ -198,6 +201,7 @@ parseMetadata metadataPath' tomlText = do
return Metadata { version = version'
, description = description'
, license = license'
, packageKeywords = keywords'
, authors = authors'
, target = target'
}
@@ -123,6 +123,7 @@ import Nirum.Package.Metadata ( Author (Author, name, email)
, version
, description
, license
, packageKeywords
)
, MetadataError ( FieldError
, FieldTypeError
@@ -1187,12 +1188,13 @@ SOURCE_ROOT = '{sourceDirectory Python3}'
if sys.version_info < (3, 0):
SOURCE_ROOT = '{sourceDirectory Python2}'
# TODO: long_description, url, keywords, classifiers
# TODO: long_description, url, classifiers
setup(
name='{pName}',
version='{pVersion}',
description=$pDescription,
license=$pLicense,
keywords=$pKeywords,
author=$author,
author_email=$authorEmail,
package_dir=\{'': SOURCE_ROOT},
@@ -1222,6 +1224,8 @@ setup(
pDescription = fromMaybeToMeta $ description metadata'
pLicense :: Code
pLicense = fromMaybeToMeta $ license metadata'
pKeywords :: Code
pKeywords = fromMaybeToMeta $ packageKeywords metadata'
strings :: [Code] -> Code
strings values = T.intercalate ", " $ map stringLiteral (L.sort values)
author :: Code
@@ -40,6 +40,7 @@ package = Package { metadata = Metadata { version = SV.version 0 0 1 [] []
, authors = []
, description = Nothing
, license = Nothing
, packageKeywords = Nothing
, target = DummyTarget
}
, modules = modules'
@@ -135,6 +135,13 @@ spec =
, "string"
, "integer (123)"
)
, ( [q|version = "1.2.3"
keywords = 789
|]
, "keywords"
, "string"
, "integer (789)"
)
] $ \ (toml, field, expected, actual) -> do
let Left e = parse toml
FieldTypeError field' expected' actual' = e
@@ -41,6 +41,7 @@ import Nirum.Package.Metadata ( Metadata ( Metadata
, version
, description
, license
, packageKeywords
)
, MetadataError (FormatError)
, Target (targetName)
@@ -64,6 +65,7 @@ createValidPackage t = createPackage Metadata { version = SV.initial
, authors = []
, description = Nothing
, license = Nothing
, packageKeywords = Nothing
, target = t
} validModules
@@ -113,6 +115,7 @@ testPackage target' = do
, authors = []
, description = Nothing
, license = Nothing
, packageKeywords = Nothing
, target = target'
}
metadata package `shouldBe` metadata'
@@ -42,7 +42,9 @@ import Nirum.Package.Metadata ( Author (Author, email, name, uri)
, target
, version
, description
, license)
, license
, packageKeywords
)
, Target (compilePackage)
)
import qualified Nirum.Package.ModuleSet as MS
@@ -102,6 +104,7 @@ makeDummySource' pathPrefix m renames =
]
, description = Just "Package description"
, license = Just "MIT"
, packageKeywords = Just "test example examples"
, target = Python "sample-package" minimumRuntime renames
}
pkg :: Package Python
@@ -1,6 +1,7 @@
version = "0.3.0"
description = "Package description"
license = "MIT"
keywords = "test example examples"
[[authors]]
name = "nirum"

0 comments on commit 9009ab3

Please sign in to comment.