Skip to content

Commit 2530016

Browse files
authored
revert(cfnspec): add CloudFormation documentation to L1 classes (#18177)
This reverts commit 0ed661d. Its currently failing our pipeline with: ```console #STDOUT> [INFO] Total time: 08:11 min -- 958 | #STDOUT> [INFO] Finished at: 2021-12-25T02:10:45Z 959 | #STDOUT> [INFO] ------------------------------------------------------------------------ 960 | #STDOUT> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project lex: Compilation failure: Compilation failure: 961 | #STDOUT> [ERROR] /tmp/npm-packDT4j4g/_aws-cdk_aws-lex/src/main/java/software/amazon/awscdk/services/lex/CfnBot.java:[11584,39] illegal unicode escape 962 | #STDOUT> [ERROR] /tmp/npm-packDT4j4g/_aws-cdk_aws-lex/src/main/java/software/amazon/awscdk/services/lex/CfnBot.java:[13,1] illegal unicode escape 963 | #STDOUT> [ERROR] /tmp/npm-packDT4j4g/_aws-cdk_aws-lex/src/main/java/software/amazon/awscdk/services/lex/CfnBot.java:[11621,58] illegal unicode escape 964 | #STDOUT> [ERROR] /tmp/npm-packDT4j4g/_aws-cdk_aws-lex/src/main/java/software/amazon/awscdk/services/lex/CfnBot.java:[17,32] illegal unicode escape ``` Looks like the docs are adding some illegal characters. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 17fc011 commit 2530016

File tree

6 files changed

+11
-102
lines changed

6 files changed

+11
-102
lines changed

packages/@aws-cdk/cfnspec/build-tools/build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ async function main() {
1717

1818
await generateResourceSpecification(inputDir, path.join(outDir, 'specification.json'));
1919
await mergeSpecificationFromDirs(path.join(inputDir, 'cfn-lint'), path.join(outDir, 'cfn-lint.json'));
20-
await fs.copyFile(path.join(inputDir, 'cfn-docs', 'cfn-docs.json'), path.join(outDir, 'cfn-docs.json'));
2120
}
2221

2322
/**

packages/@aws-cdk/cfnspec/lib/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ export function specification(): schema.Specification {
1212
return require('../spec/specification.json');
1313
}
1414

15-
/**
16-
* The complete AWS CloudFormation Resource specification, having any CDK patches and enhancements included in it.
17-
*/
18-
export function docs(): schema.CloudFormationDocsFile {
19-
// eslint-disable-next-line @typescript-eslint/no-require-imports
20-
return require('../spec/cfn-docs.json');
21-
}
22-
23-
2415
/**
2516
* Return the resource specification for the given typename
2617
*
@@ -35,21 +26,6 @@ export function resourceSpecification(typeName: string): schema.ResourceType {
3526
return ret;
3627
}
3728

38-
/**
39-
* Return documentation for the given type
40-
*/
41-
export function typeDocs(resourceName: string, propertyTypeName?: string): schema.CloudFormationTypeDocs {
42-
const key = propertyTypeName ? `${resourceName}.${propertyTypeName}` : resourceName;
43-
const ret = docs().Types[key];
44-
if (!ret) {
45-
return {
46-
description: '',
47-
properties: {},
48-
};
49-
}
50-
return ret;
51-
}
52-
5329
/**
5430
* Get the resource augmentations for a given type
5531
*/

packages/@aws-cdk/cfnspec/lib/schema/docs.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/@aws-cdk/cfnspec/lib/schema/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export * from './resource-type';
44
export * from './specification';
55
export * from './augmentation';
66
export * from './cfn-lint';
7-
export * from './docs';

packages/@aws-cdk/cfnspec/test/docs.test.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/@aws-cdk/cfn2ts/lib/codegen.ts

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { schema, cfnLintAnnotations, typeDocs } from '@aws-cdk/cfnspec';
1+
import { schema, cfnLintAnnotations } from '@aws-cdk/cfnspec';
22
import { CodeMaker } from 'codemaker';
33
import * as genspec from './genspec';
44
import { itemTypeNames, PropertyAttributeName, scalarTypeNames, SpecName } from './spec-utils';
@@ -115,7 +115,7 @@ export default class CodeGenerator {
115115
const name = genspec.CodeName.forResourceProperties(resourceContext);
116116

117117
this.docLink(spec.Documentation,
118-
`Properties for defining a \`${resourceContext.className}\``,
118+
`Properties for defining a \`${resourceContext.specName!.fqn}\``,
119119
'',
120120
'@stability external');
121121
this.code.openBlock(`export interface ${name.className}`);
@@ -144,17 +144,15 @@ export default class CodeGenerator {
144144
container: Container): Dictionary<string> {
145145
const propertyMap: Dictionary<string> = {};
146146

147-
const docs = typeDocs(resource.specName?.fqn ?? '');
148-
149147
Object.keys(propertiesSpec).sort(propertyComparator).forEach(propName => {
150148
this.code.line();
151149
const propSpec = propertiesSpec[propName];
152-
const additionalDocs = docs.properties[propName] || quoteCode(resource.specName!.relativeName(propName).fqn);
150+
const additionalDocs = resource.specName!.relativeName(propName).fqn;
153151
const newName = this.emitProperty({
154152
context: resource,
155153
propName,
156154
spec: propSpec,
157-
additionalDocs,
155+
additionalDocs: quoteCode(additionalDocs),
158156
},
159157
container,
160158
);
@@ -194,20 +192,15 @@ export default class CodeGenerator {
194192
this.code.line();
195193
}
196194

197-
const docs = typeDocs(cfnName);
198-
199195
//
200196
// The class declaration representing this Resource
201197
//
202198

203-
this.docLink(spec.Documentation, ...[
199+
this.docLink(spec.Documentation,
204200
`A CloudFormation \`${cfnName}\``,
205201
'',
206-
...docs.description.split('\n'),
207-
'',
208202
`@cloudformationResource ${cfnName}`,
209-
'@stability external',
210-
]);
203+
'@stability external');
211204
this.openClass(resourceName, RESOURCE_BASE_CLASS);
212205

213206
//
@@ -278,9 +271,7 @@ export default class CodeGenerator {
278271

279272
this.code.line();
280273

281-
this.docLink(undefined,
282-
docs.attributes?.[attributeName] ?? '',
283-
`@cloudformationAttribute ${attributeName}`);
274+
this.docLink(undefined, `@cloudformationAttribute ${attributeName}`);
284275
const attr = genspec.attributeDefinition(attributeName, attributeSpec);
285276

286277
this.code.line(`public readonly ${attr.propertyName}: ${attr.attributeType};`);
@@ -856,25 +847,18 @@ export default class CodeGenerator {
856847
this.code.line();
857848
this.beginNamespace(typeName);
858849

859-
const docs = typeDocs(resourceContext.specName?.fqn ?? '', (typeName.specName as PropertyAttributeName | undefined)?.propAttrName);
860-
861-
this.docLink(
862-
propTypeSpec.Documentation,
863-
docs.description,
864-
'@stability external',
865-
);
850+
this.docLink(propTypeSpec.Documentation, '@stability external');
866851
/*
867852
if (!propTypeSpec.Properties || Object.keys(propTypeSpec.Properties).length === 0) {
868853
this.code.line('// eslint-disable-next-line somethingsomething | A genuine empty-object type');
869854
}
870855
*/
871856
this.code.openBlock(`export interface ${typeName.className}`);
872857
const conversionTable: Dictionary<string> = {};
873-
874858
if (propTypeSpec.Properties) {
875859
Object.keys(propTypeSpec.Properties).forEach(propName => {
876860
const propSpec = propTypeSpec.Properties[propName];
877-
const additionalDocs = docs.properties[propName] || quoteCode(`${typeName.fqn}.${propName}`);
861+
const additionalDocs = quoteCode(`${typeName.fqn}.${propName}`);
878862
const newName = this.emitInterfaceProperty({
879863
context: resourceContext,
880864
propName,
@@ -966,23 +950,12 @@ export default class CodeGenerator {
966950
private docLink(link: string | undefined, ...before: string[]): void {
967951
if (!link && before.length === 0) { return; }
968952
this.code.line('/**');
969-
before.flatMap(x => x.split('\n')).forEach(line => this.code.line(` * ${escapeDocText(line)}`.trimRight()));
953+
before.forEach(line => this.code.line(` * ${line}`.trimRight()));
970954
if (link) {
971-
if (before.length > 0) {
972-
this.code.line(' *');
973-
}
974955
this.code.line(` * @link ${link}`);
975956
}
976957
this.code.line(' */');
977-
978-
/**
979-
* If '* /' occurs literally somewhere in the doc text, it will break the docstring parsing.
980-
*
981-
* Break up those characters by inserting a zero-width space.
982-
*/
983-
function escapeDocText(x: string) {
984-
return x.replace(/\*\//g, '*\u200b/');
985-
}
958+
return;
986959
}
987960
}
988961

0 commit comments

Comments
 (0)