Repository navigation
doc: move to redesign #66713
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
Open
avivkeller
wants to merge
3
commits into
nodejs:main
Choose a base branch
from
avivkeller:redesign
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+458
−475
Open
doc: move to redesign #66713
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,60 @@ | ||
| import * as common from '../common/index.mjs'; | ||
|
|
||
| import assert from 'assert'; | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
|
|
||
| if (common.isWindows) { | ||
| common.skip('`make doc` does not run on Windows'); | ||
| } | ||
|
|
||
| // This tests that `make doc` generates the documentation properly: an HTML | ||
| // page and a JSON file for every Markdown file under `doc/api`, and nothing | ||
| // for anything else. Note that for this test to pass, `make doc` must be run | ||
| // first. | ||
|
|
||
| const apiURL = new URL('../../out/doc/api/', import.meta.url); | ||
| const mdURL = new URL('../../doc/api/', import.meta.url); | ||
|
|
||
| // Kept in sync with `skip_apidoc_files` in the Makefile. | ||
| const skippedDocs = ['quic']; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/nodejs/node/pull/66613/changes does a better job of keeping this in sync by reading the Makefile directly. |
||
|
|
||
| const sources = fs.readdirSync(mdURL) | ||
| .filter((name) => path.extname(name) === '.md') | ||
| .map((name) => path.basename(name, '.md')); | ||
| const generated = fs.readdirSync(apiURL); | ||
|
|
||
| // These have no Markdown source of their own. | ||
| const expectedExtras = ['index.html', 'all.html', 'all.json']; | ||
| for (const name of expectedExtras) { | ||
| assert.ok(generated.includes(name), `${name} was not generated`); | ||
| } | ||
|
|
||
| for (const name of sources) { | ||
| for (const extension of ['.html', '.json']) { | ||
| const file = `${name}${extension}`; | ||
| if (skippedDocs.includes(name)) { | ||
| assert.ok(!generated.includes(file), `${file} was unexpectedly generated`); | ||
| continue; | ||
| } | ||
| assert.ok(generated.includes(file), `${file} was not generated`); | ||
| assert.notStrictEqual( | ||
| fs.statSync(new URL(`./${file}`, apiURL)).size, | ||
| 0, | ||
| `${file} is empty`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // Every generated page must come from a current Markdown file, so a stale | ||
| // `out/doc/api` (e.g. from a renamed document) is noticed. | ||
| const expectedPages = ['404.html', 'apilinks.json', ...expectedExtras]; | ||
| for (const name of generated) { | ||
| const extension = path.extname(name); | ||
| if (extension !== '.html' && extension !== '.json') continue; | ||
| if (expectedPages.includes(name)) continue; | ||
| assert.ok( | ||
| sources.includes(path.basename(name, extension)), | ||
| `Unexpected output: out/doc/api/${name}, remove and rerun.`, | ||
| ); | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,17 +1,22 @@ | ||
| import { join } from 'node:path'; | ||
| import { pathToFileURL } from 'node:url'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const root = new URL('../../', import.meta.url); | ||
|
|
||
| const fromRoot = (path) => | ||
| pathToFileURL(join(import.meta.dirname, '..', '..', path)).href; | ||
| fileURLToPath(new URL(path, root)).replaceAll('\\', '/'); | ||
|
|
||
| const urlFromRoot = (path) => new URL(path, root).href; | ||
|
|
||
| export default { | ||
| extends: '@node-core/doc-kit/config', | ||
|
|
||
| target: ['api-links'], | ||
|
|
||
| global: { | ||
| input: ['lib/*.js'], | ||
| input: [fromRoot('lib/*.js')], | ||
| output: fromRoot('out/doc'), | ||
|
|
||
| changelog: fromRoot('CHANGELOG.md'), | ||
| // Point every loadable URL at its local file so no network request is made. | ||
| changelog: urlFromRoot('CHANGELOG.md'), | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.