Skip to content

Commit 7e52dc0

Browse files
authored
refactor: split constants files (#232)
* refactor: split parser constants * refactor: split linter constants * refactor: split legacy-html constants * refactor: remove unused constants * refactor: split slugger constants * refactor: split man-page constants * refactor: split queries constants
1 parent c6e8099 commit 7e52dc0

File tree

20 files changed

+426
-440
lines changed

20 files changed

+426
-440
lines changed

src/constants.mjs

Lines changed: 0 additions & 420 deletions
Large diffs are not rendered by default.

src/generators/json-simple/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { join } from 'node:path';
55

66
import { remove } from 'unist-util-remove';
77

8-
import createQueries from '../../queries.mjs';
8+
import createQueries from '../../utils/queries/index.mjs';
99
import { getRemark } from '../../utils/remark.mjs';
1010

1111
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
// This is the Node.js Base URL for viewing a file within GitHub UI
4+
export const DOC_NODE_BLOB_BASE_URL =
5+
'https://github.com/nodejs/node/blob/HEAD/';
6+
7+
// This is the Node.js API docs base URL for editing a file on GitHub UI
8+
export const DOC_API_BLOB_EDIT_BASE_URL =
9+
'https://github.com/nodejs/node/edit/main/doc/api/';
10+
11+
// Base URL for a specific Node.js version within the Node.js API docs
12+
export const DOC_API_BASE_URL_VERSION = 'https://nodejs.org/docs/latest-v';

src/generators/legacy-html/utils/buildContent.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { SKIP, visit } from 'unist-util-visit';
66

77
import buildExtraContent from './buildExtraContent.mjs';
88

9-
import createQueries from '../../../queries.mjs';
9+
import createQueries from '../../../utils/queries/index.mjs';
1010

11-
import { DOC_NODE_BLOB_BASE_URL } from '../../../constants.mjs';
11+
import { DOC_NODE_BLOB_BASE_URL } from '../constants.mjs';
1212

1313
/**
1414
* Builds a Markdown heading for a given node

src/generators/legacy-html/utils/buildDropdowns.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import {
1111
DOC_API_BASE_URL_VERSION,
1212
DOC_API_BLOB_EDIT_BASE_URL,
13-
} from '../../../constants.mjs';
13+
} from '../constants.mjs';
1414

1515
/**
1616
* Builds the Dropdown for the current Table of Contents

src/generators/man-page/constants.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
// https://github.com/nodejs/node/blob/main/doc/api/cli.md#options
4+
// This slug should reference the section where the available
5+
// options are defined.
6+
export const DOC_SLUG_OPTIONS = 'options';
7+
8+
// https://github.com/nodejs/node/blob/main/doc/api/cli.md#environment-variables-1
9+
// This slug should reference the section where the available
10+
// environment variables are defined.
11+
export const DOC_SLUG_ENVIRONMENT = 'environment-variables-1';

src/generators/man-page/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
convertEnvVarToMandoc,
99
} from './utils/converter.mjs';
1010

11-
import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from '../../constants.mjs';
11+
import { DOC_SLUG_ENVIRONMENT, DOC_SLUG_OPTIONS } from './constants.mjs';
1212

1313
/**
1414
* This generator generates a man page version of the CLI.md file.

src/linter/constants.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
export const LINT_MESSAGES = {
4+
missingIntroducedIn: "Missing 'introduced_in' field in the API doc entry",
5+
missingChangeVersion: 'Missing version field in the API doc entry',
6+
invalidChangeVersion: 'Invalid version number: {{version}}',
7+
};

src/linter/rules/invalid-change-version.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LINT_MESSAGES } from '../../constants.mjs';
1+
import { LINT_MESSAGES } from '../constants.mjs';
22
import { valid } from 'semver';
33

44
/**

src/linter/rules/missing-introduced-in.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LINT_MESSAGES } from '../../constants.mjs';
1+
import { LINT_MESSAGES } from '../constants.mjs';
22

33
/**
44
* Checks if `introduced_in` field is missing

0 commit comments

Comments
 (0)