-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically generate documentation pages for acquisition API (#43)
* Build acquisition API reference using docfx * Add dotnet and docfx setup to CI workflow * Ruff format and check acquisition build script * Add instructions to build with docfx * Reorganise API docs * Fix missing ref * Add "clean" actions to Windows make file * Allow redirects to learn.microsoft.com/dotnet/api * Temporarily ignore broken URL in acquisition API reference * Fix redirected URLs * Add `plotly` dependency --------- Co-authored-by: lochhh <[email protected]>
- Loading branch information
Showing
17 changed files
with
184 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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,13 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"docfx": { | ||
"version": "2.77.0", | ||
"commands": [ | ||
"docfx" | ||
], | ||
"rollForward": false | ||
} | ||
} | ||
} |
This file contains 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 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,5 +1,7 @@ | ||
# Sphinx documentation | ||
docs/ | ||
src/reference/api/ | ||
src/reference/api.rst | ||
src/user/**/*_copy* | ||
src/user/**/*_copy* | ||
|
||
# Python scripts | ||
__pycache__ |
This file contains 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 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 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 @@ | ||
import yaml | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
def make_acquisition_doctree(): | ||
""" | ||
Create a doctree of all namespaces in aeon_acquisition. | ||
""" | ||
src_path = Path("src") | ||
subprocess.run(["dotnet", "docfx", "metadata", "--outputFormat", "markdown"], cwd=src_path) | ||
metadata_path = src_path.joinpath("reference", "api", "acquisition") | ||
|
||
# get the acquisition doc header | ||
with open(metadata_path.joinpath("toc.yml"), "r") as f: | ||
acquisition_toc = yaml.safe_load(f) | ||
|
||
# write file for acquisition doc with header + doctree | ||
with open(metadata_path.with_suffix(".rst"), "w") as f: | ||
f.write("..\n This file is auto-generated.\n\n") | ||
f.write(".. _target-acquisition-reference:\n\n") | ||
f.write("``aeon_acquisition``\n") | ||
f.write("=====================\n\n") | ||
f.write(".. toctree::\n") | ||
f.write(" :glob:\n\n") | ||
|
||
# all namespaces are children of the root element | ||
for namespace in acquisition_toc: | ||
namespace_name = namespace["name"] | ||
namespace_href = namespace.get("href") | ||
namespace_items = namespace.get("items") | ||
if namespace_href is None or namespace_items is None: | ||
continue | ||
|
||
# add namespace toctree entry | ||
f.write(f" {namespace_name} <acquisition/{namespace_name}>\n") | ||
|
||
# generate toctree for each namespace document | ||
namespace_path = metadata_path.joinpath(namespace_href) | ||
with open(namespace_path, "r+", encoding="utf-8") as nsf: | ||
content = nsf.read() | ||
content += "```{toctree}\n" | ||
|
||
# loop through all namespace items | ||
for item in namespace_items: | ||
item_name = item["name"] | ||
item_href = item.get("href") | ||
if item_href is None: # item is category, skip for now | ||
continue | ||
|
||
# item is type, add toctree entry | ||
item_path = metadata_path.joinpath(item_href) | ||
item_filename = item_path.with_suffix("").name | ||
content += f"\n{item_name} <{item_filename}>" | ||
|
||
content += "\n```" | ||
nsf.seek(0) | ||
nsf.write(content) | ||
nsf.truncate() | ||
|
||
|
||
if __name__ == "__main__": | ||
make_acquisition_doctree() |
This file contains 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 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 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ dotmap | |
matplotlib | ||
opencv-python | ||
pandas | ||
plotly | ||
|
||
linkify-it-py | ||
myst-nb | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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,12 @@ | ||
.. _target-mecha-reference: | ||
|
||
``aeon_mecha`` | ||
============== | ||
|
||
.. toctree:: | ||
:caption: aeon_mecha API | ||
:maxdepth: 1 | ||
|
||
.. autosummary:: | ||
:toctree: mecha | ||
|
This file contains 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 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 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,41 @@ | ||
{ | ||
"metadata": [ | ||
{ | ||
"src": [ | ||
{ | ||
"src": "../aeon_acquisition/src", | ||
"files": ["**/*.csproj"], | ||
"exclude": [ "**/*.Tests/**" ] | ||
} | ||
], | ||
"dest": "reference/api/acquisition" | ||
} | ||
], | ||
"build": { | ||
"content": [ | ||
{ | ||
"files": [ | ||
"**/*.{md,yml}" | ||
], | ||
"exclude": [ | ||
"_site/**" | ||
] | ||
} | ||
], | ||
"resource": [ | ||
{ | ||
"files": [ | ||
"images/**" | ||
] | ||
} | ||
], | ||
|
||
"xref": [ | ||
"https://horizongir.github.io/opencv.net/xrefmap.yml", | ||
"https://horizongir.github.io/ZedGraph/xrefmap.yml", | ||
"https://horizongir.github.io/opentk/xrefmap.yml", | ||
"https://horizongir.github.io/reactive/xrefmap.yml", | ||
"https://bonsai-rx.org/sleap/xrefmap.yml" | ||
] | ||
} | ||
} |
This file contains 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 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,9 @@ | ||
(target-api-reference)= | ||
# API Reference | ||
|
||
:::{toctree} | ||
:maxdepth: 2 | ||
:hidden: | ||
|
||
api/mecha | ||
api/acquisition |
This file contains 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