Skip to content

Commit

Permalink
Improved RDF documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
karelklima committed Jan 7, 2024
1 parent c043fae commit a4a789d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion library/rdf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as RDF from "npm:[email protected]";
import type * as RDF from "npm:@rdfjs/types";

export type { RDF };

Expand Down
22 changes: 21 additions & 1 deletion rdf.ts
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
export * from "./library/rdf.ts";
/**
* RDF utilities
*
* This module contains a re-export of external RDF libraries that are used
* in LDkit and may be used in tandem with LDkit in Linked Data applications as well.
*
* Included packages:
* - [@rdfjs/types](https://github.com/rdfjs/types) [RDF/JS](https://rdf.js.org/) authoritative TypeScript typings
* - [n3](https://rdf.js.org/N3.js/) RDF parser and serializer
* - [rdf-data-factory](https://github.com/rubensworks/rdf-data-factory.js) A TypeScript/JavaScript implementation of the RDF/JS data factory
* - [rdf-literal](https://github.com/rubensworks/rdf-literal.js) Translates between RDF literals and JavaScript primitives
* @module
*/
export {
DataFactory,
DefaultGraph,
fromRdf,
N3,
type RDF,
toRdf,
} from "./library/rdf.ts";
10 changes: 3 additions & 7 deletions tests/rdf.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { assert, assertEquals } from "./test_deps.ts";

import {
BindingsFactory,
DataFactory,
QuadFactory,
type RDF,
type RDFJSON,
} from "ldkit/rdf";
import { DataFactory, type RDF } from "ldkit/rdf";

import { BindingsFactory, QuadFactory, RDFJSON } from "../library/rdf.ts";

Deno.test("RDF / Quad Factory", () => {
const df = new DataFactory();
Expand Down
7 changes: 7 additions & 0 deletions tests/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { DataFactory, N3, type RDF } from "ldkit/rdf";
import { ldkit, schema, xsd } from "ldkit/namespaces";
import { Options, type QueryContext } from "ldkit";

import { quadsToGraph } from "../library/rdf.ts";

export type Equals<A, B> = A extends B ? (B extends A ? true : false) : false;

const X_NAMESPACE = "http://x/";
Expand Down Expand Up @@ -79,6 +81,11 @@ export const ttl = (turtle: string) => {
return quads;
};

export const createGraph = (turtle: string) => {
const quads = ttl(turtle);
return quadsToGraph(quads);
};

export const createStore = () =>
new N3.Store(undefined, {
factory: DF(),
Expand Down
2 changes: 1 addition & 1 deletion www/doc.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const toApiPath = (url: URL) => {
};

const toRemoteSourceUrl = (target: string, line?: number) => {
const prefix = "https://deno.land/x/ldkit/";
const prefix = "https://deno.land/x/ldkit/library/";
const lineSuffix = line ? `#L${line}` : "";
const suffix = `?source=${lineSuffix}`;
const chunks = target.split("/library/");
Expand Down
2 changes: 1 addition & 1 deletion www/routes/api/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const handler: Handlers<Data> = {
const slug = ctx.params.slug;

const match = slug.match(
/^([a-zA-Z_\/.]+)?(~[a-zA-Z_]+)?(\.[a-zA-Z_.]+)?$/,
/^([a-zA-Z_\/.]+)?(~[a-zA-Z0-9_]+)?(\.[a-zA-Z_.]+)?$/,
);

if (match === null) {
Expand Down
5 changes: 3 additions & 2 deletions www/utils/doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { load as defaultLoad } from "https://deno.land/x/[email protected]/loade

export function load(specifier: string) {
if (specifier.startsWith("npm:")) {
return Promise.resolve({
specifier = `https://esm.sh/${specifier.slice(4)}`;
/*return Promise.resolve({
"kind": "external" as const,
"specifier": specifier,
});
});*/
}
return defaultLoad(specifier);
}

0 comments on commit a4a789d

Please sign in to comment.