@@ -34,137 +34,3 @@ tasks:
3434 mkdir -p _tests/html-coverage _tests/html-report
3535 ./bin/uv run pytest {{.TESTS_FOLDER}} --cov=$SOURCE_FOLDER --cov-report=term --cov-report=html:_tests/html-coverage --html=_tests/html-report/report.html
3636 fi
37-
38- docs :
39- desc : Build documentation using pdoc
40- cmds :
41- - ./bin/task build:install
42- - |
43- if [ -f "pyproject.toml" ]; then
44- printf "${BLUE}[INFO] Building documentation...${RESET}\n"
45- if [ -d "src" ]; then
46- SOURCE_FOLDER=$(LC_ALL=C find src -mindepth 1 -maxdepth 1 -type d -not -path '*/\.*' | sort | head -1)
47- if [ -z "$SOURCE_FOLDER" ]; then
48- printf "${YELLOW}[WARN] src/ exists but contains no top-level packages, skipping docs${RESET}\n"
49- else
50- ./bin/uv pip install pdoc
51- ./bin/uv run pdoc -o _pdoc "$SOURCE_FOLDER"
52- fi
53- else
54- printf "${YELLOW}[WARN] No src/ directory found, skipping docs${RESET}\n"
55- fi
56- else
57- printf "${YELLOW}[WARN] No pyproject.toml found, skipping docs${RESET}\n"
58- fi
59-
60- marimushka :
61- desc : Export Marimo notebooks to HTML
62- cmds :
63- - ./bin/task build:install
64- - printf "${BLUE}[INFO] Exporting notebooks from {{.MARIMO_FOLDER}}...${RESET}\n"
65- - |
66- if [ ! -d "{{.MARIMO_FOLDER}}" ]; then
67- printf "${YELLOW}[WARN] Directory '{{.MARIMO_FOLDER}}' does not exist. Skipping marimushka.${RESET}\n"
68- else
69- ./bin/uv pip install marimo
70- mkdir -p _marimushka
71- py_files=$(find "{{.MARIMO_FOLDER}}" -maxdepth 1 -name "*.py" | tr '\n' ' ')
72- if [ -z "$py_files" ]; then
73- printf "${YELLOW}[WARN] No Python files found in '{{.MARIMO_FOLDER}}'.${RESET}\n"
74- echo "<html><head><title>Marimo Notebooks</title></head><body><h1>Marimo Notebooks</h1><p>No notebooks found.</p></body></html>" > _marimushka/index.html
75- else
76- printf "${BLUE}[INFO] Found Python files: %s${RESET}\n" "$py_files"
77- for py_file in $py_files; do
78- printf " ${BLUE}[INFO] Processing %s...${RESET}\n" "$py_file"
79- rel_path=$(echo "$py_file" | sed "s|^{{.MARIMO_FOLDER}}/||")
80- dir_path=$(dirname "$rel_path")
81- base_name=$(basename "$rel_path" .py)
82- mkdir -p "_marimushka/$dir_path"
83-
84- # Check if the file has a script header ("# /// script")
85- if grep -q "^# /// script" "$py_file"; then
86- printf " ${BLUE}[INFO] Script header detected, using --sandbox flag...${RESET}\n"
87- ./bin/uvx marimo export html --sandbox --include-code --output "_marimushka/$dir_path/$base_name.html" "$py_file"
88- else
89- printf " ${BLUE}[INFO] No script header detected, using standard export...${RESET}\n"
90- ./bin/uv run marimo export html --include-code --output "_marimushka/$dir_path/$base_name.html" "$py_file"
91- fi
92- done
93- echo "<html><head><title>Marimo Notebooks</title></head><body><h1>Marimo Notebooks</h1><ul>" > _marimushka/index.html
94- find _marimushka -name "*.html" -not -path "*index.html" | sort | while read html_file; do
95- rel_path=$(echo "$html_file" | sed "s|^_marimushka/||")
96- name=$(basename "$rel_path" .html)
97- echo "<li><a href=\"$rel_path\">$name</a></li>" >> _marimushka/index.html
98- done
99- echo "</ul></body></html>" >> _marimushka/index.html
100- touch _marimushka/.nojekyll
101- fi
102- fi
103-
104- book :
105- desc : Build the companion book with test results and notebooks
106- cmds :
107- - ./bin/task build:install
108- - printf "${BLUE}[INFO] Building combined documentation...${RESET}\n"
109- - printf "${BLUE}[INFO] Delete the _book folder...${RESET}\n"
110- - rm -rf _book
111- - printf "${BLUE}[INFO] Create empty _book folder...${RESET}\n"
112- - mkdir -p _book
113- - touch _book/links.json
114- - |
115- printf "${BLUE}[INFO] Copy API docs...${RESET}\n"
116- if [ -d _pdoc ]; then
117- mkdir -p _book/pdoc
118- cp -r _pdoc/* _book/pdoc
119- echo '{"API": "./pdoc/index.html"}' > _book/links.json
120- else
121- echo '{}' > _book/links.json
122- fi
123-
124- printf "${BLUE}[INFO] Copy coverage report...${RESET}\n"
125- if [ -d _tests/html-coverage ] && [ "$(ls -A _tests/html-coverage 2>/dev/null)" ]; then
126- mkdir -p _book/tests/html-coverage
127- cp -r _tests/html-coverage/* _book/tests/html-coverage
128- jq '. + {"Coverage": "./tests/html-coverage/index.html"}' _book/links.json > _book/tmp && mv _book/tmp _book/links.json
129- else
130- printf "${YELLOW}[WARN] No coverage report found or directory is empty${RESET}\n"
131- fi
132-
133- printf "${BLUE}[INFO] Copy test report...${RESET}\n"
134- if [ -d _tests/html-report ] && [ "$(ls -A _tests/html-report 2>/dev/null)" ]; then
135- mkdir -p _book/tests/html-report
136- cp -r _tests/html-report/* _book/tests/html-report
137- jq '. + {"Test Report": "./tests/html-report/report.html"}' _book/links.json > _book/tmp && mv _book/tmp _book/links.json
138- else
139- printf "${YELLOW}[WARN] No test report found or directory is empty${RESET}\n"
140- fi
141-
142- printf "${BLUE}[INFO] Copy notebooks...${RESET}\n"
143- if [ -d _marimushka ] && [ "$(ls -A _marimushka 2>/dev/null)" ]; then
144- mkdir -p _book/marimushka
145- cp -r _marimushka/* _book/marimushka
146- jq '. + {"Notebooks": "./marimushka/index.html"}' _book/links.json > _book/tmp && mv _book/tmp _book/links.json
147- printf "${BLUE}[INFO] Copied notebooks from {{.MARIMO_FOLDER}} to _book/marimushka${RESET}\n"
148- else
149- printf "${YELLOW}[WARN] No notebooks found or directory is empty${RESET}\n"
150- fi
151-
152- printf "${BLUE}[INFO] Generated links.json:${RESET}\n"
153- cat _book/links.json
154-
155- ./bin/uvx minibook --title "{{.BOOK_TITLE}}" --subtitle "{{.BOOK_SUBTITLE}}" --links "$(cat _book/links.json)" --output "_book"
156-
157- touch "_book/.nojekyll"
158-
159- marimo :
160- desc : Start a Marimo server
161- cmds :
162- - ./bin/task build:install
163- - printf " ${BLUE}[INFO] Start Marimo server with {{.MARIMO_FOLDER}}...${RESET}\n"
164- - |
165- if [ ! -d "{{.MARIMO_FOLDER}}" ]; then
166- printf " ${YELLOW}[WARN] Marimo folder '{{.MARIMO_FOLDER}}' not found, skipping start${RESET}\n"
167- else
168- ./bin/uv sync --all-extras
169- ./bin/uv run marimo edit "{{.MARIMO_FOLDER}}"
170- fi
0 commit comments