diff --git a/lib/markup.js b/lib/markup.js index 1337b44..b1a3d3d 100644 --- a/lib/markup.js +++ b/lib/markup.js @@ -1,30 +1,17 @@ -import { marked } from 'marked'; -import hljs from 'highlight.js'; -import cheerio from 'cheerio'; - -marked.setOptions({ - highlight: code => hljs.highlightAuto(code).value, -}); - export default function (doc) { - console.log('transforming markup for document'); for (const data of doc.data) { const { id, attributes } = data; - console.log(`\tGenerating markup for ${id}`); try { const description = attributes.description; if (description) { - attributes.description = highlight(description); + attributes.description = fixFilename(description); } - // console.log('\tcompleted highlighting') - replaceDescriptionFor(attributes.methods); replaceDescriptionFor(attributes.properties); replaceDescriptionFor(attributes.events); - // console.log(`\tMarkup Generated for ${id}\n`) } catch (e) { console.log(`Error generating markup for ${id}`); console.log(e); @@ -32,7 +19,6 @@ export default function (doc) { } } - console.log('completed markup transformation for document'); return doc; } @@ -41,90 +27,19 @@ function replaceDescriptionFor(items) { items.forEach(item => { let itemDescription = item.description; if (itemDescription) { - item.description = highlight(itemDescription); + item.description = fixFilename(itemDescription); } }); } } -function highlight(description) { +export function fixFilename(description) { if (description) { - description = description.replace(/&#(\d+);/g, function (match, dec) { - return String.fromCharCode(dec); - }); - } - let markedup = removeHLJSPrefix(marked.parse(description)); - let $ = cheerio.load(markedup); - - let codeBlocks = $('pre code'); - - codeBlocks.each((i, el) => { - let element = $(el); - let klass = element.attr('class'); - let lang = ''; - let tableHeader = ''; - if (klass) { - let type = klass.split('-').pop(); - if (isFile(type)) { - tableHeader = ` - - - ${type} - - `; - } - lang = determineLanguage(type); - } - let lines = element.html().split('\n'); - - // get rid of empty blank line - if (lines[lines.length - 1].trim() === '') { - lines.pop(); - } - - let wrappedLines = `
${lines.join('\n')}
`; - let lineNumbers = lines.map((_, i) => `${i + 1}\n`).join(''); - - element.parent().after(`
-
-
- ${tableHeader} - - - - - - -
${lineNumbers}
${wrappedLines}
-
-
- `); - - element.parent().remove(); - }); - - return $.html(); -} - -function determineLanguage(maybeFileName) { - const lang = maybeFileName.split('.').pop(); - switch (lang) { - case 'js': - case 'javascript': - return 'javascript'; - case 'ts': - return 'typescript'; - case 'hbs': - return 'handlebars'; - default: - return lang; + description = description + .replaceAll(/```([^\n]+)\.(js|hbs|ts)\n/g, '```$2 {data-filename=$1.$2}\n') + .replaceAll('```hbs', '```handlebars') + .replaceAll('```no-highlight', '```'); } -} - -function removeHLJSPrefix(string) { - return string.replace(/hljs-/g, ''); -} -function isFile(string) { - return /\./.test(string); + return description; } diff --git a/package-lock.json b/package-lock.json index 544e280..29c40af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "chalk": "^4.1.2", - "cheerio": "^1.0.0-rc.2", "command-exists": "^1.2.8", "commander": "^11.1.0", "compare-versions": "^3.5.1", @@ -19,12 +18,10 @@ "execa": "^2.0.4", "fs-extra": "^8.1.0", "glob": "^7.1.4", - "highlight.js": "^11.7.0", "http-server": "^0.11.1", "inflected": "^2.0.4", "keyfinder": "^1.0.0", "lodash-es": "^4.17.21", - "marked": "^4.3.0", "minimist": "^1.2.6", "mkdir-promise": "^1.0.0", "mkdirp": "^0.5.1", @@ -37,6 +34,10 @@ "semver-utils": "^1.1.4", "yuidoc-to-jsonapi": "^0.4.1" }, + "bin": { + "build-jsonapi-docs": "index.js", + "build-yuidoc": "generate-local.js" + }, "devDependencies": { "chai": "^4.2.0", "eslint": "^8.52.0", @@ -698,11 +699,6 @@ "safe-buffer": "^5.1.1" } }, - "node_modules/boolbase": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==" - }, "node_modules/bplist-parser": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", @@ -997,42 +993,6 @@ "node": "*" } }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", - "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", - "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1290,32 +1250,6 @@ "semver": "bin/semver" } }, - "node_modules/css-select": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", - "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", - "dependencies": { - "boolbase": "^1.0.0", - "css-what": "^6.1.0", - "domhandler": "^5.0.2", - "domutils": "^3.0.1", - "nth-check": "^2.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, - "node_modules/css-what": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", - "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -1791,57 +1725,6 @@ "node": ">=6.0.0" } }, - "node_modules/dom-serializer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", - "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.2", - "entities": "^4.2.0" - }, - "funding": { - "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" - } - }, - "node_modules/domelementtype": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", - "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ] - }, - "node_modules/domhandler": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", - "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", - "dependencies": { - "domelementtype": "^2.3.0" - }, - "engines": { - "node": ">= 4" - }, - "funding": { - "url": "https://github.com/fb55/domhandler?sponsor=1" - } - }, - "node_modules/domutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.1.0.tgz", - "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", - "dependencies": { - "dom-serializer": "^2.0.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3" - }, - "funding": { - "url": "https://github.com/fb55/domutils?sponsor=1" - } - }, "node_modules/download": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/download/-/download-7.1.0.tgz", @@ -1903,17 +1786,6 @@ "once": "^1.4.0" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -2999,38 +2871,12 @@ "he": "bin/he" } }, - "node_modules/highlight.js": { - "version": "11.9.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.9.0.tgz", - "integrity": "sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==", - "engines": { - "node": ">=12.0.0" - } - }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, - "node_modules/htmlparser2": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", - "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" - } - }, "node_modules/http-cache-semantics": { "version": "3.8.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", @@ -3926,17 +3772,6 @@ "node": ">=4" } }, - "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", - "bin": { - "marked": "bin/marked.js" - }, - "engines": { - "node": ">= 12" - } - }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -4321,17 +4156,6 @@ "node": ">=8" } }, - "node_modules/nth-check": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", - "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", - "dependencies": { - "boolbase": "^1.0.0" - }, - "funding": { - "url": "https://github.com/fb55/nth-check?sponsor=1" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -4755,29 +4579,6 @@ "node": ">=4" } }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", - "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", - "dependencies": { - "domhandler": "^5.0.2", - "parse5": "^7.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", diff --git a/package.json b/package.json index 47fa457..2f164f2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ }, "dependencies": { "chalk": "^4.1.2", - "cheerio": "^1.0.0-rc.2", "command-exists": "^1.2.8", "commander": "^11.1.0", "compare-versions": "^3.5.1", @@ -41,12 +40,10 @@ "execa": "^2.0.4", "fs-extra": "^8.1.0", "glob": "^7.1.4", - "highlight.js": "^11.7.0", "http-server": "^0.11.1", "inflected": "^2.0.4", "keyfinder": "^1.0.0", "lodash-es": "^4.17.21", - "marked": "^4.3.0", "minimist": "^1.2.6", "mkdir-promise": "^1.0.0", "mkdirp": "^0.5.1", diff --git a/test/markup-test.js b/test/markup-test.js index 7cc2be9..3d2a2cb 100644 --- a/test/markup-test.js +++ b/test/markup-test.js @@ -1,58 +1,19 @@ -import markup from '../lib/markup.js'; +import { fixFilename } from '../lib/markup.js'; import { assert } from 'chai'; -import fs from 'fs'; +import fsExtra from 'fs-extra'; +import { join } from 'path'; -function desc(path) { - return { - id: Date.now(), - attributes: { - description: fs.readFileSync(`./test/mocks/description/${path}.md`, 'utf-8'), - methods: [], - properties: [], - events: [], - }, - }; -} +const { readFileSync, readdirSync } = fsExtra; -function mark(path) { - let data = [desc(path)]; - let result = markup({ data }); - let content = result.data[0].attributes.description; - maybeWrite(content, path); - return content; -} - -function maybeWrite(content, path) { - const fsPath = `./test/mocks/description/${path}.html`; - if (fs.existsSync(fsPath)) { - return; - } - fs.writeFileSync(fsPath, content, 'utf-8'); -} - -function snapshot(path) { - const fsPath = `./test/mocks/description/${path}.html`; - return fs.readFileSync(fsPath, 'utf8'); -} +const inputFiles = readdirSync('./test/mocks/input'); describe('markup', () => { - it('render correct syntax for handlebars with title', function () { - const caseName = 'handlebars-title'; - assert.equal(mark(caseName), snapshot(caseName)); - }); + for (let file of inputFiles) { + it(`render correct syntax for ${file}`, function () { + const inputFile = readFileSync(join('./test/mocks/input', file), 'utf-8'); + const outputFile = readFileSync(join('./test/mocks/output', file), 'utf-8'); - it('render correct syntax for handlebars without title', function () { - const caseName = 'handlebars'; - assert.equal(mark(caseName), snapshot(caseName)); - }); - - it('render correct syntax for javascript with title', function () { - const caseName = 'javascript-title'; - assert.equal(mark(caseName), snapshot(caseName)); - }); - - it('render correct syntax for javascript without title', function () { - const caseName = 'javascript'; - assert.equal(mark(caseName), snapshot(caseName)); - }); + assert.equal(fixFilename(inputFile), outputFile); + }); + } }); diff --git a/test/mocks/description/handlebars-title.html b/test/mocks/description/handlebars-title.html deleted file mode 100644 index 4ef6725..0000000 --- a/test/mocks/description/handlebars-title.html +++ /dev/null @@ -1,65 +0,0 @@ -
-
-
- - - - - - - - - - - - -
profile.hbs
1
-2
-3
-
  <h1>{{person.title}}</h1>
-  {{! Executed in the component's context. }}
-  {{yield}} {{! block contents }}
-
-
- -

If you want to customize the component, in order to - handle events or actions, you implement a subclass - of Ember.Component named after the name of the - component. - For example, you could implement the action - hello for the person-profile component:

-
-
-
- - - - - - - - - - - - -
profile.js
1
-2
-3
-4
-5
-6
-7
-8
-
import Ember from 'ember';
-export default Ember.Component.extend({
-  actions: {
-    hello(name) {
-      console.log("Hello", name);
-    }
-  }
-});
-
-
- - \ No newline at end of file diff --git a/test/mocks/description/handlebars.html b/test/mocks/description/handlebars.html deleted file mode 100644 index 9464fde..0000000 --- a/test/mocks/description/handlebars.html +++ /dev/null @@ -1,60 +0,0 @@ -
-
-
- - - - - - - -
1
-2
-3
-
  <h1>{{person.title}}</h1>
-  {{! Executed in the component's context. }}
-  {{yield}} {{! block contents }}
-
-
- -

If you want to customize the component, in order to - handle events or actions, you implement a subclass - of Ember.Component named after the name of the - component. - For example, you could implement the action - hello for the person-profile component:

-
-
-
- - - - - - - - - - - - -
profile.js
1
-2
-3
-4
-5
-6
-7
-8
-
import Ember from 'ember';
-export default Ember.Component.extend({
-  actions: {
-    hello(name) {
-      console.log("Hello", name);
-    }
-  }
-});
-
-
- - \ No newline at end of file diff --git a/test/mocks/description/javascript-title.html b/test/mocks/description/javascript-title.html deleted file mode 100644 index 9ff2012..0000000 --- a/test/mocks/description/javascript-title.html +++ /dev/null @@ -1,35 +0,0 @@ -
-
-
- - - - - - - - - - - - -
app/routes/articles.js
1
-2
-3
-4
-5
-6
-7
-8
-
import Route from '@ember/routing/route';
-export default class ArticlesRoute extends Route {
-  resetController(controller, isExiting, transition) {
-    if (isExiting && transition.targetName !== 'error') {
-      controller.set('page', 1);
-    }
-  }
-}
-
-
- - \ No newline at end of file diff --git a/test/mocks/description/javascript.html b/test/mocks/description/javascript.html deleted file mode 100644 index d50ee6c..0000000 --- a/test/mocks/description/javascript.html +++ /dev/null @@ -1,30 +0,0 @@ -
-
-
- - - - - - - -
1
-2
-3
-4
-5
-6
-7
-8
-
import Route from '@ember/routing/route';
-export default class ArticlesRoute extends Route {
-  resetController(controller, isExiting, transition) {
-    if (isExiting && transition.targetName !== 'error') {
-      controller.set('page', 1);
-    }
-  }
-}
-
-
- - \ No newline at end of file diff --git a/test/mocks/description/handlebars-title.md b/test/mocks/input/handlebars-title.md similarity index 100% rename from test/mocks/description/handlebars-title.md rename to test/mocks/input/handlebars-title.md diff --git a/test/mocks/description/handlebars.md b/test/mocks/input/handlebars.md similarity index 100% rename from test/mocks/description/handlebars.md rename to test/mocks/input/handlebars.md diff --git a/test/mocks/description/javascript-title.md b/test/mocks/input/javascript-title.md similarity index 100% rename from test/mocks/description/javascript-title.md rename to test/mocks/input/javascript-title.md diff --git a/test/mocks/description/javascript.md b/test/mocks/input/javascript.md similarity index 100% rename from test/mocks/description/javascript.md rename to test/mocks/input/javascript.md diff --git a/test/mocks/input/no-highlight.md b/test/mocks/input/no-highlight.md new file mode 100644 index 0000000..6b64af2 --- /dev/null +++ b/test/mocks/input/no-highlight.md @@ -0,0 +1,5 @@ +The default is now that we don't pick a language by default so you don't need the no-highlight language + +```no-highlight +shell make me a sandwich +``` diff --git a/test/mocks/output/handlebars-title.md b/test/mocks/output/handlebars-title.md new file mode 100644 index 0000000..b46a57c --- /dev/null +++ b/test/mocks/output/handlebars-title.md @@ -0,0 +1,21 @@ +```handlebars {data-filename=app/components/person-profile.hbs} +

{{person.title}}

+ {{! Executed in the component's context. }} + {{yield}} {{! block contents }} + ``` + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. + For example, you could implement the action + `hello` for the `person-profile` component: + ```js {data-filename=app/components/person-profile.js} + import Ember from 'ember'; + export default Ember.Component.extend({ + actions: { + hello(name) { + console.log("Hello", name); + } + } + }); +``` diff --git a/test/mocks/output/handlebars.md b/test/mocks/output/handlebars.md new file mode 100644 index 0000000..0d5b915 --- /dev/null +++ b/test/mocks/output/handlebars.md @@ -0,0 +1,21 @@ +```handlebars +

{{person.title}}

+ {{! Executed in the component's context. }} + {{yield}} {{! block contents }} + ``` + If you want to customize the component, in order to + handle events or actions, you implement a subclass + of `Ember.Component` named after the name of the + component. + For example, you could implement the action + `hello` for the `person-profile` component: + ```js {data-filename=app/components/person-profile.js} + import Ember from 'ember'; + export default Ember.Component.extend({ + actions: { + hello(name) { + console.log("Hello", name); + } + } + }); +``` diff --git a/test/mocks/output/javascript-title.md b/test/mocks/output/javascript-title.md new file mode 100644 index 0000000..f90afe3 --- /dev/null +++ b/test/mocks/output/javascript-title.md @@ -0,0 +1,10 @@ +```js {data-filename=app/routes/articles.js} +import Route from '@ember/routing/route'; +export default class ArticlesRoute extends Route { + resetController(controller, isExiting, transition) { + if (isExiting && transition.targetName !== 'error') { + controller.set('page', 1); + } + } +} +``` diff --git a/test/mocks/output/javascript.md b/test/mocks/output/javascript.md new file mode 100644 index 0000000..46a9f57 --- /dev/null +++ b/test/mocks/output/javascript.md @@ -0,0 +1,10 @@ +```js +import Route from '@ember/routing/route'; +export default class ArticlesRoute extends Route { + resetController(controller, isExiting, transition) { + if (isExiting && transition.targetName !== 'error') { + controller.set('page', 1); + } + } +} +``` diff --git a/test/mocks/output/no-highlight.md b/test/mocks/output/no-highlight.md new file mode 100644 index 0000000..79d78dc --- /dev/null +++ b/test/mocks/output/no-highlight.md @@ -0,0 +1,5 @@ +The default is now that we don't pick a language by default so you don't need the no-highlight language + +``` +shell make me a sandwich +```