You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doc Structure Lint uses a _local_ language model to evaluate some parts of your templates and content. This model only takes about 2 GB of storage, and it's only downloaded once. When you run the tool for the first time, it may take a few minutes to download the language model. If you don't want to download the model during installation, set the `DOC_STRUCTURE_LINT_PRELOAD` environment variable to `0`. However, if you specify an `instructions` property in your template, the model will be downloaded regardless of the `DOC_STRUCTURE_LINT_PRELOAD` variable value.
Templates are defined in YAML and specify the structure and content requirements for your documents. Each template can contain multiple sections with various validation rules.
71
+
72
+
Template definitions also support referencing with the `$ref` key, allowing you to reuse common section definitions across multiple templates.
73
+
74
+
### Basic Structure
75
+
76
+
```yaml
77
+
templates:
78
+
template-name: # Must be alphanumeric, can include hyphens and underscores
patterns: # Array of regex patterns applied sequentially
110
+
- "^Start with.*"
111
+
- ".*end with this$"
112
+
```
113
+
114
+
#### Code Blocks
115
+
116
+
```yaml
117
+
code_blocks:
118
+
min: 0# Minimum number of code blocks
119
+
max: 5# Maximum number of code blocks
120
+
```
121
+
122
+
#### Lists
123
+
124
+
```yaml
125
+
lists:
126
+
min: 0# Minimum number of lists
127
+
max: 5# Maximum number of lists
128
+
items: # Requirements for list items
129
+
min: 1# Minimum items per list
130
+
max: 10# Maximum items per list
131
+
paragraphs: # Paragraph requirements within items
132
+
min: 0
133
+
max: 2
134
+
code_blocks: # Code block requirements within items
135
+
min: 0
136
+
max: 1
137
+
lists: # Nested list requirements
138
+
min: 0
139
+
max: 2
140
+
```
141
+
142
+
#### Content Sequence
143
+
144
+
Use `sequence` to specify a strict order of content elements:
145
+
146
+
```yaml
147
+
sequence:
148
+
- paragraphs:
149
+
min: 1 # Must start with at least one paragraph
150
+
max: 3 # But a maximum of three paragraphs
151
+
- code_blocks:
152
+
max: 1 # Followed by at most one code block
153
+
- lists:
154
+
min: 1 # Then at least one list
155
+
- paragraphs:
156
+
min: 1 # And ending with at least one paragraph
157
+
```
158
+
159
+
### Example Template
160
+
161
+
The following definition includes templates for a "How To" guide and an "API Operation" reference. Note that the `parameters` component is used in multiple sections with the `$ref` key.
64
162
65
163
```yaml
66
164
templates:
67
-
how-to-guide: # Template name
165
+
how-to:
68
166
sections:
69
-
introduction: # Section name
70
-
paragraphs: # Paragraph count requirements for the whole section
167
+
title:
168
+
instructions:
169
+
- Must mention the intent of the document
170
+
paragraphs:
171
+
min: 1
172
+
sections:
173
+
overview:
174
+
heading:
175
+
const: Overview
176
+
paragraphs:
177
+
min: 1
178
+
before you start:
179
+
heading:
180
+
const: Before you start
181
+
paragraphs:
182
+
min: 1
183
+
task:
184
+
paragraphs:
185
+
min: 1
186
+
additionalSections: true
187
+
sections:
188
+
Sub-task:
189
+
paragraphs:
190
+
min: 1
191
+
see also:
192
+
heading:
193
+
const: See also
194
+
paragraphs:
195
+
min: 1
196
+
api-operation:
197
+
sections:
198
+
overview:
199
+
heading:
200
+
const: "Overview"
201
+
paragraphs:
71
202
min: 1
72
203
max: 3
73
-
prerequisites:
74
-
sequence: # Specific sequence of elements in the section
To use this template, save it to a file (like the default `templates.yaml`) and specify the template name that matches the key you set in your definition:
0 commit comments