From e6a0d4f7f09bab7a98979e0fe250945c0a841d3c Mon Sep 17 00:00:00 2001 From: martina-equinix Date: Tue, 3 Sep 2024 11:35:10 +0200 Subject: [PATCH 1/2] Support mapping custom tags in mkdocs yaml parser (techdocs) Signed-off-by: martina-equinix --- .../generate/__fixtures__/mkdocs_with_extensions.yml | 7 ++++++- plugins/techdocs-node/src/stages/generate/helpers.test.ts | 4 ++++ plugins/techdocs-node/src/stages/generate/helpers.ts | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_extensions.yml b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_extensions.yml index d6c6858722..d1209d0c21 100644 --- a/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_extensions.yml +++ b/plugins/techdocs-node/src/stages/generate/__fixtures__/mkdocs_with_extensions.yml @@ -4,4 +4,9 @@ site_description: Test site description markdown_extensions: - pymdownx.emoji: emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_generator: !!python/object.apply:materialx.emoji.to_svg + - pymdownx.tabbed: + alternate_style: true + slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 755cd9d1a6..af61dae936 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -247,6 +247,10 @@ describe('helpers', () => { expect(updatedMkdocsYml.toString()).toContain( "emoji_index: !!python/name:materialx.emoji.twemoji ''", ); + expect(updatedMkdocsYml.toString()).toContain( + 'slugify: !!python/object/apply:pymdownx.slugs.slugify', + ); + expect(updatedMkdocsYml.toString()).toContain('case: lower'); }); it('should not override existing repo_url in mkdocs.yml', async () => { diff --git a/plugins/techdocs-node/src/stages/generate/helpers.ts b/plugins/techdocs-node/src/stages/generate/helpers.ts index d62b6dcccd..0cba56cfa5 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.ts @@ -141,6 +141,14 @@ export const MKDOCS_SCHEMA = DEFAULT_SCHEMA.extend([ instanceOf: UnknownTag, construct: (data: string, type?: string) => new UnknownTag(data, type), }), + new Type('tag:', { + kind: 'mapping', + 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), + }), new Type('', { kind: 'sequence', multi: true, From 57da51fa0fe2c1b2df0d90abe7d7a11f35ae9d92 Mon Sep 17 00:00:00 2001 From: martina-equinix Date: Tue, 3 Sep 2024 11:38:56 +0200 Subject: [PATCH 2/2] Add changeset Signed-off-by: martina-equinix --- .changeset/long-peas-repeat.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/long-peas-repeat.md diff --git a/.changeset/long-peas-repeat.md b/.changeset/long-peas-repeat.md new file mode 100644 index 0000000000..1ea65056b4 --- /dev/null +++ b/.changeset/long-peas-repeat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-node': patch +--- + +Add support for mapping custom tags in the techdocs yaml parser that validates the mkdocs.yaml file