diff --git a/.changeset/techdocs-nice-boats-wonder.md b/.changeset/techdocs-nice-boats-wonder.md new file mode 100644 index 0000000000..434cde841e --- /dev/null +++ b/.changeset/techdocs-nice-boats-wonder.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Allow usage of custom tags with sequence node type (such as the !ENV tag) in the techdocs mkdocs config. diff --git a/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml new file mode 100644 index 0000000000..cba0cd8373 --- /dev/null +++ b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_env_tag.yml @@ -0,0 +1 @@ +site_name: !ENV [SITE_NAME, OTHER_NAME, 'My default site name'] diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 7590df94fb..f45f6034ec 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -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(); + }); }); }); diff --git a/plugins/techdocs-node/src/stages/generate/helpers.ts b/plugins/techdocs-node/src/stages/generate/helpers.ts index 349783d2bd..d70793e043 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.ts @@ -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), + }), ]); /**