-
Notifications
You must be signed in to change notification settings - Fork 40
Generate api docs for EESSI test suite #319
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
base: main
Are you sure you want to change the base?
Changes from 33 commits
30b717a
3fdb896
80f2c3a
5c7ef65
65131b8
1994da4
33762ff
0004eb3
12dc637
9ca30ae
170da31
9a027b2
422a20e
dd28578
b870f15
0d242ef
a99c6db
322d0d4
1e31fd7
e1ab323
51c3d48
15ff385
2aae108
6726d44
7d3189f
af73133
09a7a5f
3364006
25e5c37
4d9deda
3c5ee20
29dbb15
b92db86
8a3aa5d
fb59aab
25c86d5
f213810
6c593b3
d831e05
2597103
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ site/ | |
venv* | ||
scripts/available_software/__pycache__ | ||
scripts/available_software/tests/__pycache__ | ||
|
||
test-suite |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file should be added to ´scripts/generate_eessi_test-suite_api_docs´ with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also mentioned this on slack
Can you also add that to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And if we need to create a subdir with test-suite we should also add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I think there's some misunderstanding here. I'm not doing the same as the software overview page. I was planning to do that, but it turns out that is fundamentally impossible, because the way mkdocs autogenerates API docs is not by creating So, integrating the requirements for this into the regular requirements file is completely valid: the API docs are now an integral part of the docs. As soon as you generate the documentation with an
That's actually not a bad idea, but should probably be in the
We could. I wouldn't consider it super essential, since you'd only checkout the test-suite when building the docs - and all of that happens in a CI workflow anyway - but sure, if you'd build it locally and don't want to see the |
||
Generate the code reference pages. | ||
Based off https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages | ||
""" | ||
|
||
import os | ||
|
||
from pathlib import Path | ||
|
||
import mkdocs_gen_files | ||
|
||
TEST_SUITE = "test-suite/test-suite" | ||
|
||
if not os.path.isdir(TEST_SUITE): | ||
raise FileNotFoundError(f"Error: {TEST_SUITE} does not exist. Please clone the eessi/test-suite in a test-suite dir.") | ||
|
||
# build a navigation for the menu and a dictionary of navigations for each section | ||
nav = mkdocs_gen_files.Nav() | ||
|
||
# Loop through all python files in test-suite/eessi | ||
for path in sorted(Path(f"{TEST_SUITE}/eessi/").rglob("*.py")): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like some logging and error reporting because I had not added the subdir test-suite and the script was just ran doing nothing. But I believe it should error out when it cannot find the test-suite subdir. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I'll look at that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@casparvl will you still return to this comment? Or should we just merge and leave this for later? |
||
# Get the relative filename, without .py suffix | ||
module_path = path.relative_to(TEST_SUITE).with_suffix("") | ||
|
||
# define the corresponding (relative) markdown filename | ||
doc_path = path.relative_to(TEST_SUITE).with_suffix(".md") | ||
|
||
# Specify the full corresponding markdown filename, including a testsuite_api subdir | ||
# so that we don't have these API docs scattered in the root of the EESSI docs repo | ||
full_doc_path = Path("testsuite_api/", doc_path) | ||
|
||
# If something is an __init__, use the directory name as the name of the python module instead of the filename | ||
parts = list(module_path.parts) | ||
if parts[-1] == "__init__": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the OpenFOAM PATH was not created properly because of this if condition, it does not have an else. |
||
parts = parts[:-1] | ||
# Skip the __main__, if there is one. This is not part of the API | ||
elif parts[-1] == "__main__": | ||
continue | ||
|
||
# Add an entry for this module to the navigation | ||
nav[parts] = doc_path.as_posix() | ||
|
||
# Create the markdown file | ||
with mkdocs_gen_files.open(full_doc_path, "w") as fd: | ||
# identifier is something like eessi.foo.bar | ||
identifier = ".".join(parts) | ||
fd.write(f"::: {identifier}") | ||
|
||
# This maps the generated .md file to the source .py, so that you can have an "Edit on GitHub" button | ||
# that links to the Python code | ||
mkdocs_gen_files.set_edit_path(full_doc_path, path) | ||
|
||
# Create the api/summary.md file and write the full navigation tree into it so it can be used as a site sidebar | ||
with mkdocs_gen_files.open("testsuite_api/summary.md", "w") as nav_file: | ||
nav_file.writelines(nav.build_literate_nav()) |
Uh oh!
There was an error while loading. Please reload this page.