-
Notifications
You must be signed in to change notification settings - Fork 0
Add Fortran docs with FORD #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b058bba
Basic solution to include fortran docs
mzecc c91b776
Fix path
mzecc aae815f
CI: Install Graphviz
mzecc 9315529
Add graphivz as dependency
mzecc ee4a265
Ignore script in mkdocs.yml and remove name equals main guard
znicholls 0e2ec6d
Fix up ford deletion of gitignore
znicholls a9a8da8
Get things building without errors
znicholls 8ccfc81
Remove Fortran API from nav to simplify for now
znicholls 658b70c
Add Fortran API back into navigation
znicholls 808cf71
Try a different build solution
znicholls 7af613f
CHANGELOG
znicholls cb8f2ee
Clean up
znicholls d06e016
Add missing newline
znicholls f1090d2
Remove unused argument from ford_config
znicholls d7333cd
Tidy up pyproject.toml
znicholls 669b40d
Update comments
znicholls File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Added documentation of the Fortran back-end/API using [ford](https://forddocs.readthedocs.io/en/stable/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """ | ||
| Drive Ford to create Fortran API docs | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import shutil | ||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| import mkdocs_gen_files | ||
|
|
||
| REPO_ROOT = Path(__file__).parents[1] | ||
|
|
||
| FORD_OUTPUT_DIR = Path("docs") / "fortran-api" | ||
|
|
||
| ford = shutil.which("ford") | ||
| if ford is None: | ||
| msg = "Could not find FORD executable" | ||
| raise AssertionError(msg) | ||
|
|
||
| subprocess.run( # noqa: S603 | ||
| [ford, "ford_config.md", "--output_dir", str(FORD_OUTPUT_DIR)], | ||
| check=True, | ||
| ) | ||
|
|
||
| # Copy files across using mkdocs_gen_files | ||
| # so it knows to include the files in the final docs. | ||
| for entry in (REPO_ROOT / FORD_OUTPUT_DIR).rglob("*"): | ||
| if not entry.is_file(): | ||
| continue | ||
|
|
||
| with open(entry, "rb") as fh: | ||
| contents = fh.read() | ||
|
|
||
| target_file = entry.relative_to(REPO_ROOT / "docs") | ||
| with mkdocs_gen_files.open(target_file, "wb") as fh: | ||
| fh.write(contents) | ||
|
|
||
| if target_file.name == "index.html": | ||
| # Also create a home.html file which we can point to from `NAVIGATION.md`. | ||
| # I don't know why just pointing to `index.html` doesn't work, | ||
| # but it doesn't (maybe cause `index.html` is a special name?). | ||
| target_file = target_file.parent / "home.html" | ||
|
|
||
| with mkdocs_gen_files.open(target_file, "wb") as fh: | ||
| fh.write(contents) | ||
|
|
||
| # # If we want to move back to using literate-nav for maanging our navigation, | ||
| # # also for the Fortran bits, we'll need something like the below | ||
| # # and adjustments to the existing `NAVIGATION.md`. | ||
| # with mkdocs_gen_files.open( | ||
| # (FORD_OUTPUT_DIR).relative_to("docs") / "NAVIGATION.md", "w" | ||
| # ) as fh: | ||
| # fh.writelines("* [example_fgen_basic](home.html)") | ||
|
|
||
| # Remove the ford files (which were just copied) | ||
| shutil.rmtree(REPO_ROOT / FORD_OUTPUT_DIR) | ||
|
|
||
| # Put back the gitkeep file | ||
| gitkeep = REPO_ROOT / FORD_OUTPUT_DIR / ".gitkeep" | ||
| gitkeep.parent.mkdir() | ||
| gitkeep.touch() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,10 @@ | ||
| ---8<--- "README.md:description" | ||
|
|
||
| ## API docs | ||
|
|
||
| Our Python API is documented in [API][example_fgen_basic_1]. | ||
| The Fortran API is documented in [Fortran API](./fortran-api/). | ||
| At present, the Fortran API docs are a sub-website so you can navigate to them | ||
| but there are no buttons to navigate back to the main docs page | ||
| (so you have to instead return yourself by re-entering the URL | ||
| or pressing back, sorry, we hope to improve this in future). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ dependencies: | |
| - pip | ||
| - gcc | ||
| - gfortran | ||
| - graphviz | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| project: Example fgen - basic | ||
| author: TODO align this with pyproject.toml | ||
| src_dir: src | ||
| graph: true | ||
| --- | ||
|
|
||
| API docs for Fortran components! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a hack but I couldnt make this behave with the more normal
[Fortran API](fortran-api/index.html)