Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: automate download node docs #696

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,389 changes: 0 additions & 1,389 deletions docs-nodejs/addons.html

This file was deleted.

1,322 changes: 0 additions & 1,322 deletions docs-nodejs/assert.html

This file was deleted.

755 changes: 0 additions & 755 deletions docs-nodejs/async_hooks.html

This file was deleted.

2,818 changes: 0 additions & 2,818 deletions docs-nodejs/buffer.html

This file was deleted.

1,549 changes: 0 additions & 1,549 deletions docs-nodejs/child_process.html

This file was deleted.

1,217 changes: 0 additions & 1,217 deletions docs-nodejs/cli.html

This file was deleted.

926 changes: 0 additions & 926 deletions docs-nodejs/cluster.html

This file was deleted.

687 changes: 0 additions & 687 deletions docs-nodejs/console.html

This file was deleted.

3,459 changes: 0 additions & 3,459 deletions docs-nodejs/crypto.html

This file was deleted.

320 changes: 0 additions & 320 deletions docs-nodejs/debugger.html

This file was deleted.

2,485 changes: 0 additions & 2,485 deletions docs-nodejs/deprecations.html

This file was deleted.

805 changes: 0 additions & 805 deletions docs-nodejs/dgram.html

This file was deleted.

1,505 changes: 0 additions & 1,505 deletions docs-nodejs/dns.html

This file was deleted.

563 changes: 0 additions & 563 deletions docs-nodejs/domain.html

This file was deleted.

2,168 changes: 0 additions & 2,168 deletions docs-nodejs/errors.html

This file was deleted.

1,137 changes: 0 additions & 1,137 deletions docs-nodejs/esm.html

This file was deleted.

792 changes: 0 additions & 792 deletions docs-nodejs/events.html

This file was deleted.

5,433 changes: 0 additions & 5,433 deletions docs-nodejs/fs.html

This file was deleted.

327 changes: 0 additions & 327 deletions docs-nodejs/globals.html

This file was deleted.

2,232 changes: 0 additions & 2,232 deletions docs-nodejs/http.html

This file was deleted.

3,482 changes: 0 additions & 3,482 deletions docs-nodejs/http2.html

This file was deleted.

539 changes: 0 additions & 539 deletions docs-nodejs/https.html

This file was deleted.

321 changes: 0 additions & 321 deletions docs-nodejs/inspector.html

This file was deleted.

394 changes: 0 additions & 394 deletions docs-nodejs/intl.html

This file was deleted.

990 changes: 0 additions & 990 deletions docs-nodejs/modules.html

This file was deleted.

4,728 changes: 0 additions & 4,728 deletions docs-nodejs/n-api.html

This file was deleted.

1,274 changes: 0 additions & 1,274 deletions docs-nodejs/net.html

This file was deleted.

1,448 changes: 0 additions & 1,448 deletions docs-nodejs/os.html

This file was deleted.

615 changes: 0 additions & 615 deletions docs-nodejs/path.html

This file was deleted.

766 changes: 0 additions & 766 deletions docs-nodejs/perf_hooks.html

This file was deleted.

281 changes: 0 additions & 281 deletions docs-nodejs/policy.html

This file was deleted.

2,302 changes: 0 additions & 2,302 deletions docs-nodejs/process.html

This file was deleted.

272 changes: 0 additions & 272 deletions docs-nodejs/punycode.html

This file was deleted.

282 changes: 0 additions & 282 deletions docs-nodejs/querystring.html

This file was deleted.

745 changes: 0 additions & 745 deletions docs-nodejs/readline.html

This file was deleted.

768 changes: 0 additions & 768 deletions docs-nodejs/repl.html

This file was deleted.

668 changes: 0 additions & 668 deletions docs-nodejs/report.html

This file was deleted.

2,662 changes: 0 additions & 2,662 deletions docs-nodejs/stream.html

This file was deleted.

220 changes: 0 additions & 220 deletions docs-nodejs/string_decoder.html

This file was deleted.

388 changes: 0 additions & 388 deletions docs-nodejs/timers.html

This file was deleted.

1,799 changes: 0 additions & 1,799 deletions docs-nodejs/tls.html

This file was deleted.

323 changes: 0 additions & 323 deletions docs-nodejs/tracing.html

This file was deleted.

432 changes: 0 additions & 432 deletions docs-nodejs/tty.html

This file was deleted.

1,357 changes: 0 additions & 1,357 deletions docs-nodejs/url.html

This file was deleted.

2,202 changes: 0 additions & 2,202 deletions docs-nodejs/util.html

This file was deleted.

621 changes: 0 additions & 621 deletions docs-nodejs/v8.html

This file was deleted.

1,308 changes: 0 additions & 1,308 deletions docs-nodejs/vm.html

This file was deleted.

746 changes: 0 additions & 746 deletions docs-nodejs/worker_threads.html

This file was deleted.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"through": "^2.3.8",
"through2": "^3.0.1",
"through2-map": "^3.0.0",
"website-scraper": "^4.2.0",
"workshopper-adventure": "^6.0.4",
"workshopper-exercise": "^3.0.1",
"workshopper-wrappedexec": "~0.1.3"
Expand All @@ -80,12 +81,19 @@
},
"scripts": {
"download-node-docs": "./tools/download-node-docs.sh",
"docs": "./tools/docs.js",
"lint": "./node_modules/.bin/standard",
"test": "npm run lint && ./node_modules/.bin/workshopper-adventure-test"
"test": "npm run lint && ./node_modules/.bin/workshopper-adventure-test",
"postinstall": "npm run docs"
},
"bin": {
"learnyounode": "./bin/learnyounode"
},
"main": "./learnyounode.js",
"preferGlobal": true
"preferGlobal": true,
"standard": {
"ignore": [
"docs-nodejs/"
]
}
}
26 changes: 26 additions & 0 deletions tools/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

const fs = require('fs')
const fsp = fs.promises
const scrape = require('website-scraper')
const rimraf = require('rimraf')
const scrapeDir = 'scrape'
const options = {
urls: ['https://nodejs.org/api/'],
filenameGenerator: 'bySiteStructure',
recursive: true,
maxRecursiveDepth: 1,
directory: scrapeDir
}

const main = async () => {
if (fs.existsSync(scrapeDir)) {
rimraf(scrapeDir, {}, () => {})
}
await scrape(options)
fsp.rename(`${scrapeDir}/nodejs.org/api`, 'docs-nodejs').then(() => {
rimraf(scrapeDir, {}, () => {})
})
}

main()