Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Docs

# Checks the documentation on every pull request. GitHub Pages publishing remains enabled during the
# Read the Docs transition; see docs/index.md for the cutover and old-URL redirect steps.
# Read the Docs hosts the site. This workflow only validates documentation changes.

on:
pull_request:
Expand All @@ -18,26 +17,13 @@ jobs:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uv sync --locked --group docs
- uses: actions/setup-node@v4
with:
node-version: "24"
- run: npm ci --ignore-scripts
- run: npm test
- run: uv run --group docs pytest -q docs/tests
- run: uv run --group docs python docs/catalogue.py
- run: uv run ruff check docs
- run: uv run ruff format --check docs
- run: uv run --group docs mkdocs build --strict
- if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: site

deploy:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ __pycache__/
build/
dist/
site/

.cache/
node_modules/
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Browse the [algorithm catalogue](https://meds-algorithm.readthedocs.io/en/latest
for implementations, reviewed installation commands and validation evidence. Register or update an
entry through `catalogue/algorithms.yaml`; documentation builds and release observations are independent
of the runtime package and never query private source repositories. See
[site maintenance](https://github.com/McDermottHealthAI/meds-algorithm/blob/main/docs/index.md).
[site maintenance](https://meds-algorithm.readthedocs.io/en/latest/documentation/).

The [unified documentation](https://meds-algorithm.readthedocs.io/en/latest/) also contains the
template workflow, [implementation prompt builder](https://meds-algorithm.readthedocs.io/en/latest/prompt-builder/),
manual tutorial, publishing guides and API/UML references.

## Package layout

Expand Down Expand Up @@ -142,8 +146,10 @@ training. Keep each algorithm's data-access and cluster approval rules in its ow

### Unreleased

- Consolidate the template guides, implementation prompt and interactive builder on Read the Docs;
use Read the Docs as the only documentation host.
- Configure Read the Docs hosting with the existing MkDocs theme and docs dependency group; update
documentation links and document the transition from GitHub Pages.
documentation links and document Read the Docs hosting.
- Host the algorithm catalogue and its release-observation workflow in this ecosystem repository.
- Add independently built documentation; catalogue metadata and tooling are excluded from Python distributions.

Expand Down
19 changes: 19 additions & 0 deletions docs/assets/prompt-builder.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.prompt-builder { --pb-line: var(--md-default-fg-color--lightest, #dce5eb); --pb-bg: var(--md-default-bg-color, #fff); --pb-ink: var(--md-default-fg-color, #182b3d); color: var(--pb-ink); }
.prompt-builder fieldset { min-width: 0; border: 1px solid var(--pb-line); border-radius: 8px; margin: 1.6em 0; padding: 1em 1.25em; }
.prompt-builder legend { padding: 0 .4em; font-weight: 700; }
.prompt-builder label { display: block; margin: .8em 0; font-weight: 600; }
.prompt-builder .pb-hint { display: block; font-size: .86em; font-weight: 400; opacity: .8; margin: .3em 0; }
.prompt-builder input:not([type="checkbox"]), .prompt-builder select, .prompt-builder textarea { display: block; width: 100%; min-width: 0; margin-top: .4em; padding: .65em .75em; border: 1px solid var(--pb-line); border-radius: 5px; color: var(--pb-ink); background: var(--pb-bg); font: inherit; font-weight: 400; }
.prompt-builder input:not([type="checkbox"]) { line-height: 1.4; }
.prompt-builder textarea { resize: vertical; line-height: 1.5; }
.prompt-builder [data-prompt-output] { font: .85em/1.6 Consolas, monospace; white-space: pre-wrap; }
.prompt-builder .pb-check { display: flex; align-items: baseline; gap: .6em; font-weight: 400; }
.prompt-builder input[type="checkbox"] { flex: 0 0 auto; width: 1em; height: 1em; }
.prompt-builder .pb-actions { display: flex; flex-wrap: wrap; gap: .7em; margin: 1em 0; }
.prompt-builder button { padding: .6em 1em; border: 1px solid var(--pb-line); border-radius: 5px; color: var(--pb-ink); background: var(--pb-bg); cursor: pointer; font: inherit; }
.prompt-builder [data-generate] { background: #116b7b; color: #fff; border-color: #116b7b; }
.prompt-builder button:disabled { opacity: .45; cursor: not-allowed; }
.prompt-builder :focus-visible { outline: 3px solid #208bba; outline-offset: 3px; }
.prompt-builder .pb-status { min-height: 1.6em; }
.prompt-builder [hidden] { display: none !important; }
@media (max-width: 600px) { .prompt-builder fieldset { padding: .75em; } }
173 changes: 173 additions & 0 deletions docs/assets/prompt-builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/* No network calls or persisted inputs: the documentation embeds the canonical implementation prompt. */
(function () {
"use strict";
const profiles = ["supervised", "finetune", "probe", "zero_shot_direct", "zero_shot_materialized", "predict_only"];
const scopes = {
local: "Implementation and local tests only.",
integration: "Implementation, local tests and MEDS-DEV integration; stop before the demo.",
full: "Implementation, local tests, MEDS-DEV integration and preparation for demo/full-data evaluation; wait for the existing execution approvals."
};
const clean = (value) => String(value ?? "").trim();
function required(value, label) {
const result = clean(value);
if (!result) throw new Error(`Supply ${label}.`);
return result;
}
function choice(value, allowed, label) {
if (!allowed.includes(value)) throw new Error(`Choose a valid ${label}.`);
return value;
}
function renderPrompt(template, values) {
const source = choice(values.source_kind, ["paper", "code", "both"], "source type");
const destination = choice(values.destination_kind, ["local", "github"], "destination");
const mode = choice(values.profile_mode, ["automatic", "manual"], "profile selection");
const tasks = choice(values.tasks_mode, ["none", "ready"], "task-input option");
const scope = choice(values.scope, Object.keys(scopes), "work scope");
if (values.exploratory_mode !== undefined && typeof values.exploratory_mode !== "boolean") {
throw new Error("Exploratory mode must be an explicit checkbox selection.");
}
let repository = "New local Git repository only; do not create a GitHub repository.";
if (destination === "github") {
const name = required(values.github_repo, "the new GitHub repository")
.replace(/^https:\/\/github\.com\//, "").replace(/\/$/, "");
if (!/^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\/[A-Za-z0-9_.-]+$/.test(name)
|| [".", ".."].includes(name.split("/")[1])) {
throw new Error("Use owner/name or https://github.com/owner/name for the new repository.");
}
const visibility = choice(values.visibility, ["private", "public"], "repository visibility");
repository = `New GitHub repository: https://github.com/${name}; visibility: ${visibility}.`;
}
let selection = "automatic";
if (mode === "manual") {
const selected = Array.isArray(values.profiles) ? [...new Set(values.profiles)] : [];
if (!selected.length || selected.some((name) => !profiles.includes(name))) {
throw new Error("Select at least one supported profile.");
}
selection = `Explicit profiles: ${selected.join(", ")}.`;
}
let bundle = "Not supplied. Continue implementation and synthetic tests; defer evaluation on external task bundles.";
if (tasks === "ready") {
required(values.dataset, "the dataset name, revision and MEDS path for these tasks");
bundle = [
`Prepared labels: ${required(values.labels_path, "the prepared labels location")}`,
`Prepared task configs: ${required(values.configs_path, "the prepared task-config location")}`,
`Bundle revision/identifier: ${required(values.bundle_revision, "the bundle revision or identifier")}`,
`Task subset: ${clean(values.task_subset) || "All tasks already present in this bundle."}`
].join("\n");
}
const replacements = {
PAPER_REFERENCES_OR_NOT_SUPPLIED: source === "code" ? "Not supplied." : required(values.papers, "at least one paper reference"),
CODE_REFERENCES_OR_NOT_SUPPLIED: source === "paper" ? "Not supplied." : required(values.code, "at least one code/repository reference"),
NEW_REPOSITORY_DESTINATION: repository,
NEW_LOCAL_REPOSITORY_PATH: required(values.local_path, "a new local repository path"),
PROFILE_SELECTION: selection,
DATASET_CONTEXT_OR_NOT_SUPPLIED: clean(values.dataset) || "Not supplied; use synthetic data for local implementation tests.",
PREPARED_TASK_BUNDLE_OR_NOT_SUPPLIED: bundle,
WORK_SCOPE: scopes[scope],
SCIENTIFIC_AMBIGUITY_MODE: values.exploratory_mode === true
? "Exploratory mode explicitly enabled: provisional algorithm-design assumptions are permitted under the policy below."
: "Confirmation required (default): ask before implementing material unresolved scientific choices.",
ADDITIONAL_CONSTRAINTS_OR_NONE: clean(values.constraints) || "None."
};
return template.replace(/<([A-Z][A-Z0-9_]*)>/g, (token, key) => {
if (!Object.hasOwn(replacements, key)) throw new Error(`Unknown prompt field: ${token}`);
return replacements[key];
});
}
function init(root) {
if (root.dataset.initialized) return;
const source = root.querySelector("[data-prompt-template]");
if (!source) return;
const template = JSON.parse(source.textContent);
const form = root.querySelector("[data-builder-form]");
const output = root.querySelector("[data-prompt-output]");
const status = root.querySelector("[data-status]");
const copy = root.querySelector("[data-copy]");
const download = root.querySelector("[data-download]");
const generate = root.querySelector("[data-generate]");
const reset = root.querySelector("[data-reset]");
root.dataset.initialized = "true";
let stale = true;
const field = (name) => form.elements.namedItem(name);
function section(name, visible, requiredNames = []) {
const block = root.querySelector(`[data-section="${name}"]`);
block.hidden = !visible;
block.querySelectorAll("input, textarea, select").forEach((input) => {
input.disabled = !visible;
input.required = visible && requiredNames.includes(input.name);
});
}
function update() {
section("papers", field("source_kind").value !== "code", ["papers"]);
section("code", field("source_kind").value !== "paper", ["code"]);
section("github", field("destination_kind").value === "github", ["github_repo"]);
section("profiles", field("profile_mode").value === "manual");
const ready = field("tasks_mode").value === "ready";
section("tasks", ready, ["labels_path", "configs_path", "bundle_revision"]);
field("dataset").required = ready;
}
form.addEventListener("input", () => {
update();
stale = true;
copy.disabled = download.disabled = true;
status.textContent = output.value ? "Inputs changed. Generate again to update the prompt; existing edits remain below." : "Fill in the inputs, then generate your prompt.";
});
form.addEventListener("submit", (event) => {
event.preventDefault();
if (!form.reportValidity()) return;
const data = new FormData(form);
const values = Object.fromEntries(data.entries());
values.profiles = data.getAll("profiles");
values.exploratory_mode = field("exploratory_mode").checked;
try {
output.value = renderPrompt(template, values);
output.readOnly = false;
stale = false;
copy.disabled = download.disabled = false;
status.textContent = "Prompt ready. Review or edit it, then copy or download.";
} catch (error) {
copy.disabled = download.disabled = true;
status.textContent = error.message;
}
});
output.addEventListener("input", () => {
download.disabled = copy.disabled = stale || !output.value.trim();
});
copy.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText(output.value);
status.textContent = "Prompt copied.";
} catch (_) {
output.focus();
output.select();
status.textContent = "Clipboard access is unavailable. The prompt is selected; use Ctrl+C or Command+C.";
}
});
download.addEventListener("click", () => {
const url = URL.createObjectURL(new Blob([output.value], {type: "text/plain;charset=utf-8"}));
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = "meds-algorithm-implementation.txt";
anchor.click();
setTimeout(() => URL.revokeObjectURL(url), 0);
});
reset.addEventListener("click", () => {
form.reset();
stale = true;
update();
output.value = "";
output.readOnly = true;
copy.disabled = download.disabled = true;
status.textContent = "Reset. Fill in the inputs, then generate your prompt.";
});
update();
generate.disabled = reset.disabled = false;
}
if (typeof module !== "undefined" && module.exports) module.exports = {renderPrompt, init};
if (typeof document !== "undefined") {
const start = () => document.querySelectorAll("[data-prompt-builder]").forEach(init);
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start);
else start();
if (typeof document$ !== "undefined") document$.subscribe(start);
}
})();
Loading
Loading