MCPcopy Create free account
hub / github.com/pytorch/pytorch / to_markdown

Function to_markdown

scripts/release_notes/commitlist.py:453–487  ·  view source on GitHub ↗
(commit_list: CommitList, category)

Source from the content-addressed store, hash-verified

451
452
453def to_markdown(commit_list: CommitList, category):
454 def cleanup_title(commit):
455 match = re.match(r"(.*) \(#\d+\)", commit.title)
456 if match is None:
457 return commit.title
458 return match.group(1)
459
460 merge_mapping = defaultdict(list)
461 for commit in commit_list.commits:
462 if commit.merge_into:
463 merge_mapping[commit.merge_into].append(commit)
464
465 cdc = get_commit_data_cache()
466 lines = [f"\n## {category}\n"]
467 for topic in topics:
468 lines.append(f"### {topic}\n")
469 commits = commit_list.filter(category=category, topic=topic)
470 if "_" in topic:
471 commits.extend(
472 commit_list.filter(category=category, topic=topic.replace("_", " "))
473 )
474 if " " in topic:
475 commits.extend(
476 commit_list.filter(category=category, topic=topic.replace(" ", "_"))
477 )
478 for commit in commits:
479 if commit.merge_into:
480 continue
481 all_related_commits = merge_mapping[commit.commit_hash] + [commit]
482 commit_list_md = ", ".join(
483 get_hash_or_pr_url(c) for c in all_related_commits
484 )
485 result = f"- {cleanup_title(commit)} ({commit_list_md})\n"
486 lines.append(result)
487 return lines
488
489
490def get_markdown_header(category):

Callers 1

mainFunction · 0.85

Calls 8

get_commit_data_cacheFunction · 0.90
get_hash_or_pr_urlFunction · 0.85
cleanup_titleFunction · 0.85
appendMethod · 0.45
filterMethod · 0.45
extendMethod · 0.45
replaceMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…