Skip to content

Commit 3b99163

Browse files
committed
docs: Add documentation
1 parent 74f15dd commit 3b99163

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
11
# RDF Vocabulary
2+
3+
This library exposes utility functions and types to help working with RDF vocabulary terms.
4+
5+
```ts
6+
import { createVocabulary } from 'rdf-vocabulary';
7+
8+
// Creates a vocabulary.
9+
// The first parameter is the namespace, all the following parameters are terms in the namespace.
10+
const FOAF = createVocabulary(
11+
'http://xmlns.com/foaf/0.1/',
12+
'Agent',
13+
'knows',
14+
);
15+
16+
// Full term URIs are then accessible through the vocabulary object.
17+
assert.equal(FOAF.knows, 'http://xmlns.com/foaf/0.1/knows');
18+
19+
// Through the `terms` field, the URIs are exposed as a NamedNode
20+
assert.equal(FOAF.terms.knows.value, 'http://xmlns.com/foaf/0.1/knows');
21+
22+
// The namespace is accessible in the same way
23+
assert.equal(FOAF.namespace, 'http://xmlns.com/foaf/0.1/');
24+
assert.equal(FOAF.terms.namespace.value, 'http://xmlns.com/foaf/0.1/');
25+
26+
// New vocabularies can be created using existing vocabulary object
27+
const FOAF_EXTENDED = extendVocabulary(FOAF, 'name', 'made');
28+
assert.equal(FOAF_EXTENDED.name, 'http://xmlns.com/foaf/0.1/name');
29+
assert.equal(FOAF_EXTENDED.knows, 'http://xmlns.com/foaf/0.1/knows');
30+
31+
// There are several utility types
32+
const local: VocabularyLocal<typeof FOAF> = 'knows';
33+
const value: VocabularyValue<typeof FOAF> = 'http://xmlns.com/foaf/0.1/knows';
34+
const term: VocabularyTerm<typeof FOAF> = namedNode('http://xmlns.com/foaf/0.1/knows');
35+
```

eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ module.exports = opinionated({
44
typescript: {
55
tsconfigPath: [ './tsconfig.json', './test/tsconfig.json' ],
66
},
7+
ignores: [
8+
'*.md',
9+
],
710
});

0 commit comments

Comments
 (0)