|
17 | 17 |
|
18 | 18 | # -- Project information ----------------------------------------------------- |
19 | 19 |
|
20 | | -project = 'OpenROAD Flow' |
21 | | -copyright = 'The Regents of the University of California, 2021' |
22 | | -author = 'OpenROAD Team' |
| 20 | +project = "OpenROAD Flow" |
| 21 | +copyright = "The Regents of the University of California, 2021" |
| 22 | +author = "OpenROAD Team" |
23 | 23 |
|
24 | 24 |
|
25 | 25 | # -- General configuration --------------------------------------------------- |
|
28 | 28 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
29 | 29 | # ones. |
30 | 30 | extensions = [ |
31 | | - 'sphinx.ext.autodoc', |
32 | | - 'sphinx.ext.ifconfig', |
33 | | - 'sphinx.ext.mathjax', |
34 | | - 'sphinx.ext.napoleon', |
35 | | - 'sphinx.ext.todo', |
36 | | - 'sphinx_external_toc', |
37 | | - 'sphinx_copybutton', |
38 | | - 'myst_parser', |
39 | | - 'sphinxcontrib.mermaid' |
| 31 | + "sphinx.ext.autodoc", |
| 32 | + "sphinx.ext.ifconfig", |
| 33 | + "sphinx.ext.mathjax", |
| 34 | + "sphinx.ext.napoleon", |
| 35 | + "sphinx.ext.todo", |
| 36 | + "sphinx_external_toc", |
| 37 | + "sphinx_copybutton", |
| 38 | + "myst_parser", |
| 39 | + "sphinxcontrib.mermaid", |
40 | 40 | ] |
41 | 41 |
|
42 | 42 | myst_enable_extensions = [ |
43 | | - 'amsmath', |
44 | | - 'colon_fence', |
45 | | - 'deflist', |
46 | | - 'dollarmath', |
47 | | - 'html_admonition', |
48 | | - 'html_image', |
49 | | - 'replacements', |
50 | | - 'smartquotes', |
51 | | - 'substitution', |
52 | | - 'tasklist', |
53 | | - 'html_image', |
| 43 | + "amsmath", |
| 44 | + "colon_fence", |
| 45 | + "deflist", |
| 46 | + "dollarmath", |
| 47 | + "html_admonition", |
| 48 | + "html_image", |
| 49 | + "replacements", |
| 50 | + "smartquotes", |
| 51 | + "substitution", |
| 52 | + "tasklist", |
| 53 | + "html_image", |
54 | 54 | ] |
55 | 55 |
|
56 | | -external_toc_path = 'toc.yml' |
| 56 | +external_toc_path = "toc.yml" |
57 | 57 |
|
58 | 58 | # Add any paths that contain templates here, relative to this directory. |
59 | | -templates_path = ['_templates'] |
| 59 | +templates_path = ["_templates"] |
60 | 60 |
|
61 | 61 | # The suffix(es) of source filenames. |
62 | 62 | # You can specify multiple suffix as a list of string: |
63 | | -source_suffix = ['.md'] |
| 63 | +source_suffix = [".md"] |
64 | 64 |
|
65 | 65 | # The master toctree document. |
66 | | -master_doc = 'index2.md' |
| 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. |
70 | 70 | # This pattern also affects html_static_path and html_extra_path. |
71 | 71 | exclude_patterns = [ |
72 | | - '_build', |
73 | | - 'Thumbs.db', |
74 | | - '.DS_Store', |
75 | | - '**/LICENSE', |
76 | | - '**/LICENSE.md', |
77 | | - 'README.md', |
78 | | - 'docs/releases/PostAlpha2.1BranchMethodology.md', |
79 | | - 'main', |
80 | | - 'index.md' |
| 72 | + "_build", |
| 73 | + "Thumbs.db", |
| 74 | + ".DS_Store", |
| 75 | + "**/LICENSE", |
| 76 | + "**/LICENSE.md", |
| 77 | + "README.md", |
| 78 | + "docs/releases/PostAlpha2.1BranchMethodology.md", |
| 79 | + "main", |
| 80 | + "index.md", |
81 | 81 | ] |
82 | 82 |
|
83 | 83 | # The name of the Pygments (syntax highlighting) style to use. |
|
97 | 97 | "show_navbar_depth": 2, |
98 | 98 | "use_issues_button": True, |
99 | 99 | "use_download_button": True, |
100 | | - |
101 | 100 | # list for more fine-grained ordering of icons |
102 | 101 | "icon_links": [ |
103 | 102 | { |
|
126 | 125 | "icon": "https://img.shields.io/github/stars/The-OpenROAD-Project/OpenROAD-flow-scripts", |
127 | 126 | "type": "url", |
128 | 127 | }, |
129 | | - ], |
| 128 | + ], |
130 | 129 | } |
131 | 130 |
|
132 | 131 | # Add any paths that contain custom static files (such as style sheets) here, |
133 | 132 | # relative to this directory. They are copied after the builtin static files, |
134 | 133 | # so a file named "default.css" will overwrite the builtin "default.css". |
135 | 134 |
|
| 135 | + |
136 | 136 | def get_file_from_url(url, fname): |
137 | 137 | r = requests.get(url) |
138 | | - with open(fname, 'wb') as f: |
| 138 | + with open(fname, "wb") as f: |
139 | 139 | f.write(r.content) |
140 | 140 |
|
| 141 | + |
141 | 142 | def swap_prefix(file, old, new): |
142 | | - with open(file, 'r') as f: |
| 143 | + with open(file, "r") as f: |
143 | 144 | lines = f.read() |
144 | 145 | lines = lines.replace(old, new) |
145 | | - with open(file, 'wt') as f: |
| 146 | + with open(file, "wt") as f: |
146 | 147 | f.write(lines) |
147 | 148 |
|
| 149 | + |
148 | 150 | def setup(app): |
149 | 151 | import shutil |
150 | | - |
| 152 | + |
151 | 153 | # symlink does not work for ORFS because of long recursive file links |
152 | | - shutil.copy('../README.md', 'mainREADME.md') |
153 | | - swap_prefix('mainREADME.md', '```mermaid', '```{mermaid}\n:align: center\n') |
| 154 | + shutil.copy("../README.md", "mainREADME.md") |
| 155 | + swap_prefix("mainREADME.md", "```mermaid", "```{mermaid}\n:align: center\n") |
154 | 156 |
|
155 | 157 | # Grab the reference file from OR |
156 | | - url = 'https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/docs/contrib/GitGuide.md' |
157 | | - get_file_from_url(url, 'contrib/GitGuide.md') |
158 | | - |
| 158 | + url = "https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/docs/contrib/GitGuide.md" |
| 159 | + get_file_from_url(url, "contrib/GitGuide.md") |
| 160 | + |
159 | 161 | # 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') |
| 162 | + url = "https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/3563176d00daeb613eed2ccf9442137b0ae2cad3/docs/index.md" |
| 163 | + get_file_from_url(url, "SupportedOS.md") |
162 | 164 |
|
163 | 165 | # edit OpenROAD to OpenROAD-flow-scripts for GitGuide |
164 | | - with open('contrib/GitGuide.md', 'r') as f: |
| 166 | + with open("contrib/GitGuide.md", "r") as f: |
165 | 167 | content = f.read() |
166 | | - content = content.replace('user/Build.md', '../index.md#build-or-installing-orfs-dependencies') |
167 | | - content = content.replace('OpenROAD', 'OpenROAD-flow-scripts') |
168 | | - content = content.replace('The-OpenROAD-flow-scripts', 'The-OpenROAD') |
169 | | - with open('contrib/GitGuide.md', 'w') as f: |
| 168 | + content = content.replace( |
| 169 | + "user/Build.md", "../index.md#build-or-installing-orfs-dependencies" |
| 170 | + ) |
| 171 | + content = content.replace("OpenROAD", "OpenROAD-flow-scripts") |
| 172 | + content = content.replace("The-OpenROAD-flow-scripts", "The-OpenROAD") |
| 173 | + with open("contrib/GitGuide.md", "w") as f: |
170 | 174 | f.write(content) |
171 | 175 |
|
172 | 176 | # Create a copy of the index.md file |
173 | 177 | import shutil |
174 | | - shutil.copy('index.md', 'index2.md') |
175 | 178 |
|
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: |
| 179 | + shutil.copy("index.md", "index2.md") |
| 180 | + |
| 181 | + # Use re to find the desired content |
| 182 | + start_pattern = "## Supported Operating Systems" |
| 183 | + end_pattern = "## Code of conduct" |
| 184 | + with open("SupportedOS.md", "r") as f: |
180 | 185 | markdown_content = f.read() |
181 | 186 |
|
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' |
| 187 | + match = re.search(f"{start_pattern}(.*?){end_pattern}", markdown_content, re.DOTALL) |
| 188 | + |
| 189 | + assert match is not None, "No match found, check the OR Doc pattern on index.md" |
185 | 190 | extracted_content = match.group(1) |
186 | 191 | extracted_content = "\n#### Supported Operating Systems" + extracted_content |
187 | 192 | print(extracted_content) |
188 | | - |
| 193 | + |
189 | 194 | # Find insert position |
190 | | - with open('index2.md', 'r') as f: |
| 195 | + with open("index2.md", "r") as f: |
191 | 196 | 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: |
| 197 | + match = re.search(r"### Setup", existing_content) |
| 198 | + assert match is not None, "Check search keyword." |
| 199 | + with open("index2.md", "w") as f: |
195 | 200 | insert_position = match.end() + 1 |
196 | 201 | before_insert = existing_content[:insert_position] |
197 | 202 | after_insert = existing_content[insert_position:] |
198 | 203 |
|
199 | 204 | # Combine the parts with the extracted content |
200 | 205 | updated_content = before_insert + extracted_content + after_insert |
201 | | - |
| 206 | + |
202 | 207 | f.write(updated_content) |
203 | | - |
| 208 | + |
204 | 209 | # Get Manpage file |
205 | | - url = 'https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/src/utl/README.md' |
206 | | - get_file_from_url(url, 'Manpage.md') |
| 210 | + url = "https://raw.githubusercontent.com/The-OpenROAD-Project/OpenROAD/master/src/utl/README.md" |
| 211 | + get_file_from_url(url, "Manpage.md") |
0 commit comments