Skip to content

Commit 216b45c

Browse files
committed
Add pages to the search index
1 parent 309633e commit 216b45c

File tree

2 files changed

+30
-69
lines changed

2 files changed

+30
-69
lines changed

src/app/docs/schema-reference-guide/page.md

Lines changed: 29 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,16 @@ The TerminusDB schema language enables documents and their relationships to be s
1515

1616
## Schema Objects
1717

18-
A JSON object in TerminusDB schema is composed of **key-value** pairs.
18+
A JSON object in TerminusDB schema is composed of **key-value** pairs. There are two main types of schema objects, one `@context` typed schema object, and different kinds of structures, including the following:
1919

20-
#### Key
20+
* **Class**:definitions for document and subdocument instances
21+
* **Enum**: definitions for enum values
22+
* **Foreign**: definitions for foreign IRI references (arbitrary IRIs)
23+
* **TaggedUnion**: definitions for tagged union types (one of property definitions)
2124

22-
A key is one of two values, **keyword** or **property**, described in the table below. The full schema definition is a stream or list of these values or JSON objects.
23-
24-
#### Table: Types of keys
25-
26-
{%table%}
27-
28-
- Key type
29-
- Example
30-
- Description
31-
32-
---
33-
34-
- **keyword**
35-
- `@id`
36-
- Starts with `@`, has a value with a special meaning.
37-
---
38-
39-
- **property**
40-
- `name`
41-
- Does not start with `@`, has a value with a **range** type.
42-
43-
{%/table%}
25+
Each of the above types of schema objects has a `@type` property with the value of the type, and several other definition keywords as described next.
4426

45-
### Class definition
46-
47-
The basic unit of specification is a **class**. A class definition is a schema object with the keyword `@type` with type value `Class`. The keyword `@id` specifies the name of the class. The example below define a class named `Person` with a property `name` of type `xsd:string`. Search XSD definitions for more information about types.
48-
49-
#### Code: The basic unit of specification
50-
51-
```json
52-
{
53-
"@type" : "Class",
54-
"@id" : "Person",
55-
"name" : "xsd:string"
56-
}
57-
```
58-
https://assets.terminusdb.com/docs/technical-documentation-terminuscms-og.png
59-
media: []
60-
---
61-
62-
The TerminusDB schema language enables documents and their relationships to be specified using simple JSON syntax. This syntax makes it as easy as possible to specify a JSON object to automatically convert to a graph. This approach enables data to be viewed as collections of documents or as knowledge graphs of interconnected objects.
63-
64-
## Schema Objects
65-
66-
A JSON object in TerminusDB schema is composed of **key-value** pairs.
67-
68-
#### Key
27+
### Key
6928

7029
A key is one of two values, **keyword** or **property**, described in the table below. The full schema definition is a stream or list of these values or JSON objects.
7130

@@ -90,7 +49,7 @@ A key is one of two values, **keyword** or **property**, described in the table
9049

9150
{%/table%}
9251

93-
### Class definition
52+
## Class definition
9453

9554
The basic unit of specification is a **class**. A class definition is a schema object with the keyword `@type` with type value `Class`. The keyword `@id` specifies the name of the class. The example below define a class named `Person` with a property `name` of type `xsd:string`. Search XSD definitions for more information about types.
9655

@@ -104,7 +63,7 @@ The basic unit of specification is a **class**. A class definition is a schema o
10463
}
10564
```
10665

107-
### Context object
66+
## Context object
10867

10968
The **context object** is a special schema object affecting the entire schema. The context object is specified by the special `@type` value `@context`. An example:
11069

@@ -139,7 +98,7 @@ This example does the following:
13998
* `@authors`
14099
* `@description`
141100

142-
#### Context Prefixes
101+
### Context Prefixes
143102

144103
All properties in the context object that do not start with `@`, such as `xsd`, are URI definitions. They must be of the form shown below. Prefix and URI are defined by their respective regular expressions. That is, a prefix has an identifier starting with an alphabetic character followed by alphanumeric characters. The URI has a protocol followed by valid URI characters. Each prefix is paired with a URI.
145104

@@ -152,11 +111,11 @@ URI := ":alpha:alphaNum:*://:uriChar:*"
152111
... }
153112
```
154113

155-
## Context keywords
114+
### Context keywords
156115

157116
A list of keywords used in the context object.
158117

159-
### @schema
118+
#### @schema
160119

161120
The `@schema` keyword specifies the default URI expansion to use for all elements of the schema. In the example below, the class name `NamedQuery` expands to `http://terminusdb.com/schema/woql#NamedQuery`.
162121

@@ -199,7 +158,7 @@ The `@schema` keyword specifies the default URI expansion to use for all element
199158
}
200159
```
201160

202-
### @documentation
161+
#### @documentation
203162

204163
`@documentation` specifies documentation global to the entire schema. See the `@documentation` section in the previous context object example. The `@documentation` tag can be a single value, or it can be a list with each element having an additional `@langugage` tag. The `@language` tag must have an IANA language code, and this will be used to select appropriate descriptions when internationalising the schema.
205164

@@ -255,7 +214,7 @@ An example of the `@language` tag for a context is as follows:
255214
}
256215
```
257216

258-
## Document definition keywords
217+
## Document structure definition keywords
259218

260219
A document definition includes several properties, and the keywords, prefixed `@`, describing class behavior.
261220

@@ -322,7 +281,7 @@ You can specify the order of properties within your schema so that it is display
322281
...
323282
```
324283

325-
### Class schema type
284+
## Class schema type
326285

327286
`Class` designates a standard class document. It contains the definition of several properties and keywords describing various class attributes. An example of a class, and an instance of the class:
328287

@@ -343,7 +302,7 @@ You can specify the order of properties within your schema so that it is display
343302
}
344303
```
345304

346-
#### Code: An example of a class instance
305+
### Code: An example of a class instance
347306

348307
```json
349308
{
@@ -359,11 +318,11 @@ You can specify the order of properties within your schema so that it is display
359318
}
360319
```
361320

362-
### Enum schema type
321+
## Enum schema type
363322

364323
An `Enum` is a non-standard class in which each instance is a simple URI with no additional structure. To be a member of the class, you must be one of the referent URIs. An `Enum` example with an extension `Blue` is s shown below. In the database, the actual URI for an Enum is expanded with the preceding type name, so the `blue` extension becomes `http://s#PrimaryColour/blue`
365324

366-
#### Code: An example of an enum class
325+
### Code: An example of an enum class
367326

368327
```json
369328
{
@@ -378,13 +337,13 @@ An `Enum` is a non-standard class in which each instance is a simple URI with no
378337
}
379338
```
380339

381-
### TaggedUnion schema type
340+
## TaggedUnion schema type
382341

383342
A `TaggedUnion` specifies mutually exclusive properties. This is useful when there is a disjoint choice between options.
384343

385344
Examples below of a schema with a TaggedUnion and a concrete TaggedUnion class extension. In these examples, the `BinaryTree` class specifies a `TaggedUnion` enabling a choice between a `leaf` (with no value), or a `node` class with a value and branches.
386345

387-
#### Code: An example schema with a TaggedUnion
346+
### Code: An example schema with a TaggedUnion
388347

389348
```json
390349
{
@@ -416,7 +375,7 @@ Examples below of a schema with a TaggedUnion and a concrete TaggedUnion class e
416375
}
417376
```
418377

419-
#### Code: An example TaggedUnion class extension
378+
### Code: An example TaggedUnion class extension
420379

421380
```json
422381
{
@@ -435,13 +394,13 @@ Examples below of a schema with a TaggedUnion and a concrete TaggedUnion class e
435394
}
436395
```
437396

438-
### @oneOf
397+
## @oneOf in a Class definition
439398

440399
The `TaggedUnion` is a special case and syntactic sugar for the more general case of collections of disjoint properties. These more complex cases can be represented by inheriting from a number of `TaggedUnion`s, but they may also be given explicitly using the `@oneOf` field, together with a Class.
441400

442401
The value of the `@oneOf` field is a set, so can be any number of documents all of which have mutually disjoint properties, but which can coexist. Examples with more than one disjoint property are given below.
443402

444-
#### Code: An example schema with @oneOf
403+
### Code: An example schema with @oneOf
445404

446405
```json
447406
{
@@ -495,7 +454,7 @@ The value of the `@oneOf` field is a set, so can be any number of documents all
495454
}
496455
```
497456

498-
#### Code: Examples of `@oneOf` class extensions
457+
### Code: Examples of `@oneOf` class extensions
499458

500459
```json
501460
{
@@ -554,6 +513,8 @@ But not:
554513

555514
The `Unit` type has a single extension `[]`. This is used when only the presence of the property is interesting, but it has no interesting value. See the `BinaryTree` in the [TaggedUnion class extension](#codeanexampletaggedunionclassextension) example above.
556515

516+
## Class definition details
517+
557518
### @id
558519

559520
The `@id` key of a class defines the class name and identifier. The name uniquely defines the class, enabling the class to be updated, retrieved, and deleted. In the example below, the class is named `NamedQuery`. It does not have a fully qualified URL or prefix, so it is implicitly based on the URI given for `@schema`.
@@ -1015,7 +976,7 @@ An example of inheritance of properties and an object meeting this specification
1015976
}
1016977
```
1017978

1018-
## @unfoldable
979+
### @unfoldable
1019980

1020981
The `@unfoldable` key is present with the value `[]` or it is not present.
1021982

@@ -1025,7 +986,7 @@ The `@unfoldable` option can only be set on a class which does not directly or i
1025986

1026987
The purpose of `@unfoldable` is to be able to treat linked (top-level) documents as subdocuments in representation. Subdocuments can only be linked by one document, its owner, whereas normal documents can be linked by any number of other documents. If the desired result is to have a document linked by several other documents, but still have it fully unfolded on retrieval like a subdocument, use this option.
1027988

1028-
### Code: An example unfoldable
989+
#### Code: An example unfoldable
1029990

1030991
```json
1031992
{
@@ -1102,7 +1063,7 @@ The above example shows both Doug and Phil using the same address document. On r
11021063

11031064
The address is fully unfolded in both documents despite not being a subdocument.
11041065

1105-
## Class properties
1066+
### Class properties
11061067

11071068
All non-keywords are treated as properties of the class, with the form:
11081069

src/markdoc/search.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function extractSections(node, sections, isRoot = true) {
3030
}
3131
if (node.type === 'heading' || node.type === 'paragraph') {
3232
let content = toString(node).trim()
33-
if (node.type === 'heading' && node.attributes.level <= 2) {
33+
if (node.type === 'heading' && node.attributes.level <= 3) {
3434
let hash = node.attributes?.id ?? slugify(content)
3535
sections.push([content, hash, []])
3636
} else {

0 commit comments

Comments
 (0)