Skip to content

Commit 5738b8d

Browse files
committed
feat: add wireoutput to help
1 parent ad40bee commit 5738b8d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

website/help.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,53 @@ <h2>Configuration</h2>
103103
<pre><code>{
104104
<span class="blue">"checks.typography.symbols.curly_quotes"</span>: <span class="red">false</span>
105105
}</code></pre>
106+
107+
108+
<h2>Wire Output</h2>
109+
<p>
110+
<em>Proselint</em> supports structured output for programmatic usage
111+
with the <code>--output-format json</code> flag, like so:
112+
113+
<pre><code><span class="blue">proselint</span> <span class="purple">--output-format</span> <span class="green">json</span> syllabus.md</code></pre>
114+
</p>
115+
116+
117+
<p>The output schema is:</p>
118+
<pre><code><span class="purple">enum</span> <span class="blue">ErrorCode</span> {
119+
<span class="green">Unknown</span> = -31999,
120+
<span class="green">FileError</span> = -31998,
121+
<span class="green">LintError</span> = -31997,
122+
}
123+
124+
<span class="purple">interface</span> <span class="blue">ResponseError</span> {
125+
<span class="green">code</span>: ErrorCode;
126+
<span class="green">message</span>: string;
127+
<span class="green">data</span>?: any;
128+
}
129+
130+
<span class="purple">interface</span> <span class="blue">CheckResult</span> {
131+
<span class="green">check_path</span>: string;
132+
<span class="green">message</span>: string;
133+
<span class="green">span</span>: [number, number];
134+
<span class="green">replacements</span>: string | null;
135+
}
136+
137+
<span class="purple">interface</span> <span class="blue">LintResult</span> <span class="purple">extends</span> <span class="blue">CheckResult</span> {
138+
<span class="green">pos</span>: [number, number];
139+
}
140+
141+
<span class="purple">interface</span> <span class="blue">FileOutput</span> {
142+
<span class="green">diagnostics</span>?: LintResult[];
143+
<span class="green">error</span>?: ResponseError;
144+
}
145+
146+
<span class="purple">interface</span> <span class="blue">ProselintOutput</span> {
147+
<span class="green">result</span>?: Record&lt;string, FileOutput&gt;;
148+
<span class="green">error</span>?: ResponseError;
149+
}</code></pre>
150+
151+
<p>Every invocation of <em>proselint</em> produces exactly one <code>ProselintOutput</code> object. Both <code>ProselintOutput</code> and <code>FileOutput</code> are tagged unions. <br /> <br />
152+
This means that <code>ProselintOutput</code> will always contain one of <code>result</code> or <code>error</code>, but never both, and the same applies to <code>diagnostics</code> and <code>error</code> for <code>FileOutput</code>.</p>
106153
</main>
107154

108155
<footer>

0 commit comments

Comments
 (0)