UNPKG

3.17 kBJavaScriptView Raw
1"use strict";
2// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3// See LICENSE in the project root for license information.
4var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5 if (k2 === undefined) k2 = k;
6 var desc = Object.getOwnPropertyDescriptor(m, k);
7 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8 desc = { enumerable: true, get: function() { return m[k]; } };
9 }
10 Object.defineProperty(o, k2, desc);
11}) : (function(o, m, k, k2) {
12 if (k2 === undefined) k2 = k;
13 o[k2] = m[k];
14}));
15var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16 Object.defineProperty(o, "default", { enumerable: true, value: v });
17}) : function(o, v) {
18 o["default"] = v;
19});
20var __importStar = (this && this.__importStar) || function (mod) {
21 if (mod && mod.__esModule) return mod;
22 var result = {};
23 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24 __setModuleDefault(result, mod);
25 return result;
26};
27var __importDefault = (this && this.__importDefault) || function (mod) {
28 return (mod && mod.__esModule) ? mod : { "default": mod };
29};
30Object.defineProperty(exports, "__esModule", { value: true });
31exports.DocumenterConfig = void 0;
32const path = __importStar(require("path"));
33const node_core_library_1 = require("@rushstack/node-core-library");
34const api_documenter_schema_json_1 = __importDefault(require("../schemas/api-documenter.schema.json"));
35/**
36 * Helper for loading the api-documenter.json file format. Later when the schema is more mature,
37 * this class will be used to represent the validated and normalized configuration, whereas `IConfigFile`
38 * represents the raw JSON file structure.
39 */
40class DocumenterConfig {
41 constructor(filePath, configFile) {
42 this.configFilePath = filePath;
43 this.configFile = configFile;
44 switch (configFile.newlineKind) {
45 case 'lf':
46 this.newlineKind = node_core_library_1.NewlineKind.Lf;
47 break;
48 case 'os':
49 this.newlineKind = node_core_library_1.NewlineKind.OsDefault;
50 break;
51 default:
52 this.newlineKind = node_core_library_1.NewlineKind.CrLf;
53 break;
54 }
55 }
56 /**
57 * Load and validate an api-documenter.json file.
58 */
59 static loadFile(configFilePath) {
60 const configFile = node_core_library_1.JsonFile.loadAndValidate(configFilePath, DocumenterConfig.jsonSchema);
61 return new DocumenterConfig(path.resolve(configFilePath), configFile);
62 }
63}
64/**
65 * The JSON Schema for API Documenter config file (api-documenter.schema.json).
66 */
67DocumenterConfig.jsonSchema = node_core_library_1.JsonSchema.fromLoadedObject(api_documenter_schema_json_1.default);
68/**
69 * The config file name "api-documenter.json".
70 */
71DocumenterConfig.FILENAME = 'api-documenter.json';
72exports.DocumenterConfig = DocumenterConfig;
73//# sourceMappingURL=DocumenterConfig.js.map
\No newline at end of file