Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffa committed Jun 20, 2023
1 parent e8048fd commit 183504a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fetch-schema-data:
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_cdk_cfn_docs.py --docs .tmp/cfn-docs.json > 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
29 changes: 7 additions & 22 deletions bin/parse_cdk_cfn_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,25 @@
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 argparse
import json
from pathlib import Path
import sys
from typing import Any, Dict


def convert(obj: Dict[str, Any]) -> Dict[str, Any]:
out = {
"properties": {},
}
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

return out


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--docs", type=Path, required=True)
args = parser.parse_args()

obj = json.loads(args.docs.read_text())
print(
json.dumps(
convert(obj),
indent=2,
sort_keys=True,
)
)
print(json.dumps(out, indent=2, sort_keys=True))


if __name__ == "__main__":
Expand Down

0 comments on commit 183504a

Please sign in to comment.