This repository has been archived by the owner on Feb 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49904b6
commit 89ed8fe
Showing
3 changed files
with
36 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
const Toc = require('markdown-toc') | ||
const Fs = require('fs') | ||
const Package = require('./package.json') | ||
|
||
const internals = { | ||
api: { | ||
filename: './API.md', | ||
contents: Fs.readFileSync('./API.md', 'utf8') | ||
}, | ||
readme: { | ||
filename: './README.md', | ||
contents: Fs.readFileSync('./README.md', 'utf8') | ||
} | ||
} | ||
|
||
const tocOptions = { | ||
bullets: '-', | ||
slugify: function (text) { | ||
return text.toLowerCase() | ||
.replace(/\s/g, '-') | ||
.replace(/[^\w-]/g, '') | ||
} | ||
} | ||
|
||
// generate table of contents and version label docs | ||
const api = Toc.insert(internals.api.contents, tocOptions) | ||
.replace(/<!-- version -->(.|\n)*<!-- versionstop -->/, `<!-- version -->\nAPI Documentation - \`v${Package.version}\`\n---\n<!-- versionstop -->`) | ||
Fs.writeFileSync(internals.api.filename, api) | ||
|
||
// create absolute URL for versioned docs | ||
const readme = internals.readme.contents.replace(/\[API Documentation\]\(.*\)/g, `[API Documentation](${Package.homepage || ''}/blob/v${Package.version}/${internals.api.filename})`) | ||
Fs.writeFileSync(internals.readme.filename, readme) |
This file was deleted.
Oops, something went wrong.
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