Skip to content

Commit 499f3c1

Browse files
committed
Add default values for parameters
1 parent 998840c commit 499f3c1

File tree

2 files changed

+142
-97
lines changed

2 files changed

+142
-97
lines changed
Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,62 @@
11
---
2-
import { type formats as formatsType, type Format, supportsDirection,type Direction } from '@lib/formats';
3-
import { Tabs, TabItem } from '@astrojs/starlight/components';
4-
import {type Type} from '@lib/parameters';
2+
import {
3+
type formats as formatsType,
4+
type Format,
5+
supportsDirection,
6+
type Direction,
7+
} from "@lib/formats";
8+
import { Tabs, TabItem } from "@astrojs/starlight/components";
9+
import { type Type } from "@lib/parameters";
510
611
interface Props {
712
formats: typeof formatsType;
813
direction: Direction;
914
}
1015
1116
const { formats, direction } = Astro.props;
12-
---
17+
---
1318

1419
<Tabs>
15-
{
16-
(Object.entries(formats) as [keyof typeof formats, Format][]).map(([_key, format]) => {
17-
18-
// Specify the styling of each parameter
19-
return (
20-
<TabItem label={format.name}>
21-
<table>
22-
<tbody>
23-
{supportsDirection(format,direction) && format.parameters.map((param) => (
24-
<tr>
25-
<td class="parameter-item text-sm leading-relaxed">
26-
<u><code>{param.name}</code></u><br />
27-
<span set:html={param.description}></span><br />
28-
<span>Accepted type(s): {param.types.map((type: Type) => type.description).join(', ') }</span><br />
29-
{param.example ? <span> Example: <code>{param.example}</code></span> : null}
30-
</td>
31-
</tr>
32-
))}
33-
</tbody>
34-
</table>
35-
</TabItem>
36-
);
37-
})
20+
{
21+
(Object.entries(formats) as [keyof typeof formats, Format][]).map(
22+
([_key, format]) => (
23+
<TabItem label={format.name}>
24+
<table>
25+
<tbody>
26+
{supportsDirection(format, direction) &&
27+
format.parameters.map((param) => (
28+
<tr>
29+
<td class="parameter-item text-sm leading-relaxed">
30+
<u>
31+
<code>{param.name}</code>
32+
</u>
33+
<br />
34+
<span set:html={param.description} />
35+
<br />
36+
<span>
37+
Accepted type(s):{" "}
38+
{param.types
39+
.map((type: Type) => type.description)
40+
.join(", ")}
41+
</span>
42+
<br />
43+
{param.default ? (
44+
<span>
45+
Default value: <code>{param.default}</code>
46+
</span>
47+
) : null}
48+
{param.example ? (
49+
<span>
50+
Example: <code>{param.example}</code>
51+
</span>
52+
) : null}
53+
</td>
54+
</tr>
55+
))}
56+
</tbody>
57+
</table>
58+
</TabItem>
59+
),
60+
)
3861
}
39-
</Tabs>
40-
62+
</Tabs>

src/lib/parameters.tsx

Lines changed: 91 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,132 @@
1-
21
export interface Type {
3-
description: string
2+
description: string;
43
}
54

65
export interface Parameter {
7-
name: string,
8-
types: Type[],
9-
description: string,
10-
example?: string,
6+
name: string;
7+
types: Type[];
8+
description: string;
9+
example?: string;
10+
default?: string;
1111
}
12-
const IRI: Type = {description: 'IRI'};
13-
const String: Type = {description: 'String'};
14-
const Integer: Type = {description: 'Unsigned integer'};
15-
const Boolean: Type = {description: 'Boolean'};
16-
const Char: Type = {description: 'Character'};
17-
const Tuple: Type = {description: 'Tuple of Nemo type names'};
18-
const Value: Type = {description: 'Nemo type name'};
19-
const HeaderMap: Type = {description: 'Map with key-value pairs that can be of type: String, Constant or Number'};
20-
const ParamMap: Type = {description: 'Map where each key is of type String, Constant or Number and each value is a (possibly unary) tuple containing Strings, Numbers and Constants.'};
12+
const IRI: Type = { description: "IRI" };
13+
const String: Type = { description: "String" };
14+
const Integer: Type = { description: "Unsigned integer" };
15+
const Boolean: Type = { description: "Boolean" };
16+
const Char: Type = { description: "Character" };
17+
const Tuple: Type = { description: "Tuple of Nemo type names" };
18+
const Value: Type = { description: "Nemo type name" };
19+
const HeaderMap: Type = {
20+
description:
21+
"Map with key-value pairs that can be of type: String, Constant or Number",
22+
};
23+
const ParamMap: Type = {
24+
description:
25+
"Map where each key is of type String, Constant or Number and each value is a (possibly unary) tuple containing Strings, Numbers and Constants.",
26+
};
2127

22-
export const resource: Parameter = {
23-
name: 'resource',
24-
types: [IRI, String],
25-
description: `The file name to write to.
28+
export const resource: Parameter = {
29+
name: "resource",
30+
types: [IRI, String],
31+
description: `The file name to write to.
2632
If it contains an extension, this is used to automatically set the <code>compression</code> parameter.
2733
If set to the empty string <code>\"\"</code>, the tuples are read from <code>stdin</code>.
2834
This is restricted to one <code>stdin</code> resource per program. If omitted, this is set based on the predicate name,
29-
file format and compression type <code>&lt;predicate-name&gt;.&lt;format&gt;.&lt;compression&gt;</code>.`
35+
file format and compression type <code>&lt;predicate-name&gt;.&lt;format&gt;.&lt;compression&gt;</code>.`,
3036
};
3137

32-
export const format: Parameter = {
33-
name: 'format',
34-
types: [Tuple, Value],
35-
description: `The input-format of the imported data.
36-
Might be <code>int</code>, <code>double</code>, <code>string</code>, <code>rdf</code> or <code>skip</code>.`
38+
export const format: Parameter = {
39+
name: "format",
40+
types: [Tuple, Value],
41+
description: `The input-format of the imported data.
42+
Can be <code>int</code>, <code>double</code>, <code>string</code>, <code>rdf</code> or <code>skip</code>.`,
3743
};
3844

39-
export const compression: Parameter = {
40-
name: 'compression',
41-
types: [String],
45+
export const compression: Parameter = {
46+
name: "compression",
47+
types: [String],
4248
description: `The compression to use. Currently only <code>gzip</code> or <code>none</code> is supported. '
4349
This will normally be guessed correctly from the file extension,
44-
but can be useful for non-standard file names or URLs.`
45-
};
46-
47-
export const limit: Parameter = {
48-
name: 'limit',
49-
types: [Integer],
50-
description: 'The maximum number of tuples to import. (great for testing when working with large files) '
50+
but can be useful for non-standard file names or URLs.`,
51+
};
52+
53+
export const limit: Parameter = {
54+
name: "limit",
55+
types: [Integer],
56+
description:
57+
"The maximum number of tuples to import (great for testing when working with large files).",
58+
};
59+
60+
export const delimiter: Parameter = {
61+
name: "delimiter",
62+
types: [Char],
63+
description: "The delimiter to use.",
5164
};
5265

53-
export const delimiter: Parameter = {
54-
name: 'delimiter',
55-
types: [Char],
56-
description: 'The delimiter to use. '
66+
export const ignore_headers: Parameter = {
67+
name: "ignore_headers",
68+
types: [Boolean],
69+
description:
70+
"if <code>true</code>, the first record (containing the column headers) is ignored.",
71+
default: "false",
5772
};
5873

59-
export const ignore_headers: Parameter = {
60-
name: 'ignore_headers',
61-
types: [Boolean],
62-
description: 'if <code>true</code>, the first record (containing the column headers) is ignored '
74+
export const quoting: Parameter = {
75+
name: "quoting",
76+
types: [Boolean],
77+
description:
78+
'if <code>true</code> (the default), quotation marks <code>"</code> in the input are interpreted. This allows, e.g., reading values containing the delimiter. Cannot currently be disabled for writing.',
79+
default: "true",
6380
};
6481

6582
export const http_headers: Parameter = {
66-
name: 'http_headers',
67-
types: [HeaderMap],
68-
description: 'Each pair is added as HTTP headers when making an HTTP request ',
69-
example: 'http_headers=(\"Accept-Language\"=\"en-US\",\"Accept-Charset\=\"utf-8\")'
83+
name: "http_headers",
84+
types: [HeaderMap],
85+
description: "Each pair is added as HTTP headers when making an HTTP request",
86+
example: 'http_headers=("Accept-Language"="en-US","Accept-Charset="utf-8")',
7087
};
7188

7289
export const http_get_parameters: Parameter = {
73-
name: 'http_get_parameters',
74-
types: [ParamMap],
75-
description: 'The map will be flattened into pairs that are appended to the IRI before making an HTTP request ',
76-
example: 'http_get_parameters={name=\"John Doe\", age=42, parent=(\"Johanna Doe\", \"Josh Doe\")}'
90+
name: "http_get_parameters",
91+
types: [ParamMap],
92+
description:
93+
"The map will be flattened into pairs that are appended to the IRI before making an HTTP request",
94+
example:
95+
'http_get_parameters={name="John Doe", age=42, parent=("Johanna Doe", "Josh Doe")}',
7796
};
7897

7998
export const http_post_parameters: Parameter = {
80-
name: 'http_post_parameters',
81-
types: [ParamMap],
82-
description: 'The map will be flattened into pairs that are sent as the body of an HTTP POST request ',
83-
example: 'http_post_parameters={name=\"John Doe\", age=42, parent=(\"Johanna Doe\", \"Josh Doe\")}'
84-
99+
name: "http_post_parameters",
100+
types: [ParamMap],
101+
description:
102+
"The map will be flattened into pairs that are sent as the body of an HTTP POST request",
103+
example:
104+
'http_post_parameters={name="John Doe", age=42, parent=("Johanna Doe", "Josh Doe")}',
85105
};
86106

87107
export const iri_fragment: Parameter = {
88-
name: 'iri_fragment',
89-
types: [String],
90-
description: 'A fragment that is appended to a <code>resource</code> or <code>endpoint</code> IRI'
108+
name: "iri_fragment",
109+
types: [String],
110+
description:
111+
"A fragment that is appended to a <code>resource</code> or <code>endpoint</code> IRI",
91112
};
92113

93114
export const base: Parameter = {
94-
name: 'base',
95-
types: [String],
96-
description: 'Specify the base IRI to be used when importing RDF data; if given, relative IRIs will be made absolute based on this base; otherwise, relative IRIs remain relative in Nemo'
115+
name: "base",
116+
types: [String],
117+
description:
118+
"Specify the base IRI to be used when importing RDF data; if given, relative IRIs will be made absolute based on this base; otherwise, relative IRIs remain relative in Nemo",
97119
};
98120

99121
export const endpoint: Parameter = {
100-
name: 'endpoint',
101-
types: [IRI, String],
102-
description: 'Any endpoint that supports SPARQL queries.'
122+
name: "endpoint",
123+
types: [IRI, String],
124+
description: "Any endpoint that supports SPARQL queries.",
103125
};
104126

105127
export const query: Parameter = {
106-
name: 'query',
107-
types: [String],
108-
description: 'The SPARQL query sent to the endpoint. The query will be validated before sending. Make sure to include all necessary prefixes. '
128+
name: "query",
129+
types: [String],
130+
description:
131+
"The SPARQL query sent to the endpoint. The query will be validated before sending. Make sure to include all necessary prefixes.",
109132
};

0 commit comments

Comments
 (0)