Skip to content

Commit

Permalink
Add ability to document IRIs
Browse files Browse the repository at this point in the history
This patch introduces the ability to document IRIs generated from an
RDFS or OWL vocabulary.  It does not provide any documentation for
such IRIs, though, so there should be no change in the generated
documentation after applying this patch.
  • Loading branch information
pniedzielski committed Mar 20, 2024
1 parent 61bb2f6 commit e99f5c7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ vocabulary graph =
subject <- nub $ subjectOf <$> triplesOf graph
iri <- maybeToList $ toIRI subject
name <- maybeToList $ iriToName iri
return (name, declareIRI name iri)
return (name, declareIRI name iri Nothing)
(PrefixMappings prefixMappings') = prefixMappings graph
namespaceDecls = do
(prefix, iri) <- M.toList prefixMappings'
Expand All @@ -87,11 +87,13 @@ unodeFun = VarE $ mkName "Data.RDF.Types.unode"
mkPrefixedNSFun :: Exp
mkPrefixedNSFun = VarE $ mkName "Data.RDF.Namespace.mkPrefixedNS"

declareIRI :: Name -> Text -> Q Dec
declareIRI name iri =
declareIRI :: Name -> Text -> Maybe Text -> Q Dec
declareIRI name iri comment =
let iriLiteral = LitE . StringL $ T.unpack iri
unodeLiteral = AppE unodeFun $ AppE packFun iriLiteral
in funD name [return $ Clause [] (NormalB unodeLiteral) []]
in funD_doc name [return $ Clause [] (NormalB unodeLiteral) []]
(T.unpack <$> comment)
[Nothing]

declareIRIs :: [Name] -> Q Dec
declareIRIs names =
Expand Down

0 comments on commit e99f5c7

Please sign in to comment.