Skip to content

Commit 808cf71

Browse files
committed
Try a different build solution
1 parent 658b70c commit 808cf71

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

docs/NAVIGATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ See https://oprypin.github.io/mkdocs-literate-nav/
1313
- [Dependency pinning and testing](further-background/dependency-pinning-and-testing.md)
1414
- [Development](development.md)
1515
- [API reference](api/example_fgen_basic/)
16-
- [Fortran API](fortran-api/index.html)
16+
- [Fortran API](fortran-api/home.html)
1717
- [Changelog](changelog.md)

docs/gen_fortran_api.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,46 @@
1111
import mkdocs_gen_files
1212

1313
REPO_ROOT = Path(__file__).parents[1]
14-
PACKAGE_NAME_ROOT = "example_fgen_basic"
15-
ROOT_DIR = Path("fortran-api")
16-
nav = mkdocs_gen_files.Nav()
14+
15+
FORD_OUTPUT_DIR = Path("docs") / "fortran-api"
1716

1817
ford = shutil.which("ford")
1918
if ford is None:
2019
msg = "Could not find FORD executable"
2120
raise AssertionError(msg)
2221

2322
subprocess.run( # noqa: S603
24-
[ford, "ford_config.md"],
23+
[ford, "ford_config.md", "--output_dir", str(FORD_OUTPUT_DIR)],
2524
check=True,
2625
)
2726

27+
# Copy files across using mkdocs_gen_files
28+
# so it knows to include the files in the final docs.
29+
for entry in (REPO_ROOT / FORD_OUTPUT_DIR).rglob("*"):
30+
if not entry.is_file():
31+
continue
32+
33+
with open(entry, "rb") as fh:
34+
contents = fh.read()
35+
36+
target_file = entry.relative_to(REPO_ROOT / "docs")
37+
with mkdocs_gen_files.open(target_file, "wb") as fh:
38+
fh.write(contents)
39+
if target_file.name == "index.html":
40+
target_file = target_file.parent / "home.html"
41+
42+
with mkdocs_gen_files.open(target_file, "wb") as fh:
43+
fh.write(contents)
44+
45+
# with mkdocs_gen_files.open(
46+
# (FORD_OUTPUT_DIR).relative_to("docs") / "NAVIGATION.md", "w"
47+
# ) as fh:
48+
# fh.writelines("* [example_fgen_basic](home.html)")
49+
50+
# Remove the ford files (which were just copied)
51+
shutil.rmtree(REPO_ROOT / FORD_OUTPUT_DIR)
52+
2853
# Put back the gitkeep file which ford deletes
29-
(REPO_ROOT / "docs" / ROOT_DIR / ".gitkeep").touch()
54+
gitkeep = REPO_ROOT / FORD_OUTPUT_DIR / ".gitkeep"
55+
gitkeep.parent.mkdir()
56+
gitkeep.touch()

environment-docs-conda-base.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dependencies:
99
- pip
1010
- gcc
1111
- gfortran
12+
- graphviz

0 commit comments

Comments
 (0)