Skip to content

Commit

Permalink
Undo deprecation, make tests not warn
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Nov 21, 2023
1 parent 5cdb7e0 commit 5c7ce56
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
Expand Down
17 changes: 5 additions & 12 deletions src/docgen/view/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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.');
Expand Down Expand Up @@ -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,
);
Expand Down
8 changes: 4 additions & 4 deletions test/docgen/transpile/transpile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

0 comments on commit 5c7ce56

Please sign in to comment.