Skip to content

Commit 9694194

Browse files
sbryngelsonclaude
andcommitted
Address reviewer feedback on API docs scripts
- gen_api_landing.py: scan .f90 files (not just .fpp), add encoding and mkdir, add future annotations - fix_file_briefs.py: exclude module procedure from regex, add encoding, add future annotations - CMakeLists.txt: add source file DEPENDS to stamp commands so they re-run when Fortran sources change Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2b7a917 commit 9694194

6 files changed

Lines changed: 39 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ if (MFC_DOCUMENTATION)
813813
add_custom_command(
814814
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gen-api-landing.stamp"
815815
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/gen_api_landing.py"
816+
${pre_process_FPPs} ${pre_process_F90s}
817+
${simulation_FPPs} ${simulation_F90s}
818+
${post_process_FPPs} ${post_process_F90s}
816819
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/docs/gen_api_landing.py"
817820
"${CMAKE_CURRENT_SOURCE_DIR}"
818821
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/gen-api-landing.stamp"
@@ -829,6 +832,9 @@ if (MFC_DOCUMENTATION)
829832
add_custom_command(
830833
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/fix-file-briefs.stamp"
831834
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/docs/fix_file_briefs.py"
835+
${pre_process_FPPs} ${pre_process_F90s}
836+
${simulation_FPPs} ${simulation_F90s}
837+
${post_process_FPPs} ${post_process_F90s}
832838
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/docs/fix_file_briefs.py"
833839
"${CMAKE_CURRENT_SOURCE_DIR}"
834840
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/fix-file-briefs.stamp"

docs/fix_file_briefs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
(Doxygen lowercases Fortran namespaces).
1313
"""
1414

15+
from __future__ import annotations
16+
1517
import re
1618
import sys
1719
from pathlib import Path
@@ -27,7 +29,8 @@
2729

2830
# First `module X` or `program X` that isn't `end module/program`.
2931
DECL_RE = re.compile(
30-
r"^\s*(module|program)\s+(\w+)\s*$", re.MULTILINE | re.IGNORECASE
32+
r"^\s*(module(?!\s+procedure)\b|program)\s+(\w+)\s*$",
33+
re.MULTILINE | re.IGNORECASE,
3134
)
3235

3336
# Any "Contains module/program <name>" in a Doxygen comment line.
@@ -66,7 +69,7 @@ def has_file_directive(text: str) -> bool:
6669
if not d.exists():
6770
continue
6871
for f in sorted(list(d.glob("*.fpp")) + list(d.glob("*.f90"))):
69-
text = f.read_text()
72+
text = f.read_text(encoding="utf-8")
7073
entity = find_entity(text)
7174
if entity is None:
7275
continue
@@ -77,7 +80,7 @@ def has_file_directive(text: str) -> bool:
7780
# No @file at all — prepend a complete header.
7881
header = f"!>\n!! @file\n!! @brief Contains {kind} {ref}\n\n"
7982
text = header + text
80-
f.write_text(text)
83+
f.write_text(text, encoding="utf-8")
8184
fixed += 1
8285
print(f"Added {f.relative_to(src_dir)}")
8386
continue
@@ -96,7 +99,7 @@ def has_file_directive(text: str) -> bool:
9699
new_text = text[: m.start()] + new_line + text[m.end() :]
97100

98101
if new_text != text:
99-
f.write_text(new_text)
102+
f.write_text(new_text, encoding="utf-8")
100103
fixed += 1
101104
print(f"Fixed {f.relative_to(src_dir)}: {current_name} -> {ref}")
102105

docs/gen_api_landing.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
Usage: python3 gen_api_landing.py [source_dir]
55
source_dir defaults to current directory.
66
7-
Scans src/{target}/*.fpp and src/common/*.fpp to produce module tables
8-
in docs/{target}/readme.md. Intro text is defined below per target.
7+
Scans src/{target}/*.fpp,*.f90 and src/common/*.fpp,*.f90 to produce module
8+
tables in docs/{target}/readme.md. Intro text is defined below per target.
99
"""
1010

11+
from __future__ import annotations
12+
1113
import sys
1214
from pathlib import Path
1315

@@ -46,10 +48,12 @@
4648

4749

4850
def get_modules(directory: Path) -> list[str]:
49-
"""Return sorted list of module names (m_*) from .fpp files."""
50-
return sorted(
51-
f.stem for f in directory.glob("m_*.fpp")
52-
)
51+
"""Return sorted list of module names (m_*) from .fpp and .f90 files."""
52+
modules: set[str] = set()
53+
for pattern in ("m_*.fpp", "m_*.f90"):
54+
for f in directory.glob(pattern):
55+
modules.add(f.stem)
56+
return sorted(modules)
5357

5458

5559
for target, info in TARGETS.items():
@@ -88,5 +92,6 @@ def get_modules(directory: Path) -> list[str]:
8892
lines.append(f"- [{label} API](../{sib}/index.html)")
8993
lines.append("")
9094

91-
out.write_text("\n".join(lines))
95+
out.parent.mkdir(parents=True, exist_ok=True)
96+
out.write_text("\n".join(lines), encoding="utf-8")
9297
print(f"Generated {out}")

docs/post_process/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The post-process component reads raw simulation output and computes derived quan
77
### Post-Process
88

99
- @ref m_checker "m_checker"
10+
- @ref m_data_input "m_data_input"
1011
- @ref m_data_output "m_data_output"
1112
- @ref m_derived_variables "m_derived_variables"
1213
- @ref m_global_parameters "m_global_parameters"
@@ -18,14 +19,18 @@ The post-process component reads raw simulation output and computes derived quan
1819
- @ref m_boundary_common "m_boundary_common"
1920
- @ref m_checker_common "m_checker_common"
2021
- @ref m_chemistry "m_chemistry"
22+
- @ref m_compile_specific "m_compile_specific"
2123
- @ref m_constants "m_constants"
24+
- @ref m_delay_file_access "m_delay_file_access"
2225
- @ref m_derived_types "m_derived_types"
2326
- @ref m_finite_differences "m_finite_differences"
2427
- @ref m_helper "m_helper"
2528
- @ref m_helper_basic "m_helper_basic"
2629
- @ref m_model "m_model"
2730
- @ref m_mpi_common "m_mpi_common"
31+
- @ref m_nvtx "m_nvtx"
2832
- @ref m_phase_change "m_phase_change"
33+
- @ref m_precision_select "m_precision_select"
2934
- @ref m_variables_conversion "m_variables_conversion"
3035

3136
## See Also

docs/pre_process/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The pre-process component generates initial conditions and computational meshes
1313
- @ref m_checker "m_checker"
1414
- @ref m_data_output "m_data_output"
1515
- @ref m_global_parameters "m_global_parameters"
16+
- @ref m_grid "m_grid"
1617
- @ref m_icpp_patches "m_icpp_patches"
1718
- @ref m_initial_condition "m_initial_condition"
1819
- @ref m_mpi_proxy "m_mpi_proxy"
@@ -25,14 +26,18 @@ The pre-process component generates initial conditions and computational meshes
2526
- @ref m_boundary_common "m_boundary_common"
2627
- @ref m_checker_common "m_checker_common"
2728
- @ref m_chemistry "m_chemistry"
29+
- @ref m_compile_specific "m_compile_specific"
2830
- @ref m_constants "m_constants"
31+
- @ref m_delay_file_access "m_delay_file_access"
2932
- @ref m_derived_types "m_derived_types"
3033
- @ref m_finite_differences "m_finite_differences"
3134
- @ref m_helper "m_helper"
3235
- @ref m_helper_basic "m_helper_basic"
3336
- @ref m_model "m_model"
3437
- @ref m_mpi_common "m_mpi_common"
38+
- @ref m_nvtx "m_nvtx"
3539
- @ref m_phase_change "m_phase_change"
40+
- @ref m_precision_select "m_precision_select"
3641
- @ref m_variables_conversion "m_variables_conversion"
3742

3843
## See Also

docs/simulation/readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ The simulation component is the core flow solver. It advances the governing equa
4343
- @ref m_boundary_common "m_boundary_common"
4444
- @ref m_checker_common "m_checker_common"
4545
- @ref m_chemistry "m_chemistry"
46+
- @ref m_compile_specific "m_compile_specific"
4647
- @ref m_constants "m_constants"
48+
- @ref m_delay_file_access "m_delay_file_access"
4749
- @ref m_derived_types "m_derived_types"
4850
- @ref m_finite_differences "m_finite_differences"
4951
- @ref m_helper "m_helper"
5052
- @ref m_helper_basic "m_helper_basic"
5153
- @ref m_model "m_model"
5254
- @ref m_mpi_common "m_mpi_common"
55+
- @ref m_nvtx "m_nvtx"
5356
- @ref m_phase_change "m_phase_change"
57+
- @ref m_precision_select "m_precision_select"
5458
- @ref m_variables_conversion "m_variables_conversion"
5559

5660
## See Also

0 commit comments

Comments
 (0)