Check the model table in the index.rst is consistent with the state of the lib and maybe `overwrite`.
(overwrite=False)
| 159 | |
| 160 | |
| 161 | def check_model_table(overwrite=False): |
| 162 | """Check the model table in the index.rst is consistent with the state of the lib and maybe `overwrite`.""" |
| 163 | current_table, start_index, end_index, lines = _find_text_in_file( |
| 164 | filename=os.path.join(PATH_TO_DOCS, "index.md"), |
| 165 | start_prompt="<!--This table is updated automatically from the auto modules", |
| 166 | end_prompt="<!-- End table-->", |
| 167 | ) |
| 168 | new_table = get_model_table_from_auto_modules() |
| 169 | |
| 170 | if current_table != new_table: |
| 171 | if overwrite: |
| 172 | with open(os.path.join(PATH_TO_DOCS, "index.md"), "w", encoding="utf-8", newline="\n") as f: |
| 173 | f.writelines(lines[:start_index] + [new_table] + lines[end_index:]) |
| 174 | else: |
| 175 | raise ValueError( |
| 176 | "The model table in the `index.md` has not been updated. Run `make fix-copies` to fix this." |
| 177 | ) |
| 178 | |
| 179 | |
| 180 | if __name__ == "__main__": |
no test coverage detected