Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bin/parse_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ def remove_first_line(s: str) -> str:
return s.split("\n", 1)[1]


def convert_to_full_path(description: str) -> str:
pattern = re.compile("\(([#\.a-zA-Z0-9_-]+)\)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can move it to constant to avoid repeat compile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give it a name to explain what we are trying to match?

matched_content = pattern.findall(description)

for path in matched_content:
if "https://docs.aws.amazon.com/" not in path:
url = path.split(".")[0] + ".html"
if "#" in path:
url += "#" + path.split("#")[1]
description = description.replace(
path, f"https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/{url}"
)
return description


def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("dir", type=Path)
Expand All @@ -48,6 +63,7 @@ def main() -> None:
props[path.stem] = {}
description = remove_first_line(description) # Remove property name; already in the schema title
description = fix_markdown_code_link(description)
description = convert_to_full_path(description)
props[path.stem][name] = description

print(
Expand Down
Loading