Skip to content

Commit 39424ae

Browse files
committed
regen docs
1 parent 9432535 commit 39424ae

File tree

10 files changed

+235
-102
lines changed

10 files changed

+235
-102
lines changed

docs/_includes/examples.html

+92-51
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
<div><script type="application/ld+json">{"@context":"http://schema.org","@type":"WebPage","name":"@btilford/md-check","url":"https://btilford.github.io/md-check/","author":"btilford","copyrightHolder":{"@type":"Person","name":"Ben Tilford"},"copyrightYear":2020,"dateModified":"2020-04-13T04:23:43.906Z","discussionUrl":"https://github.com/btilford/md-check/issues","description":"Compile and execute markdown code fences","keywords":["markdown","documentation","docs"]}</script><script type="application/ld+json">{"@context":"http://schema.org","@type":"Project","name":"@btilford/md-check","founder":"btilford","url":"https://github.com/btilford/md-check","description":"Compile and execute markdown code fences","sameAs":"git+ssh://[email protected]/btilford/md-check.git","contactPoint":{"url":"https://github.com/btilford/md-check/issues"}}</script><script type="application/ld+json">{"@context":"http://schema.org","@type":"SoftwareSourceCode","name":"@btilford/md-check","version":"1.0.1","codeRepository":"git+ssh://[email protected]/btilford/md-check.git","codeSampleType":"full","programmingLanguage":["Typescript","Javacript","Markdown"],"runtimePlatform":"NodeJS","copyrightHolder":"Ben Tilford","copyrightYear":2020,"dateModified":"2020-04-13T04:23:43.906Z","discussionUrl":"https://github.com/btilford/md-check/issues","description":"Compile and execute markdown code fences","license":"https://github.com/btilford/md-check/LICENSE","keywords":["markdown","documentation","docs"],"contributor":[{"@type":"Person"}],"maintainer":[],"url":"https://github.com/btilford/md-check","inLanguage":"en-US"}</script>
1+
<main class="md-check__main"><script type="application/ld+json">[{"@context":"http://schema.org","@type":"WebPage","name":"@btilford/md-check","url":"https://btilford.github.io/md-check/","author":"btilford","copyrightHolder":{"@type":"Person","name":"Ben Tilford"},"copyrightYear":2020,"dateModified":"2020-04-13T05:32:08.244Z","discussionUrl":"https://github.com/btilford/md-check/issues","description":"Compile and execute markdown code fences","keywords":["markdown","documentation","docs"]},{"@context":"http://schema.org","@type":"Project","name":"@btilford/md-check","founder":"btilford","url":"https://github.com/btilford/md-check","description":"Compile and execute markdown code fences","sameAs":"git+ssh://[email protected]/btilford/md-check.git","contactPoint":{"url":"https://github.com/btilford/md-check/issues"}},{"@context":"http://schema.org","@type":"SoftwareSourceCode","name":"@btilford/md-check","version":"1.0.1","codeRepository":"git+ssh://[email protected]/btilford/md-check.git","codeSampleType":"full","programmingLanguage":["Typescript","Javacript","Markdown"],"runtimePlatform":"NodeJS","copyrightHolder":"Ben Tilford","copyrightYear":2020,"dateModified":"2020-04-13T05:32:08.244Z","discussionUrl":"https://github.com/btilford/md-check/issues","description":"Compile and execute markdown code fences","license":"https://github.com/btilford/md-check/LICENSE","keywords":["markdown","documentation","docs"],"contributor":[{"@type":"Person"}],"maintainer":[],"url":"https://github.com/btilford/md-check","inLanguage":"en-US"}]</script>
22
<nav class="md-check__nav">
33
<ol class="nav__list">
44
<li class="nav__item"><a class="nav__link"
55
href="#file_src-0-README-md"
6-
title="Compile and execute typescript code blocks.">Typescript Examples</a>
6+
title="Check your docs!">md-check</a>
77
<div class="nav__sub">
88
<ol class="nav__list">
99
<li class="nav__item"><a class="md-check__nav-link"
10-
href="#src-0-README-md_Basic"
11-
title="undefined">Basic</a>
10+
href="#src-0-README-md_Installation"
11+
title="undefined">Installation</a>
1212
</li>
1313

1414

1515
<li class="nav__item"><a class="md-check__nav-link"
16-
href="#src-0-README-md_Configuration"
17-
title="undefined">Configuration</a>
16+
href="#src-0-README-md_Getting-Started"
17+
title="Configure and run md-check">Getting Started</a>
18+
</li>
19+
20+
21+
<li class="nav__item"><a class="md-check__nav-link"
22+
href="#src-0-README-md_Development"
23+
title="Building md-check">Development</a>
1824
</li>
1925
</ol>
2026
</div>
@@ -30,12 +36,6 @@
3036
href="#src-1-writing-markdown-md_Executing-Code-Blocks"
3137
title="Trigger execution of fences">Executing Code Blocks</a>
3238
</li>
33-
34-
35-
<li class="nav__item"><a class="md-check__nav-link"
36-
href="#src-1-writing-markdown-md_Configuring-metadata"
37-
title="Set metadata for nicer output">Configuring metadata</a>
38-
</li>
3939
</ol>
4040
</div>
4141
</li>
@@ -139,34 +139,78 @@
139139
</li>
140140
</ol>
141141
</nav>
142-
142+
<div class="md-check__content">
143143
<section id="file_src-0-README-md" class="md-check__file">
144144

145145
<a href="#file_src-0-README-md"
146146
class="file__permalink"
147-
title="Compile and execute typescript code blocks."
147+
title="Check your docs!"
148148
rel="instructions">
149-
<h2 class="file__heading">Typescript Examples</h2>
149+
<h2 class="file__heading">md-check</h2>
150150
</a>
151151
<div class="file__content">
152-
<h3 id="installation">Installation <a class="header-anchor" href="#installation"></a></h3>
153-
<pre><code id="src-0-README-md_Basic" class="md-check__code-block language-console">npm install --save-dev @btilford/md-check-compile-typescript
152+
<p><img src="https://github.com/btilford/md-check/workflows/Rush%20CI/badge.svg?branch=master" alt="Rush CI"></p>
153+
<h1 id="md-check">md-check <a class="header-anchor" href="#md-check"></a></h1>
154+
<p><em>Compile and execute your markdown documentation.</em></p>
155+
<p><strong>Why?</strong></p>
156+
<ol>
157+
<li>Your docs have drifted out of sync with your codebase.</li>
158+
<li>Your docs are incomplete or wrong and won’t compile.</li>
159+
<li>Your users will thank you.</li>
160+
</ol>
161+
<p><strong>What?</strong></p>
162+
<p>Essentially this is like and borrows a lot from storybook and MDX. But isn’t
163+
focused on UI components.</p>
164+
<ol>
165+
<li>Extract fences from your markdown.</li>
166+
<li>Compile individual blocks if necessary.</li>
167+
<li>Execute each block and optionally capture output.</li>
168+
</ol>
169+
<p>This verifies that</p>
170+
<ol>
171+
<li>Your code at the very least is valid.</li>
172+
<li>Your code is complete including imports because each block compiles and executes by
173+
itself. <em>No more crawling the web for what was actually imported for that random snippet
174+
that was missing pieces.</em></li>
175+
<li>You code executes without an error. You could even execute tests in you code block. Part
176+
of the inspiration for this was Mocha’s <a href="https://mochajs.org/#doc">doc</a> and
177+
<a href="https://mochajs.org/#markdown">markdown</a> reporters.</li>
178+
</ol>
179+
<h2 id="install">Install <a class="header-anchor" href="#install"></a></h2>
180+
<pre><code id="src-0-README-md_Installation" class="md-check__code-block language-console"><span class="hljs-meta">#</span><span class="bash"> Run node and other commands</span>
181+
npm install --save-dev @btilford/md-check
182+
<span class="hljs-meta">
183+
#</span><span class="bash"> To compile typescript code blocks</span>
184+
npm install --save-dev @btilford/md-check-compile-typescript
154185
</code></pre>
155-
<h3 id="setup-the-typescript-compiler">Setup the Typescript compiler <a class="header-anchor" href="#setup-the-typescript-compiler"></a></h3>
156-
<pre><code id="src-0-README-md_Configuration" class="md-check__code-block language-typescript"><span class="hljs-keyword">import</span> {TsCompiler} <span class="hljs-keyword">from</span> <span class="hljs-string">'@btilford/md-check-compile-typescript'</span>;
186+
<h2 id="getting-started">Getting Started <a class="header-anchor" href="#getting-started"></a></h2>
187+
<p>The documentation <a href="https://btilford.github.io/md-check//examples.html">here</a> was generated
188+
from the markdown in <a href="examples/src">examples/src</a> by the <a href="examples/md-check.js">md-check.js</a> script .</p>
189+
<p><strong>Configure md-check</strong></p>
190+
<pre><code id="src-0-README-md_Getting-Started" class="md-check__code-block language-javascript"><span class="hljs-keyword">const</span> {mdCheck, NodeVmExecutor} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@btilford/md-check'</span>);
157191

158-
TsCompiler.supply(); <span class="hljs-comment">// default configs, uses ${process.cwd()}/tsconfig.json</span>
159-
TsCompiler.supply(<span class="hljs-string">'tsconfig.json'</span>); <span class="hljs-comment">// Provide a path to you tsconfig</span>
160-
TsCompiler.supply({<span class="hljs-comment">/* compiler options */</span>}); <span class="hljs-comment">// Provide a configuration object</span>
192+
<span class="hljs-keyword">const</span> run = mdCheck({
193+
<span class="hljs-attr">include</span>: {
194+
<span class="hljs-attr">patterns</span>: [
195+
<span class="hljs-string">'docs/**/*.{md,mdx}'</span>
196+
]
197+
},
198+
<span class="hljs-attr">executors</span>: [
199+
[NodeVmExecutor.supply()]
200+
]
201+
});
202+
<span class="hljs-comment">// Calling run() will trigger execution.</span>
161203
</code></pre>
162-
<h3 id="as-a-node.js-script">As a Node.js script <a class="header-anchor" href="#as-a-node.js-script"></a></h3>
163-
<p><em>Inside your markdown file add a code fence starting with <strong>typescript</strong>.</em></p>
164-
<pre><code>```typescript node
165-
import {ConsoleLog} from '@btilford/ts-base';
166-
167-
const log: Log = ConsoleLog.create('example');
168-
log.info('Hello');
169-
```
204+
<h2 id="development">Development <a class="header-anchor" href="#development"></a></h2>
205+
<p>If you don’t have <a href="https://rushjs.io/">rush</a> installed you’ll need to get that.</p>
206+
<pre><code id="src-0-README-md_Development" class="md-check__code-block language-console">npm install -g @microsoft/rush
207+
</code></pre>
208+
<p>Clone and initialize</p>
209+
<pre><code id="src-0-README-md_" class="md-check__code-block language-console">git clone [email protected]:btilford/md-check.git
210+
rush install
211+
</code></pre>
212+
<p>Building</p>
213+
<pre><code id="src-0-README-md_" class="md-check__code-block language-console">rush build
170214
</code></pre>
171215
</div>
172216
</section>
@@ -184,27 +228,24 @@ <h3 id="making-code-blocks-executable">Making code blocks executable <a class="h
184228
<p>Executors get passed the fence and can either accept it or skip it.
185229
The node vm executor will split the fence’s name and check if the last
186230
item in the array is <strong>node</strong> or <strong>node-vm</strong>.</p>
187-
<pre class="md-check__code-block language-markdown" id="src-1-writing-markdown-md_Executing-Code-Blocks">
188-
<code>
189-
<span class="hljs-tag">```</span><span class="hljs-keyword">javascript node</span>
231+
<pre><code>```javascript node
190232
console.log('This would be executed by the node vm executor');
191-
<span class="hljs-tag">```</span>
192-
</code>
193-
<code>
194-
<span class="hljs-tag">```</span><span class="hljs-keyword">javascript node-vm</span>
233+
```
234+
235+
236+
```javascript node-vm
195237
console.log('This would be executed by the node vm executor');
196-
<span class="hljs-tag">```</span>
197-
</code>
198-
<code>
199-
<span class="hljs-tag">```</span><span class="hljs-keyword">javascript js</span>
238+
```
239+
240+
241+
```javascript js
200242
console.warn('This would NOT be executed by the node vm executor');
201-
<span class="hljs-tag">```</span>
202-
</code>
203-
</pre>
243+
```
244+
</code></pre>
204245
<h3 id="file-metadata">File metadata <a class="header-anchor" href="#file-metadata"></a></h3>
205246
<p>Metadata is YAML parsed out of the header block of the file. The currently support
206247
entries are.</p>
207-
<pre><code id="src-1-writing-markdown-md_Configuring-metadata" class="md-check__code-block language-yaml"><span class="hljs-attr">title:</span> <span class="hljs-string">Title</span> <span class="hljs-string">for</span> <span class="hljs-string">the</span> <span class="hljs-string">file</span> <span class="hljs-comment"># Used to generate header and link text</span>
248+
<pre><code id="src-1-writing-markdown-md_Executing-Code-Blocks" class="md-check__code-block language-yaml"><span class="hljs-attr">title:</span> <span class="hljs-string">Title</span> <span class="hljs-string">for</span> <span class="hljs-string">the</span> <span class="hljs-string">file</span> <span class="hljs-comment"># Used to generate header and link text</span>
208249
<span class="hljs-attr">description:</span> <span class="hljs-string">Added</span> <span class="hljs-string">to</span> <span class="hljs-string">link.title</span>
209250
<span class="hljs-attr">env:</span> <span class="hljs-comment"># Provide env parameters for the file</span>
210251
<span class="hljs-bullet">-</span> <span class="hljs-attr">NODE_ENV:</span> <span class="hljs-string">test</span>
@@ -242,7 +283,7 @@ <h3 id="configure-the-mochaexecutor">Configure the MochaExecutor <a class="heade
242283

243284
</code></pre>
244285
<h3 id="running-mocha-tests">Running Mocha Tests <a class="header-anchor" href="#running-mocha-tests"></a></h3>
245-
<p><em>Inside your markdown file add a code fence ending with <strong>mocha</strong>.</em></p>
286+
<p><em>Inside your markdown file add a code fence ending with <strong>mocha</strong>, <strong>```javascript mocha</strong>.</em></p>
246287
<pre><code id="src-mocha-mdx_Configure" class="md-check__code-block language-typescript"><span class="hljs-keyword">import</span> {expect} <span class="hljs-keyword">from</span> <span class="hljs-string">'chai'</span>;
247288

248289
describe(<span class="hljs-string">'My test'</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
@@ -395,20 +436,20 @@ <h3 id="setup-the-typescript-compiler">Setup the Typescript compiler <a class="h
395436
TsCompiler.supply(<span class="hljs-string">'tsconfig.json'</span>); <span class="hljs-comment">// Provide a path to you tsconfig</span>
396437
TsCompiler.supply({<span class="hljs-comment">/* compiler options */</span>}); <span class="hljs-comment">// Provide a configuration object</span>
397438
</code></pre>
398-
<h3 id="as-a-node.js-script">As a Node.js script <a class="header-anchor" href="#as-a-node.js-script"></a></h3>
399-
<p><em>Inside your markdown file add a code fence starting with <strong>typescript</strong>.</em></p>
439+
<h3 id="compile-and-run">Compile and run <a class="header-anchor" href="#compile-and-run"></a></h3>
440+
<p><em>Inside your markdown file add a code fence starting with <strong>typescript</strong> <strong>```typescript</strong>.</em></p>
400441
<pre><code id="src-typescript-mdx_typescript-node-3" class="md-check__code-block language-typescript"><span class="hljs-keyword">import</span> {ConsoleLog} <span class="hljs-keyword">from</span> <span class="hljs-string">'@btilford/ts-base'</span>;
401442

402443
<span class="hljs-keyword">const</span> log: Log = ConsoleLog.create(<span class="hljs-string">'example'</span>);
403444
log.info(<span class="hljs-string">'Hello'</span>);
404445
</code></pre>
405446
</div>
406447
</section>
407-
448+
</div>
408449
<section class="md-check__footer">
409450
<span class="footer__project-name">@btilford/md-check</span>
410451
<span class="footer__project-version">v1.0.1</span>
411-
<span class="footer__timestamp">2020-04-13T04:23:53.327Z</span>
452+
<span class="footer__timestamp">2020-04-13T05:32:16.425Z</span>
412453
</section>
413-
</div>
454+
</main>
414455

docs/_sass/usage.scss docs/_sass/md-check.scss

+23
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
.file__content {
77
position: relative;
88
}
9+
910
.file__content {
1011
padding: 10px;
1112
}
1213

14+
1315
.file__content pre,
16+
.file__content pre code,
1417
.highlighter-rouge .md-check__code-block,
1518
.highlighter-rouge .md-check__code-block pre,
1619
.highlighter-rouge .md-check__code-block code,
@@ -85,6 +88,7 @@
8588
right: 0;
8689
//bottom: -25px ;
8790
}
91+
8892
.file__content code,
8993
code.highlighter-rouge {
9094
background-color: #ddd;
@@ -93,3 +97,22 @@ code.highlighter-rouge {
9397
margin: 0;
9498
display: inline-block;
9599
}
100+
101+
.md-check__main {
102+
display: grid;
103+
grid-template-areas: "header header header" "sidebar content content" ". . footer";
104+
grid-template-columns: 300px 1fr;
105+
}
106+
107+
.md-check__nav {
108+
grid-area: sidebar;
109+
}
110+
111+
.md-check__footer {
112+
grid-area: footer;
113+
font-size: small;
114+
}
115+
116+
.md-check__content {
117+
grid-area: content;
118+
}

docs/assets/css/style.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@import "jekyll-theme-slate";
55
@import "hljs";
6-
@import "usage";
6+
@import "md-check";
77

88

99
.inner {

examples/md-check.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const config = mdCheck({
7777
},
7878
include: {
7979
patterns: [
80-
'**/*.{mdx,md}',
80+
'src/**/*.{mdx,md}',
8181
],
8282
},
8383
executors: [

0 commit comments

Comments
 (0)