|
| 1 | +set working-directory := ".." |
| 2 | + |
| 3 | +# mkdocs defaults |
| 4 | +site-directory := "./site" |
| 5 | +dev-address := "localhost:8000" |
| 6 | + |
| 7 | +## Help |
| 8 | +help: (_mod_help source_file()) |
| 9 | + |
| 10 | +_mod_help justfile: |
| 11 | + @{{ just_executable() }} -f {{ justfile }} --list --unsorted |
| 12 | + |
| 13 | +## Logging |
| 14 | +_info message: |
| 15 | + @printf "{{BOLD}}--> {{message}}{{NORMAL}}\n" |
| 16 | + |
| 17 | +_success message="Task finished successfully": |
| 18 | + @printf "{{GREEN}}--> ✔ {{message}}{{NORMAL}}\n" |
| 19 | + |
| 20 | +_error message: |
| 21 | + @printf "{{RED}}--> ✘ {{message}}{{NORMAL}}\n" |
| 22 | + |
| 23 | +# Prints this help |
| 24 | + |
| 25 | +_install_dependencies: (_info "Installing documentation related dependencies") && (_success "Documentation related dependencies are installed") |
| 26 | + uv sync --frozen --all-extras --group docs |
| 27 | + |
| 28 | +# Build documentation to html |
| 29 | +build *mkdocs-args: _install_dependencies (_info "Building documentation") && (_success "Documentation built to " + site-directory + " directory") |
| 30 | + uv run mkdocs build -q --site-dir {{ site-directory }} {{ mkdocs-args }} |
| 31 | + |
| 32 | +# Open documentation in browser |
| 33 | +open *mkdocs-args: _install_dependencies (_info "Running mkdocs server listening at " + dev-address + ". Press CTRL-C to exit") |
| 34 | + uv run mkdocs serve -q --dev-addr {{ dev-address }} --open {{ mkdocs-args }} |
| 35 | + |
| 36 | +# Generate Handler markdowns |
| 37 | +generate-handlers-doc: |
| 38 | + #!/usr/bin/env python |
| 39 | + from pathlib import Path |
| 40 | + |
| 41 | + from unblob.doc import generate_markdown |
| 42 | + from unblob.handlers import BUILTIN_HANDLERS |
| 43 | + |
| 44 | + FORMAT_TABLE_HEADERS = """| Format | Type | Fully supported? |\n| :------------ | :----------------------------------- | :-----------------: |\n""" |
| 45 | + |
| 46 | + sorted_handlers = sorted(BUILTIN_HANDLERS, key=lambda handler_class: handler_class.NAME) |
| 47 | + handlers_path = Path("docs/handlers.md") |
| 48 | + print(f"Generating: {handlers_path}") |
| 49 | + with handlers_path.open("w") as f: |
| 50 | + f.write(FORMAT_TABLE_HEADERS) |
| 51 | + |
| 52 | + for handler_class in sorted_handlers: |
| 53 | + support_icon = "octicons-check-16" if handler_class.DOC.fully_supported else "octicons-alert-fill-12" |
| 54 | + f.write(f"""| [`{handler_class.DOC.name.upper()}`](#{handler_class.DOC.name.replace(" ", "-").lower()}) | {handler_class.DOC.handler_type.name} | :{support_icon}: |\n""") |
| 55 | + |
| 56 | + for handler_class in sorted_handlers: |
| 57 | + content = generate_markdown(handler_class.DOC) |
| 58 | + f.write("\n" + content) |
0 commit comments