|
18 | 18 |
|
19 | 19 | import argparse
|
20 | 20 | import fileinput
|
| 21 | +import os |
21 | 22 | import pathlib
|
22 | 23 | import re
|
23 | 24 |
|
@@ -64,7 +65,40 @@ def main(args):
|
64 | 65 |
|
65 | 66 | print(line, end="")
|
66 | 67 |
|
67 |
| - # TODO(scotttodd): replace [TOC] with \n[TOC] as needed (transform ops) |
| 68 | + # Add explicit custom_edit_url links as these markdown files were generated |
| 69 | + # from other source files. |
| 70 | + dialect_sources_map = { |
| 71 | + "Check.md": "compiler/src/iree/compiler/Modules/Check/IR", |
| 72 | + "Flow.md": "compiler/src/iree/compiler/Dialect/Flow/IR", |
| 73 | + "HAL.md": "compiler/src/iree/compiler/Dialect/HAL/IR", |
| 74 | + "HALInline.md": "compiler/src/iree/compiler/Modules/HAL/Inline/IR", |
| 75 | + "HALLoader.md": "compiler/src/iree/compiler/Modules/HAL/Loader/IR", |
| 76 | + "IOParameters.md": "compiler/src/iree/compiler/Modules/IO/Parameters/IR", |
| 77 | + "IREEInput.md": "llvm-external-projects/iree-dialects/include/iree-dialects/Dialect/Input", |
| 78 | + "IREELinalgExt.md": "llvm-external-projects/iree-dialects/include/iree-dialects/Dialect/LinalgExt/IR", |
| 79 | + "IREEVectorExt.md": "llvm-external-projects/iree-dialects/include/iree-dialects/Dialect/VectorExt/IR", |
| 80 | + "Stream.md": "compiler/src/iree/compiler/Dialect/Stream/IR", |
| 81 | + "Util.md": "compiler/src/iree/compiler/Dialect/Util/IR", |
| 82 | + "VM.md": "compiler/src/iree/compiler/Dialect/VM/IR", |
| 83 | + "VMVX.md": "compiler/src/iree/compiler/Dialect/VMVX/IR", |
| 84 | + } |
| 85 | + base_url = "https://github.com/openxla/iree/tree/main/" |
| 86 | + for file in files: |
| 87 | + filename = pathlib.Path(file).name |
| 88 | + relative_path = dialect_sources_map.get(filename, None) |
| 89 | + if not relative_path: |
| 90 | + print("Warning: missing dialect source path for '%s'" % filename) |
| 91 | + continue |
| 92 | + |
| 93 | + full_url = base_url + relative_path |
| 94 | + with open(file, "r+") as f: |
| 95 | + content = f.read() |
| 96 | + f.seek(0, 0) |
| 97 | + frontmatter = f"""--- |
| 98 | +custom_edit_url: {full_url} |
| 99 | +--- |
| 100 | +""" |
| 101 | + f.write(frontmatter + os.linesep + content) |
68 | 102 |
|
69 | 103 |
|
70 | 104 | def parse_arguments():
|
|
0 commit comments