mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Remove o-error update script (#15070)
GitOrigin-RevId: dfa0c582453eadc6834056a7c8a0832ddb878b70
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs')
|
||||
const jsdoc2md = require('jsdoc-to-markdown')
|
||||
const toc = require('markdown-toc')
|
||||
|
||||
const README = 'README.md'
|
||||
const HEADER = '## OError API Reference'
|
||||
const FOOTER = '<!-- END API REFERENCE -->'
|
||||
|
||||
async function main() {
|
||||
const apiDocs = await jsdoc2md.render({ files: 'index.js' })
|
||||
const apiDocLines = apiDocs.trim().split(/\r?\n/g)
|
||||
|
||||
// The first few lines don't make much sense when included in the README.
|
||||
const apiDocStart = apiDocLines.indexOf('* [OError](#OError)')
|
||||
if (apiDocStart === -1) {
|
||||
console.error('API docs not in expected format for insertion.')
|
||||
process.exit(1)
|
||||
}
|
||||
apiDocLines.splice(1, apiDocStart - 1)
|
||||
apiDocLines.unshift(HEADER, '')
|
||||
|
||||
const readme = await fs.promises.readFile(README, { encoding: 'utf8' })
|
||||
const readmeLines = readme.split(/\r?\n/g)
|
||||
|
||||
const apiStart = readmeLines.indexOf(HEADER)
|
||||
const apiEnd = readmeLines.indexOf(FOOTER)
|
||||
|
||||
if (apiStart === -1 || apiEnd === -1) {
|
||||
console.error('Could not find the API Reference section.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
Array.prototype.splice.apply(
|
||||
readmeLines,
|
||||
[apiStart, apiEnd - apiStart].concat(apiDocLines)
|
||||
)
|
||||
|
||||
const readmeWithApi = readmeLines.join('\n')
|
||||
|
||||
let readmeWithApiAndToc = toc.insert(readmeWithApi)
|
||||
|
||||
// Unfortunately, the ⇒ breaks the generated TOC links.
|
||||
readmeWithApiAndToc = readmeWithApiAndToc.replace(/-%E2%87%92-/g, '--')
|
||||
|
||||
await fs.promises.writeFile(README, readmeWithApiAndToc)
|
||||
}
|
||||
main()
|
||||
@@ -39,8 +39,6 @@
|
||||
"@types/chai": "^4.3.0",
|
||||
"@types/node": "^18.17.4",
|
||||
"chai": "^4.3.6",
|
||||
"jsdoc-to-markdown": "^7.1.0",
|
||||
"markdown-toc": "^1.2.0",
|
||||
"mocha": "^10.2.0",
|
||||
"nyc": "^15.1.0",
|
||||
"typescript": "^5.0.4"
|
||||
|
||||
Reference in New Issue
Block a user