Skip to content

Commit 530913d

Browse files
committed
Exclude sections from run button in docs
Disable the runnable JS button on JS blocks that aren't suitable for running inline.
1 parent a86942b commit 530913d

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

documentation/docmaker.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
"cyJson": "#core/initialisation"
2525
},
2626

27+
"mdRunButtonBlocked": [
28+
"intro.md",
29+
"notation.md",
30+
"getting-started.md",
31+
"core/init.md"
32+
],
33+
2734
"sections": [
2835
{
2936
"md": "links"

documentation/docmaker.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const readFileSync = file => fs.readFileSync( path.join(__dirname, file), 'utf8'
1919

2020
let config, versions;
2121
let mdRend = new marked.Renderer();
22+
let mdRendDefault = new marked.Renderer();
2223

2324
let rendCode = mdRend.code;
2425
mdRend.code = function(code, lang){
@@ -69,9 +70,7 @@ function md2html( file ){
6970
throw 'A markdown file named `' + file + '` was referenced but could not be read';
7071
}
7172

72-
// let html = converter.makeHtml( md );
73-
//let html = mdConvertor( md );
74-
marked.setOptions({
73+
let options = {
7574
highlight: function(code, lang){
7675
let ret;
7776

@@ -87,10 +86,20 @@ function md2html( file ){
8786

8887
smartypants: true,
8988

90-
renderer: mdRend,
91-
9289
gfm: true
93-
} );
90+
};
91+
92+
let mdBtnBlocked = config.mdRunButtonBlocked.indexOf(file) >= 0;
93+
let mdBtnAllowed = !mdBtnBlocked;
94+
95+
if( mdBtnAllowed ){
96+
// add run button to code blocks
97+
options.renderer = mdRend;
98+
} else {
99+
options.renderer = mdRendDefault;
100+
}
101+
102+
marked.setOptions(options);
94103

95104
let html = marked.parse( md );
96105

0 commit comments

Comments
 (0)