Skip to content

Commit cae36e8

Browse files
committed
Replace "tsdocVersion" with "$schema"
1 parent 7db88ef commit cae36e8

File tree

10 files changed

+40
-19
lines changed

10 files changed

+40
-19
lines changed

tsdoc-config/src/ConfigLoader.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ interface IPackageJson {
1111
tsdocConfig?: string;
1212
}
1313

14+
/**
15+
* Use this class to load the `tsdoc-config.json` file.
16+
* @public
17+
*/
1418
export class ConfigLoader {
1519
public static readonly JSON_FILE_NAME: string = 'tsdoc-config.json';
1620

@@ -74,6 +78,6 @@ export class ConfigLoader {
7478
return undefined;
7579
}
7680

77-
return TSDocConfigFile.load(rootConfigFilePath);
81+
return TSDocConfigFile.loadFromFile(rootConfigFilePath);
7882
}
7983
}

tsdoc-config/src/TSDocConfigFile.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,38 @@ interface ITagConfigJson {
2525
}
2626

2727
interface IConfigJson {
28+
$schema: string;
2829
tsdocVersion: string;
2930
extends?: string[];
3031
tagDefinitions: ITagConfigJson[];
3132
}
3233

34+
/**
35+
* Represents an individual `tsdoc-config.json` file.
36+
*
37+
* @public
38+
*/
3339
export class TSDocConfigFile {
34-
40+
/**
41+
* The full path of the file.
42+
*/
3543
public readonly filePath: string;
3644

37-
public readonly tsdocVersion: string;
45+
/**
46+
* The `$schema` field from the `tsdoc-config.json` file.
47+
*/
48+
public readonly tsdocSchema: string;
3849

50+
/**
51+
* Module paths for other config files that this file extends from.
52+
*/
3953
public readonly extends: ReadonlyArray<string>;
4054

4155
public readonly tagDefinitions: ReadonlyArray<TSDocTagDefinition>;
4256

4357
private constructor(filePath: string, configJson: IConfigJson) {
4458
this.filePath = filePath;
45-
this.tsdocVersion = configJson.tsdocVersion;
59+
this.tsdocSchema = configJson.$schema;
4660
this.extends = configJson.extends || [];
4761
const tagDefinitions: TSDocTagDefinition[] = [];
4862

@@ -66,7 +80,16 @@ export class TSDocConfigFile {
6680
this.tagDefinitions = tagDefinitions;
6781
}
6882

69-
public static load(jsonFilePath: string): TSDocConfigFile {
83+
/**
84+
* Loads the contents of a single JSON input file.
85+
*
86+
* @remarks
87+
*
88+
* This method does not process the `extends` field of `tsdoc-config.json`.
89+
* For full functionality, including discovery of the file path, use the {@link ConfigLoader}
90+
* API instead.
91+
*/
92+
public static loadFromFile(jsonFilePath: string): TSDocConfigFile {
7093
const fullJsonFilePath: string = path.resolve(jsonFilePath);
7194

7295
const configJsonContent: string = fs.readFileSync(fullJsonFilePath).toString();

tsdoc-config/src/__tests__/ConfigLoader.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test('Load p5', () => {
7171
"tagNameWithUpperCase": "@MYMODIFIERTAG",
7272
},
7373
],
74-
"tsdocVersion": "0.12",
74+
"tsdocSchema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json",
7575
}
7676
`
7777
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tsdocVersion": "0.12"
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json"
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tsdocVersion": "0.12"
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json"
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tsdocVersion": "0.12"
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json"
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"tsdocVersion": "0.12"
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json"
33
}

tsdoc-config/src/__tests__/assets/p5/tsdoc-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/tsdoc-config.schema.json",
3-
"tsdocVersion": "0.12",
2+
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v1/tsdoc-config.schema.json",
43
"extends": [],
54
"tagDefinitions": [
65
{

tsdoc-config/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { TSDocConfigFile } from './TSDocConfigFile';
2+
export { ConfigLoader } from './ConfigLoader';

tsdoc-config/src/schemas/tsdoc-config.schema.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
"type": "string"
99
},
1010

11-
"tsdocVersion": {
12-
"description": "The target version of the TSDoc spec",
13-
"type": "string",
14-
"pattern": "^[0-9]+\\.[0-9]+$"
15-
},
16-
1711
"extends": {
1812
"description": "Optionally specifies another JSON config files that this file extends from. This provides a way for standard settings to be shared across multiple projects.",
1913
"type": "array",
@@ -30,7 +24,7 @@
3024
}
3125
}
3226
},
33-
"required": [ "tsdocVersion" ],
27+
"required": [ "$schema" ],
3428
"additionalProperties": false,
3529

3630
"definitions": {

0 commit comments

Comments
 (0)