diff --git a/lib/blueprint-job-code.ts b/lib/blueprint-job-code.ts new file mode 100644 index 0000000..7d66e0a --- /dev/null +++ b/lib/blueprint-job-code.ts @@ -0,0 +1,27 @@ +export const blueprintJobCode = { + square: `use blueprint_sdk::macros::debug_job; +use blueprint_sdk::tangle::extract::{TangleArg, TangleResult}; + +#[debug_job] +pub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult { + let result = x * x; + TangleResult(result) +}`, + router: `use blueprint_sdk::macros::debug_job; +use blueprint_sdk::tangle::extract::{TangleArg, TangleResult}; +use blueprint_sdk::tangle::TangleLayer; +use blueprint_sdk::{Job, Router}; + +pub const XSQUARE_JOB_ID: u8 = 0; + +#[debug_job] +pub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult { + let result = x * x; + TangleResult(result) +} + +#[must_use] +pub fn router() -> Router { + Router::new().route(XSQUARE_JOB_ID, square.layer(TangleLayer)) +}`, +}; diff --git a/pages/developers/blueprint-runner/jobs.mdx b/pages/developers/blueprint-runner/jobs.mdx index 2f1cf25..6c4bd5d 100644 --- a/pages/developers/blueprint-runner/jobs.mdx +++ b/pages/developers/blueprint-runner/jobs.mdx @@ -2,7 +2,8 @@ title: Jobs --- -import GithubFileReaderDisplay from '/components/GithubFileReaderDisplay'; +import CodeDisplay from '/components/CodeDisplay'; +import { blueprintJobCode } from '/lib/blueprint-job-code'; # Jobs @@ -29,18 +30,18 @@ Jobs in a Blueprint are defined in the library package of your project. A job de ### Basic Job Structure -This source excerpt defines `square` in the Incredible Squaring example. -Run it as part of that example project. +A squaring handler with its imports, for `src/lib.rs` in a Blueprint project: - In this example: -- The router registers `square` under the `XSQUARE_JOB_ID` constant +- The router below registers `square` under the `XSQUARE_JOB_ID` constant - `square` is the function that implements the job's logic - The job takes a single ABI-encoded input parameter `x` extracted by `TangleArg<(u64,)>` - The job returns a `TangleResult`, which the runner ABI-encodes for submission @@ -60,12 +61,14 @@ See the [Contexts guide](/developers/contexts/introduction) for complete example ## Job Registration -Jobs need to be registered to a route with the [router](/developers/blueprint-runner/routers) to be accessible. This is done when defining a Blueprint Runner: +Register the handler with the [router](/developers/blueprint-runner/routers). +This complete `src/lib.rs` registers the squaring job on the Tangle layer: - ## Job Execution Flow diff --git a/review-evidence/docs-jobs-20261002/README.md b/review-evidence/docs-jobs-20261002/README.md new file mode 100644 index 0000000..23e6051 --- /dev/null +++ b/review-evidence/docs-jobs-20261002/README.md @@ -0,0 +1,14 @@ +# Jobs code examples + +Before: https://docs.tangle.tools/developers/blueprint-runner/jobs, served shared CodeDisplay from Docs #190. +After: real Next dev preview of the changed Jobs page, based on `31a50b6`. +Viewports: 1440 × 1000 and 390 × 1000; light and dark themes. + +The copy recording runs at normal speed; the MP4 is a format conversion of the retained WebM original. +`proof.json` records exact clipboard text, keyboard focus and code scrolling, and document width. +Both snippets contain their own imports and definitions and preserve indentation. +Imports, handler, job constant and route were checked against SDK commit `9acf12127c9ef89b9ffcfb95dd5371dca4326531`. +The router example keeps that source's single `square` route. +The rendered page and source links were checked; a separate Cargo compilation was not run. + +These review artifacts are outside the documentation's application and public directories. diff --git a/review-evidence/docs-jobs-20261002/after-1440-light-0.png b/review-evidence/docs-jobs-20261002/after-1440-light-0.png new file mode 100644 index 0000000..fee8fdf Binary files /dev/null and b/review-evidence/docs-jobs-20261002/after-1440-light-0.png differ diff --git a/review-evidence/docs-jobs-20261002/after-1440-light-1.png b/review-evidence/docs-jobs-20261002/after-1440-light-1.png new file mode 100644 index 0000000..5f706f8 Binary files /dev/null and b/review-evidence/docs-jobs-20261002/after-1440-light-1.png differ diff --git a/review-evidence/docs-jobs-20261002/after-390-dark-1.png b/review-evidence/docs-jobs-20261002/after-390-dark-1.png new file mode 100644 index 0000000..49556ae Binary files /dev/null and b/review-evidence/docs-jobs-20261002/after-390-dark-1.png differ diff --git a/review-evidence/docs-jobs-20261002/after-390-light-0.png b/review-evidence/docs-jobs-20261002/after-390-light-0.png new file mode 100644 index 0000000..e723a9b Binary files /dev/null and b/review-evidence/docs-jobs-20261002/after-390-light-0.png differ diff --git a/review-evidence/docs-jobs-20261002/after-390-light-1.png b/review-evidence/docs-jobs-20261002/after-390-light-1.png new file mode 100644 index 0000000..68dcf0e Binary files /dev/null and b/review-evidence/docs-jobs-20261002/after-390-light-1.png differ diff --git a/review-evidence/docs-jobs-20261002/before-1440.png b/review-evidence/docs-jobs-20261002/before-1440.png new file mode 100644 index 0000000..e7c103d Binary files /dev/null and b/review-evidence/docs-jobs-20261002/before-1440.png differ diff --git a/review-evidence/docs-jobs-20261002/before-390.png b/review-evidence/docs-jobs-20261002/before-390.png new file mode 100644 index 0000000..45bff13 Binary files /dev/null and b/review-evidence/docs-jobs-20261002/before-390.png differ diff --git a/review-evidence/docs-jobs-20261002/before-registration-1440.png b/review-evidence/docs-jobs-20261002/before-registration-1440.png new file mode 100644 index 0000000..aa912ff Binary files /dev/null and b/review-evidence/docs-jobs-20261002/before-registration-1440.png differ diff --git a/review-evidence/docs-jobs-20261002/before-registration-390.png b/review-evidence/docs-jobs-20261002/before-registration-390.png new file mode 100644 index 0000000..e9ee906 Binary files /dev/null and b/review-evidence/docs-jobs-20261002/before-registration-390.png differ diff --git a/review-evidence/docs-jobs-20261002/copy-mobile.mp4 b/review-evidence/docs-jobs-20261002/copy-mobile.mp4 new file mode 100644 index 0000000..e9f6432 Binary files /dev/null and b/review-evidence/docs-jobs-20261002/copy-mobile.mp4 differ diff --git a/review-evidence/docs-jobs-20261002/copy-mobile.webm b/review-evidence/docs-jobs-20261002/copy-mobile.webm new file mode 100644 index 0000000..e3afe91 Binary files /dev/null and b/review-evidence/docs-jobs-20261002/copy-mobile.webm differ diff --git a/review-evidence/docs-jobs-20261002/proof.json b/review-evidence/docs-jobs-20261002/proof.json new file mode 100644 index 0000000..7535fcf --- /dev/null +++ b/review-evidence/docs-jobs-20261002/proof.json @@ -0,0 +1,104 @@ +[ + { + "width": 1440, + "theme": "light", + "sections": [ + { + "i": 0, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L25-L87", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 830, + "overflow": 830, + "left": 0 + } + }, + { + "i": 1, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\nuse blueprint_sdk::tangle::TangleLayer;\nuse blueprint_sdk::{Job, Router};\n\npub const XSQUARE_JOB_ID: u8 = 0;\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}\n\n#[must_use]\npub fn router() -> Router {\n Router::new().route(XSQUARE_JOB_ID, square.layer(TangleLayer))\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L201-L217", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 830, + "overflow": 830, + "left": 0 + } + } + ], + "widthState": { + "client": 1440, + "scroll": 1440 + } + }, + { + "width": 390, + "theme": "light", + "sections": [ + { + "i": 0, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L25-L87", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 340, + "overflow": 730, + "left": 4 + } + }, + { + "i": 1, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\nuse blueprint_sdk::tangle::TangleLayer;\nuse blueprint_sdk::{Job, Router};\n\npub const XSQUARE_JOB_ID: u8 = 0;\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}\n\n#[must_use]\npub fn router() -> Router {\n Router::new().route(XSQUARE_JOB_ID, square.layer(TangleLayer))\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L201-L217", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 340, + "overflow": 730, + "left": 40 + } + } + ], + "widthState": { + "client": 390, + "scroll": 390 + } + }, + { + "width": 390, + "theme": "dark", + "sections": [ + { + "i": 0, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L25-L87", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 340, + "overflow": 730, + "left": 1 + } + }, + { + "i": 1, + "copied": "use blueprint_sdk::macros::debug_job;\nuse blueprint_sdk::tangle::extract::{TangleArg, TangleResult};\nuse blueprint_sdk::tangle::TangleLayer;\nuse blueprint_sdk::{Job, Router};\n\npub const XSQUARE_JOB_ID: u8 = 0;\n\n#[debug_job]\npub async fn square(TangleArg((x,)): TangleArg<(u64,)>) -> TangleResult {\n let result = x * x;\n TangleResult(result)\n}\n\n#[must_use]\npub fn router() -> Router {\n Router::new().route(XSQUARE_JOB_ID, square.layer(TangleLayer))\n}", + "source": "https://github.com/tangle-network/blueprint/blob/9acf12127c9ef89b9ffcfb95dd5371dca4326531/examples/incredible-squaring/incredible-squaring-lib/src/lib.rs#L201-L217", + "copiedFeedback": "Copied", + "focus": true, + "scroll": { + "width": 340, + "overflow": 730, + "left": 1 + } + } + ], + "widthState": { + "client": 390, + "scroll": 390 + } + } +] \ No newline at end of file