-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-zarrarray-as-mag
- Loading branch information
Showing
55 changed files
with
2,501 additions
and
2,308 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
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
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
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 |
---|---|---|
|
@@ -137,6 +137,6 @@ dmypy.json | |
# Cython debug symbols | ||
cython_debug/ | ||
|
||
/src/api | ||
/src/api/webknossos | ||
/wk-repo | ||
/out |
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,17 +1,17 @@ | ||
# Documentation | ||
|
||
Run `docs/generate.sh` to open a server rendering the documentation. | ||
To update docstrings restart the server, manually written pages in `src` are auto-reloaded. | ||
## Development | ||
Run `./generate.sh` to open a live-reloading server rendering the documentation. | ||
|
||
To get a live-reloading server for the docstrings, run `docs/generate.sh --api`. This opens pdoc, which looks differently than the final result, but the actual contents are the same. | ||
## Production | ||
|
||
To produce the html in `out`, run `docs/generate.sh --persist`. | ||
Run `./generate.sh --persist` to produce the production website/HTML in `out`. Use GitHub Actions for building and deploying the website. | ||
|
||
|
||
## Further links | ||
|
||
* https://www.mkdocs.org | ||
* https://pdoc.dev | ||
* https://squidfunk.github.io/mkdocs-material | ||
* https://facelessuser.github.io/pymdown-extensions | ||
* https://python-markdown.github.io/extensions/#officially-supported-extensions | ||
* https://mkdocstrings.github.io/ |
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,11 +1,7 @@ | ||
#! /usr/bin/env bash | ||
set -Eeo pipefail | ||
|
||
PROJECT_DIR="$(dirname "$(dirname "$0")")" | ||
|
||
|
||
cd "$PROJECT_DIR/docs" | ||
poetry install | ||
poetry install --no-root | ||
|
||
if [ ! -d "wk-repo" ]; then | ||
echo | ||
|
@@ -14,25 +10,11 @@ if [ ! -d "wk-repo" ]; then | |
echo 'git clone --depth 1 [email protected]:scalableminds/webknossos.git docs/wk-repo' | ||
exit 1 | ||
fi | ||
rm -rf src/api/webknossos | ||
PYTHONPATH=$PYTHONPATH poetry run python generate_api_doc_pages.py | ||
|
||
export PDOC_CLASS_MODULES="$(poetry run python get_keyword_mapping.py)" | ||
if [ $# -eq 1 ] && [ "$1" = "--api" ]; then | ||
poetry run pdoc ../webknossos/webknossos !webknossos.dataset._utils -t pdoc_templates/pure_pdoc -h 0.0.0.0 -p 8196 | ||
if [ $# -eq 1 ] && [ "$1" = "--persist" ]; then | ||
PYTHONPATH=$PYTHONPATH poetry run mkdocs build | ||
else | ||
rm -rf src/api | ||
poetry run pdoc ../webknossos/webknossos !webknossos.dataset._utils -t pdoc_templates/with_mkdocs -o src/api | ||
# rename .html files to .md | ||
find src/api -iname "*.html" -exec sh -c 'mv "$0" "${0%.html}.md"' {} \; | ||
# assert that API docs are written | ||
webknossos_files="$(find src/api/webknossos -type f -name "*.md" | wc -l)" | ||
if ! [ "$webknossos_files" -gt "50" ]; then | ||
echo "Error: There are too few ($webknossos_files, expected > 80) files in src/api/webknossos," | ||
echo "probably there was an error with pdoc before!" | ||
exit 1 | ||
fi | ||
if [ $# -eq 1 ] && [ "$1" = "--persist" ]; then | ||
PYTHONPATH=$PYTHONPATH:. poetry run mkdocs build | ||
else | ||
PYTHONPATH=$PYTHONPATH:. poetry run mkdocs serve -a localhost:8197 --watch-theme | ||
fi | ||
PYTHONPATH=$PYTHONPATH poetry run mkdocs serve -a localhost:8197 --watch-theme | ||
fi |
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 inspect | ||
from logging import getLogger | ||
from pathlib import Path | ||
|
||
import webknossos | ||
|
||
""" | ||
This script generates a mapping of all classes in webknossos to their | ||
corresponding MkDocs pages. It is used to generate the API reference. | ||
""" | ||
|
||
logger = getLogger(__name__) | ||
|
||
OUT_PATH = Path("src/api") | ||
|
||
# Initialize a dictionary to store submodules and their classes | ||
submodules_classes = {} | ||
|
||
# Iterate through all the members of the module | ||
for name, member in inspect.getmembers(webknossos): | ||
# Check if the member is a module (submodule) | ||
if inspect.ismodule(member) and member.__name__.startswith("webknossos"): | ||
submodule_name = member.__name__ | ||
|
||
# List classes in the submodule | ||
classes = inspect.getmembers(member, inspect.isclass) | ||
|
||
# Filter classes that are defined in this specific submodule | ||
defined_classes = [ | ||
cls for cls_name, cls in classes if cls.__module__ == submodule_name | ||
] | ||
|
||
# If there are classes defined in this submodule, add them to the dictionary | ||
if defined_classes: | ||
submodules_classes[submodule_name] = defined_classes | ||
|
||
# Print the submodules and their classes | ||
for submodule, classes in submodules_classes.items(): | ||
# The file content uses a special syntax for MkDocs to render the | ||
# docstrings as Markdown. The syntax is: | ||
# ::: module.submodule.class | ||
# See https://mkdocstrings.github.io/python/ | ||
classes_string = "\n".join( | ||
[ | ||
f" - {c.__name__}" | ||
for c in classes | ||
if not c.__name__.startswith("_") | ||
] | ||
) | ||
file_content = f"""::: {submodule} | ||
options: | ||
members:\n{classes_string}\n""" | ||
|
||
submodule_parts = submodule.split(".") | ||
submodule_name = submodule_parts[-1] | ||
file_name = Path(f"{submodule_name}.md") | ||
file_path = "/".join(submodule_parts[:-1]) | ||
|
||
out_path = OUT_PATH.joinpath(file_path) | ||
out_path.mkdir(exist_ok=True, parents=True) | ||
|
||
logger.debug(f"Writing API docs to {out_path.joinpath(file_name)}") | ||
out_path.joinpath(file_name).write_text(file_content) |
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,2 @@ | ||
[filtering] | ||
ignorewarnings=http-redirected |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.