Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use auto-generated CFN docs from CDK #3219

Merged
merged 13 commits into from
Jun 27, 2023
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ fetch-schema-data:
rm -rf .tmp/aws-sam-developer-guide
git clone --branch main --depth 1 https://github.com/awsdocs/aws-sam-developer-guide.git .tmp/aws-sam-developer-guide

rm -rf .tmp/aws-cloudformation-user-guide
git clone --depth 1 https://github.com/awsdocs/aws-cloudformation-user-guide.git .tmp/aws-cloudformation-user-guide
curl -o .tmp/cfn-docs.json https://raw.githubusercontent.com/aws/aws-cdk/main/packages/%40aws-cdk/cfnspec/spec-source/cfn-docs/cfn-docs.json

curl -o .tmp/cloudformation.schema.json https://raw.githubusercontent.com/awslabs/goformation/master/schema/cloudformation.schema.json

update-schema-data:
# Parse docs
bin/parse_docs.py .tmp/aws-sam-developer-guide/doc_source > samtranslator/internal/schema_source/sam-docs.json
bin/parse_docs.py --cfn .tmp/aws-cloudformation-user-guide/doc_source > schema_source/cloudformation-docs.json
bin/parse_cdk_cfn_docs.py < .tmp/cfn-docs.json > schema_source/cloudformation-docs.json

# Add CloudFormation docs to CloudFormation schema
python bin/add_docs_cfn_schema.py --schema .tmp/cloudformation.schema.json --docs schema_source/cloudformation-docs.json > schema_source/cloudformation.schema.json
Expand Down
30 changes: 30 additions & 0 deletions bin/parse_cdk_cfn_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
"""
Converts docs JSON from this format:
https://github.com/aws/aws-cdk/blob/ad89f0182e218eee01b0aef84b055a96556dda59/packages/%40aws-cdk/cfnspec/spec-source/cfn-docs/cfn-docs.json
To this format:
https://github.com/aws/serverless-application-model/blob/237c7394c6e7ab61c1fad27f439a7b52bcd1b5af/schema_source/cloudformation-docs.json
Originally used https://github.com/awsdocs/aws-cloudformation-user-guide, but switched since retired.
See https://aws.amazon.com/blogs/aws/retiring-the-aws-documentation-on-github/
Expects input from stdin; outputs to stdout.
"""

import json
import sys
from typing import Any, Dict


def main() -> None:
obj = json.load(sys.stdin)

out: Dict[str, Any] = {"properties": {}}
for k, v in obj["Types"].items():
kk = k.replace(".", " ")
vv = v["properties"]
out["properties"][kk] = vv

print(json.dumps(out, indent=2, sort_keys=True))


if __name__ == "__main__":
main()
Loading