-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* do not commit generated content to VCS This removes `markdown-magic` and replaces its functionality with the built-in data capabilities of 11ty. The TOC, `--help` output, and source files are now all done via global data scripts in `docs/_data`. When building documentation, we will no longer get changes to e.g., `docs/index.md` because of the automatically generated content. * add inclusive language plugin to eleventy Usage of the words as defined in options will result in a warning, and will not break the build. Also: Eleventy should ignore the historical changelogs in `docs/changelogs`.
- Loading branch information
Showing
14 changed files
with
647 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ LICENSE* | |
.* | ||
_dist/ | ||
example/ | ||
changelogs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
const {resolve, relative, dirname} = require('path'); | ||
const {readFileSync} = require('fs'); | ||
|
||
const PROJECT_ROOT_DIR = resolve(__dirname, '..', '..'); | ||
const FILES = [ | ||
{ | ||
slug: 'simplereporter', | ||
path: require.resolve('../../test/integration/fixtures/simple-reporter.js'), | ||
header: '// my-reporter.js' | ||
} | ||
]; | ||
|
||
const HEADER = '```js\n'; | ||
const FOOTER = '```\n'; | ||
|
||
const loadFile = (path, {header} = {}) => { | ||
const relativeDir = relative(dirname(path), PROJECT_ROOT_DIR); | ||
let content = readFileSync(path, 'utf-8'); | ||
// replace relative paths in `require()` to root with "mocha". | ||
// might not work in the general case. not gonna parse an AST for this | ||
// e.g. `require('../../lib/foo')` => `require('mocha/lib/foo')` | ||
// also trim any trailing whitespace | ||
content = content | ||
.replace( | ||
new RegExp(`require\\(['"]${relativeDir}(.*?)['"]\\)`, 'g'), | ||
"require('mocha$1')" | ||
) | ||
.trim(); | ||
return `${HEADER}${header}\n\n${content}${FOOTER}`; | ||
}; | ||
|
||
/** | ||
* Loads files from disk (see `FILES` above) to be shown as data. | ||
* Used for embedding sources directly into pages | ||
*/ | ||
module.exports = () => { | ||
const files = FILES.map(({path, header, slug}) => { | ||
const content = loadFile(path, {header}); | ||
return {slug, content}; | ||
}); | ||
return files.reduce( | ||
(files, {slug, content}) => ({ | ||
...files, | ||
[slug]: content | ||
}), | ||
{} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const markdownToc = require('markdown-toc'); | ||
const {readFileSync} = require('fs'); | ||
const {resolve} = require('path'); | ||
|
||
const IGNORED_HEADINGS_REGEXP = /Features|Table of Contents|Backers|Sponsors/i; | ||
const DOCUMENT_PATH = resolve(__dirname, '..', 'index.md'); | ||
|
||
module.exports = () => { | ||
const doc = readFileSync(DOCUMENT_PATH, 'utf-8'); | ||
return markdownToc(doc, { | ||
slugify: require('uslug'), | ||
firsth1: false, | ||
bullets: '-', | ||
maxdepth: 2, | ||
// if filter is supplied, maxdepth is apparently ignored, | ||
// so we have to do it ourselves. | ||
filter: (str, ele) => ele.lvl < 2 && !IGNORED_HEADINGS_REGEXP.test(str) | ||
}).content; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const stripAnsi = require('strip-ansi'); | ||
const {resolve} = require('path'); | ||
const {execSync} = require('child_process'); | ||
|
||
const executable = require.resolve('../../bin/mocha'); | ||
const flag = '--help'; | ||
|
||
/** | ||
* Return the output of `mocha --help` for display | ||
*/ | ||
module.exports = () => { | ||
return stripAnsi( | ||
String( | ||
execSync(`"${process.execPath}" ${executable} ${flag}`, { | ||
cwd: resolve(__dirname, '..') | ||
}) | ||
).trim() | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Historical Changelogs | ||
|
||
These are changelogs for (very) old versions of Mocha. | ||
|
||
These changelogs are _not_ included in the website, and are here only for archival purposes. | ||
|
||
_If you're looking for the current changelog, [here is the current changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)._ |
Oops, something went wrong.