|
63 | 63 | source_suffix = ['.md'] |
64 | 64 |
|
65 | 65 | # The master toctree document. |
66 | | -master_doc = 'index' |
| 66 | +master_doc = 'index2.md' |
67 | 67 |
|
68 | 68 | # List of patterns, relative to source directory, that match files and |
69 | 69 | # directories to ignore when looking for source files. |
|
77 | 77 | 'README.md', |
78 | 78 | 'docs/releases/PostAlpha2.1BranchMethodology.md', |
79 | 79 | 'main', |
| 80 | + 'index.md' |
80 | 81 | ] |
81 | 82 |
|
82 | 83 | # The name of the Pygments (syntax highlighting) style to use. |
@@ -151,20 +152,55 @@ def setup(app): |
151 | 152 | shutil.copy('../README.md', 'mainREADME.md') |
152 | 153 | swap_prefix('mainREADME.md', '```mermaid', '```{mermaid}\n:align: center\n') |
153 | 154 |
|
154 | | - # Get GitGuide file |
| 155 | + # Grab the reference file from OR |
155 | 156 | url = 'https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/docs/contrib/GitGuide.md' |
156 | 157 | get_file_from_url(url, 'contrib/GitGuide.md') |
| 158 | + |
| 159 | + # Temporarily using commit number, will change once OR commit merged. |
| 160 | + url = 'https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/3563176d00daeb613eed2ccf9442137b0ae2cad3/docs/index.md' |
| 161 | + get_file_from_url(url, 'SupportedOS.md') |
157 | 162 |
|
158 | 163 | # edit OpenROAD to OpenROAD-flow-scripts for GitGuide |
159 | 164 | with open('contrib/GitGuide.md', 'r') as f: |
160 | 165 | content = f.read() |
161 | | - |
162 | 166 | content = content.replace('user/Build.md', '../index.md#build-or-installing-orfs-dependencies') |
163 | 167 | content = content.replace('OpenROAD', 'OpenROAD-flow-scripts') |
164 | 168 | content = content.replace('The-OpenROAD-flow-scripts', 'The-OpenROAD') |
165 | 169 | with open('contrib/GitGuide.md', 'w') as f: |
166 | 170 | f.write(content) |
167 | 171 |
|
| 172 | + # Create a copy of the index.md file |
| 173 | + import shutil |
| 174 | + shutil.copy('index.md', 'index2.md') |
| 175 | + |
| 176 | + # Use re to find the desired content |
| 177 | + start_pattern = '## Supported Operating Systems' |
| 178 | + end_pattern = '## Code of conduct' |
| 179 | + with open('SupportedOS.md', 'r') as f: |
| 180 | + markdown_content = f.read() |
| 181 | + |
| 182 | + match = re.search(f'{start_pattern}(.*?){end_pattern}', markdown_content, re.DOTALL) |
| 183 | + |
| 184 | + assert match is not None, 'No match found, check the OR Doc pattern on index.md' |
| 185 | + extracted_content = match.group(1) |
| 186 | + extracted_content = "\n#### Supported Operating Systems" + extracted_content |
| 187 | + print(extracted_content) |
| 188 | + |
| 189 | + # Find insert position |
| 190 | + with open('index2.md', 'r') as f: |
| 191 | + existing_content = f.read() |
| 192 | + match = re.search(r'### Setup', existing_content) |
| 193 | + assert match is not None, 'Check search keyword.' |
| 194 | + with open('index2.md', 'w') as f: |
| 195 | + insert_position = match.end() + 1 |
| 196 | + before_insert = existing_content[:insert_position] |
| 197 | + after_insert = existing_content[insert_position:] |
| 198 | + |
| 199 | + # Combine the parts with the extracted content |
| 200 | + updated_content = before_insert + extracted_content + after_insert |
| 201 | + |
| 202 | + f.write(updated_content) |
| 203 | + |
168 | 204 | # Get Manpage file |
169 | 205 | url = 'https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/src/utl/README.md' |
170 | 206 | get_file_from_url(url, 'Manpage.md') |
0 commit comments