From 5c7ce56b60a09b4eeb4b0210368756e9ba17b4f0 Mon Sep 17 00:00:00 2001 From: Rico Huijbers Date: Tue, 21 Nov 2023 14:18:17 +0100 Subject: [PATCH] Undo deprecation, make tests not warn --- src/cli.ts | 2 +- src/docgen/view/documentation.ts | 17 +++++------------ test/docgen/transpile/transpile.test.ts | 8 ++++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index f30673ad..34717152 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -41,7 +41,7 @@ async function generateForLanguage(docs: Documentation, options: GenerateOptions for (const submodule of submodules) { const content = await docs.toMarkdown({ ...options, - submoduleFqn: submodule.fqn, + submodule: submodule.fqn, allSubmodules: false, header: { title: `\`${submoduleRelName(submodule)}\` Submodule`, id: submodule.fqn }, }); diff --git a/src/docgen/view/documentation.ts b/src/docgen/view/documentation.ts index 87df5fb1..54ac805a 100644 --- a/src/docgen/view/documentation.ts +++ b/src/docgen/view/documentation.ts @@ -50,17 +50,9 @@ export interface RenderOptions extends TransliterationOptions { * Generate documentation only for a specific submodule. * * @default - Documentation is generated for the root module only. - * @deprecated Prefer `submoduleFqn`. */ readonly submodule?: string; - /** - * Generate documentation only for a specific submodule, identified by its FQN - * - * @default - Documentation is generated for the root module only. - */ - readonly submoduleFqn?: string; - /** * Generate a single document with APIs from all assembly submodules * (including the root). @@ -242,10 +234,7 @@ export class Documentation { throw new LanguageNotSupportedError(`Laguage ${language} is not supported for package ${this.assemblyFqn}`); } - if (options?.submoduleFqn && options.submoduleFqn) { - throw new Error('Supply at most one of \'submodule\' and \'submoduleFqn\''); - } - let submoduleStr = options.submoduleFqn ?? options.submodule; + let submoduleStr = options.submodule; if (allSubmodules && submoduleStr) { throw new Error('Cannot call toJson with allSubmodules and a specific submodule both selected.'); @@ -339,6 +328,10 @@ export class Documentation { * root-relative submodule name as well (`sub1.sub2`). */ private findSubmodule(assembly: reflect.Assembly, submodule: string): reflect.Submodule { + // If 'submodule' does not have a '.' in it, we know exactly what is intended. + + + const fqnSubs = assembly.allSubmodules.filter( (s) => s.fqn === submodule, ); diff --git a/test/docgen/transpile/transpile.test.ts b/test/docgen/transpile/transpile.test.ts index 92f61882..4c8f5ece 100644 --- a/test/docgen/transpile/transpile.test.ts +++ b/test/docgen/transpile/transpile.test.ts @@ -58,26 +58,26 @@ describe('submodules without an explicit name', () => { test('java', async () => { const docs = await Documentation.forAssembly('@aws-cdk/aws-cloudfront', Assemblies.AWSCDK_1_126_0); - const markdown = await docs.toMarkdown({ language: Language.JAVA, submodule: 'experimental' }); + const markdown = await docs.toMarkdown({ language: Language.JAVA, submodule: '@aws-cdk/aws-cloudfront.experimental' }); expect(markdown.render()).toMatchSnapshot(); }); test('python', async () => { const docs = await Documentation.forAssembly('@aws-cdk/aws-cloudfront', Assemblies.AWSCDK_1_126_0); - const markdown = await docs.toMarkdown({ language: Language.PYTHON, submodule: 'experimental' }); + const markdown = await docs.toMarkdown({ language: Language.PYTHON, submodule: '@aws-cdk/aws-cloudfront.experimental' }); expect(markdown.render()).toMatchSnapshot(); }); test('csharp', async () => { const docs = await Documentation.forAssembly('@aws-cdk/aws-cloudfront', Assemblies.AWSCDK_1_126_0); - const markdown = await docs.toMarkdown({ language: Language.CSHARP, submodule: 'experimental' }); + const markdown = await docs.toMarkdown({ language: Language.CSHARP, submodule: '@aws-cdk/aws-cloudfront.experimental' }); expect(markdown.render()).toMatchSnapshot(); }); test('go', async () => { // NOTE: @aws-cdk/aws-cloudfront 1.126.0 does not support Go, so we use region_info from aws-cdk-lib instead, which does. const docs = await Documentation.forAssembly('aws-cdk-lib', Assemblies.AWSCDK_1_106_0); - const markdown = await docs.toMarkdown({ language: Language.GO, submodule: 'region_info' }); + const markdown = await docs.toMarkdown({ language: Language.GO, submodule: 'aws-cdk-lib.region_info' }); expect(markdown.render()).toMatchSnapshot(); }); });