Merge pull request #10846 from TierMobility/master
[TechDocs] Accept sequence node custom tags in mkdocs config validation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
site_name: !ENV [SITE_NAME, OTHER_NAME, 'My default site name']
|
||||
@@ -78,6 +78,9 @@ const mkdocsYmlWithoutPlugins = fs.readFileSync(
|
||||
const mkdocsYmlWithAdditionalPlugins = fs.readFileSync(
|
||||
resolvePath(__filename, '../__fixtures__/mkdocs_with_additional_plugins.yml'),
|
||||
);
|
||||
const mkdocsYmlWithEnvTag = fs.readFileSync(
|
||||
resolvePath(__filename, '../__fixtures__/mkdocs_with_env_tag.yml'),
|
||||
);
|
||||
const mockLogger = getVoidLogger();
|
||||
const warn = jest.spyOn(mockLogger, 'warn');
|
||||
|
||||
@@ -582,10 +585,16 @@ describe('helpers', () => {
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('should validate files with custom yaml tags', async () => {
|
||||
it('should validate files with custom yaml tags (scalar)', async () => {
|
||||
await expect(
|
||||
validateMkdocsYaml(inputDir, mkdocsYmlWithExtensions.toString()),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should validate files with custom yaml tags (sequence)', async () => {
|
||||
await expect(
|
||||
validateMkdocsYaml(inputDir, mkdocsYmlWithEnvTag.toString()),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -134,6 +134,14 @@ export const MKDOCS_SCHEMA = DEFAULT_SCHEMA.extend([
|
||||
instanceOf: UnknownTag,
|
||||
construct: (data: string, type?: string) => new UnknownTag(data, type),
|
||||
}),
|
||||
new Type('', {
|
||||
kind: 'sequence',
|
||||
multi: true,
|
||||
representName: o => (o as UnknownTag).type,
|
||||
represent: o => (o as UnknownTag).data ?? '',
|
||||
instanceOf: UnknownTag,
|
||||
construct: (data: string, type?: string) => new UnknownTag(data, type),
|
||||
}),
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user