Skip to content

Commit

Permalink
docs: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jun 9, 2021
1 parent e9faf40 commit 6987508
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
48 changes: 15 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
# @zazuko/build-your-vocabularies
# @hydrofoil/vocabularies

Roll your own vocabularies package which will export your ontologies/vocabularies as n-quads and code modules.
Collection of vocabularies from the `https://hypermedia.app/` namespace

## Preparation
## Usage

Having created a repository from this template, follow the instructions below to create a package with your vocabularies.
### Builders

1. Adjust `package.json`, at the least by:
* changing the name
* changing the `bin` name
* changing the `indexBase` in `fetch` script
* possibly remove `private: true`
2. Prepare your vocabularies:
* add their prefix/namespace pairs in [src/prefixes.ts](src/prefixes.ts)
* if necessary, set up their fetch routine in [`build/overrides.ts`](build/overrides.ts)
* see [here](https://github.com/zazuko/rdf-vocabularies/blob/master/overrides.ts) for examples of various overrides
* local vocabularies can be created in [src/vocabulary](src/vocabulary) as RDF sources
3. `npm run fetch`
* optionally call as `npm run fetch -- <prefix>` to fetch+process only one
4. Customise this readme
4. Commit the result
5. Bump version and publish your package
* Might consider setting CI automation
Easily construct terms using exported namespace builders

Check the `example` branch for inspiration
```typescript
import { knossos } from '@hydrofoil/vocabularies/builders'

## Usage
const { memberTemplate } = knossos
```

The final product will be an extension to the `@zazuko/rdf-vocabularies`, albeit with side effects. Simply import in your project the to have you prefixes added to the default selection.
### Extend `@zazuko/rdf-vocabularies`

Import somewhere at the beginning of your code

```javascript
// replace with your package name
import '@zazuko/build-your-vocabularies'
import '@hydrofoil/vocabularies'
```

Additionally, modules exporting `@rdfjs/namespace` builders will be generated.
The namespaces will be added to the default selection and thus apply to the `expand/shrink` functionality as well as external libraries such as `@tpluscode/rdf-string`.

```javascript
// default builders
import { prefixA } from '@zazuko/build-your-vocabularies/builders'

// strict builders prevent constructing terms which are not defined in vocabulary
import { prefixB } from '@zazuko/build-your-vocabularies/builders/strict'
import { prefixes } from '@zazuko/rdf-vocabularies'
```

Check [`@zazuko/rdf-vocabularies` readme](https://github.com/zazuko/rdf-vocabularies#usage) for detailed usage instructions.
12 changes: 11 additions & 1 deletion src/prefixes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
export default {
const prefixes = {
'hyper-auth': 'https://hypermedia.app/auth#',
'hyper-events': 'https://hypermedia.app/events#',
'hyper-query': 'https://hypermedia.app/query#',
knossos: 'https://hypermedia.app/knossos#',
roadshow: 'https://hypermedia.app/roadshow#'
}

type LocalPrefixes = typeof prefixes

declare module '@zazuko/rdf-vocabularies/prefixes' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Prefixes extends LocalPrefixes {
}
}

export default prefixes

0 comments on commit 6987508

Please sign in to comment.