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 >
2
2
< nav class ="md-check__nav ">
3
3
< ol class ="nav__list ">
4
4
< li class ="nav__item "> < a class ="nav__link "
5
5
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 >
7
7
< div class ="nav__sub ">
8
8
< ol class ="nav__list ">
9
9
< 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 >
12
12
</ li >
13
13
14
14
15
15
< 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 >
18
24
</ li >
19
25
</ ol >
20
26
</ div >
30
36
href ="#src-1-writing-markdown-md_Executing-Code-Blocks "
31
37
title ="Trigger execution of fences "> Executing Code Blocks</ a >
32
38
</ 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 >
39
39
</ ol >
40
40
</ div >
41
41
</ li >
139
139
</ li >
140
140
</ ol >
141
141
</ nav >
142
-
142
+ < div class =" md-check__content " >
143
143
< section id ="file_src-0-README-md " class ="md-check__file ">
144
144
145
145
< a href ="#file_src-0-README-md "
146
146
class ="file__permalink "
147
- title ="Compile and execute typescript code blocks. "
147
+ title ="Check your docs! "
148
148
rel ="instructions ">
149
- < h2 class ="file__heading "> Typescript Examples </ h2 >
149
+ < h2 class ="file__heading "> md-check </ h2 >
150
150
</ a >
151
151
< 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
154
185
</ 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 > );
157
191
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 >
161
203
</ 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
170
214
</ code > </ pre >
171
215
</ div >
172
216
</ section >
@@ -184,27 +228,24 @@ <h3 id="making-code-blocks-executable">Making code blocks executable <a class="h
184
228
< p > Executors get passed the fence and can either accept it or skip it.
185
229
The node vm executor will split the fence’s name and check if the last
186
230
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
190
232
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
195
237
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
200
242
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 >
204
245
< h3 id ="file-metadata "> File metadata < a class ="header-anchor " href ="#file-metadata "> ¶</ a > </ h3 >
205
246
< p > Metadata is YAML parsed out of the header block of the file. The currently support
206
247
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 >
208
249
< 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 >
209
250
< span class ="hljs-attr "> env:</ span > < span class ="hljs-comment "> # Provide env parameters for the file</ span >
210
251
< 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
242
283
243
284
</ code > </ pre >
244
285
< 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 >
246
287
< 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 > ;
247
288
248
289
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
395
436
TsCompiler.supply(< span class ="hljs-string "> 'tsconfig.json'</ span > ); < span class ="hljs-comment "> // Provide a path to you tsconfig</ span >
396
437
TsCompiler.supply({< span class ="hljs-comment "> /* compiler options */</ span > }); < span class ="hljs-comment "> // Provide a configuration object</ span >
397
438
</ 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 >
400
441
< 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 > ;
401
442
402
443
< span class ="hljs-keyword "> const</ span > log: Log = ConsoleLog.create(< span class ="hljs-string "> 'example'</ span > );
403
444
log.info(< span class ="hljs-string "> 'Hello'</ span > );
404
445
</ code > </ pre >
405
446
</ div >
406
447
</ section >
407
-
448
+ </ div >
408
449
< section class ="md-check__footer ">
409
450
< span class ="footer__project-name "> @btilford/md-check</ span >
410
451
< 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 >
412
453
</ section >
413
- </ div >
454
+ </ main >
414
455
0 commit comments