|
55 | 55 | ) |
56 | 56 | server_version = server_instance.version |
57 | 57 | server.shutdown_all_session_servers() |
58 | | -print(f"DPF version: {server_version}") |
| 58 | +print("".rjust(40, '*')) |
| 59 | +print(f"Doc built for DPF server version {server_version} at:\n{server_instance.ansys_path}") |
| 60 | +print("".rjust(40, '*')) |
| 61 | + |
| 62 | +def get_tutorial_version_requirements(tutorial_path: str) -> str: |
| 63 | + note_flag = r".. note::" |
| 64 | + version_flag = "This tutorial requires DPF" |
| 65 | + previous_line_is_note = False |
| 66 | + minimum_version = "0.0" |
| 67 | + tutorial_path = Path(tutorial_path) |
| 68 | + with tutorial_path.open("r") as f: |
| 69 | + for line in f: |
| 70 | + if (version_flag in line) and previous_line_is_note: |
| 71 | + minimum_version = line.strip(version_flag).split()[0] |
| 72 | + break |
| 73 | + if note_flag in line: |
| 74 | + previous_line_is_note = True |
| 75 | + else: |
| 76 | + previous_line_is_note = False |
| 77 | + return minimum_version |
59 | 78 |
|
60 | 79 | # Build ignore pattern |
61 | 80 | ignored_pattern = r"(ignore" |
62 | | -header_flag = "\"\"\"" |
63 | | -note_flag = r".. note::" |
64 | 81 | for example in glob(r"../../examples/**/*.py"): |
65 | 82 | minimum_version_str = get_example_required_minimum_dpf_version(example) |
66 | 83 | if float(server_version) - float(minimum_version_str) < -0.05: |
|
71 | 88 | ignored_pattern += "|06-distributed_stress_averaging.py" |
72 | 89 | ignored_pattern += r")" |
73 | 90 |
|
| 91 | +exclude_patterns = [] |
| 92 | +for tutorial_file in glob(r"user_guide/tutorials/**/*.rst"): |
| 93 | + if Path(tutorial_file).name == "index.rst": |
| 94 | + continue |
| 95 | + minimum_version_str = get_tutorial_version_requirements(tutorial_file) |
| 96 | + if float(server_version) - float(minimum_version_str) < -0.05: |
| 97 | + print(f"Tutorial {Path(tutorial_file).name} skipped as it requires DPF {minimum_version_str}.") |
| 98 | + exclude_patterns.append(tutorial_file) |
| 99 | + |
74 | 100 | # Autoapi ignore pattern |
75 | 101 | autoapi_ignore_list = [ |
76 | 102 | "*/log.py", |
|
159 | 185 | # List of patterns, relative to source directory, that match files and |
160 | 186 | # directories to ignore when looking for source files. |
161 | 187 | # This pattern also affects html_static_path and html_extra_path. |
162 | | -exclude_patterns = ["links_and_refs.rst"] |
| 188 | +exclude_patterns.extend(["links_and_refs.rst"]) |
163 | 189 |
|
164 | 190 | # make rst_epilog a variable, so you can add other epilog parts to it |
165 | 191 | rst_epilog = "" |
|
0 commit comments