From 99468003d1ee9ab497488c93f2768056db92f3d7 Mon Sep 17 00:00:00 2001 From: bblietz Date: Tue, 19 May 2026 17:22:01 -0700 Subject: [PATCH] docs: tag bare BrightScript code fences + add brightscript-fence-required lint rule Audit step 2 of dev-doc-review-report-2026-05-16.md. Tags every bare ``` fence whose body is confidently BrightScript so the renderer can apply syntax highlighting, and ships a docs-lint rule to prevent regression. Sweep results (across docs/DEVELOPER, docs/REFERENCES, docs/SPECIFICATIONS, docs/THE ROKU CHANNEL): - Total bare fences identified: 644 (regex+mdast aware of 0-3 space and blockquote indent) - Auto-tagged 568 fences in 154 files: - brightscript: 499 (315 strong-signal, 143 directory-context, 8 hand-patched for deep-indented or blockquote fences the regex sweep missed) - c: 25 (debugger protocol struct/enum in socket-based-debugger.md; tagging as `brightscript` would have actively miscolored them) - text: 22 (Roku channel manifest snippets, BRS debug dumps like ` = { ... }`, URL templates) - json: 7 - http: 6 - xml: 1 - Left bare: 76 fences with truly ambiguous content (Robot Framework test files, single-line `pkg:/...` paths, RAF API schema descriptions, math notation, release-notes literal dumps) New tooling: - `.github/scripts/docs-lint/lib/code-fence-classifier.mjs` - shared classifier returning {lang, confidence, signals}. Conservative; prefers 'unknown' over guessing. Used by the one-shot sweep tool AND the new lint rule below. - `.github/scripts/docs-lint/rules/code-fences.mjs` - new `brightscript-fence-required` rule: any bare fence whose body classifies as BrightScript with confidence >= 0.7 is reported as an error. - `.github/scripts/docs-lint/index.mjs` - wired the new rule into the RULES array. Classifier signals (BrightScript): `sub`/`function`/`end sub`/`end function`/ `endif`/`endwhile`/`endfor` keywords; `as Type` annotations (String, Integer, Boolean, Object, Dynamic, Float, etc.); `CreateObject("ro...")`; `m.top`/ `m.global`/`m.video`/`m.field` references; ro-prefixed object names (roSGNode, roMessagePort, roByteArray, ...); BRS REPL prompt (`BrightScript> `); BRS line comments (`'`); hex literals (`&h...`); `Library "...brs"` statement; `Roku_Ads()` framework call; `observeFieldScoped` / `callFunc` methods. Two or more signals -> 0.95 confidence; one high-specificity signal -> 0.85; one weak signal alone stays below the 0.7 act-threshold. Classifier signals (non-BRS): XML opener (`` BRS debug-dump format to `text` not `xml` -- audit caught those as false-positives during dry-run. Directory-context pass (sweep tool only, NOT the lint rule): In confirmed BRS directories (REFERENCES/brightscript/, REFERENCES/scenegraph/, DEVELOPER/core-concepts/, DEVELOPER/advertising/, DEVELOPER/media-playback/, DEVELOPER/getting-started/, DEVELOPER/dev-tools/, DEVELOPER/discovery/, DEVELOPER/voice/, DEVELOPER/performance-guide/), fences that don't hit strong classifier signals AND don't contain explicit non-BRS content are promoted to brightscript with `directory-context` justification. Catches 1-line BRS method calls like `adIface.setAdUrl(myAdUrl)` that have no distinctive BRS keywords on their own but live in unambiguously-BRS docs. Lint baseline preserved: docs-lint shows the same 3 findings as before (all in `REFERENCES/brightscript/interfaces/ifscreen.md`, unchanged) and ZERO `brightscript-fence-required` errors after the sweep. Out of scope (separate follow-up): - Audit's `roku-pay-best_practices` underscore mismatch claim - already fixed upstream before this PR; not visible. - One pre-existing malformed fence with code in the info string (`createobject("roprogramguide")```` not properly closed) - flagged for manual review; not in scope here. - The remaining 76 truly-ambiguous fences (Robot Framework, schema descriptions, paths, release-notes literals) - intentionally left bare so the renderer treats them as plain text rather than try to syntax-highlight them as BRS or another language. --- .github/scripts/docs-lint/index.mjs | 3 +- .../docs-lint/lib/code-fence-classifier.mjs | 270 ++++++++++++++++++ .../scripts/docs-lint/rules/code-fences.mjs | 37 +++ docs/DEVELOPER/advertising/csas.md | 4 +- .../integrating-roku-advertising-framework.md | 48 ++-- docs/DEVELOPER/advertising/raf-api.md | 2 +- docs/DEVELOPER/advertising/ssai-adapters.md | 18 +- .../on-device-authentication.md | 8 +- ...hentication-protocol-for-single-sign-on.md | 4 +- .../controlling-screen-program-flow.md | 2 +- docs/DEVELOPER/core-concepts/data-scoping.md | 12 +- .../developing-scenegraph-applications.md | 8 +- .../downloading-server-content.md | 2 +- docs/DEVELOPER/core-concepts/event-loops.md | 16 +- .../handling-application-events.md | 18 +- docs/DEVELOPER/core-concepts/localization.md | 10 +- .../DEVELOPER/core-concepts/playing-videos.md | 8 +- .../scenegraph-brightscript/index.md | 2 +- docs/DEVELOPER/core-concepts/threads.md | 4 +- .../creating-custom-components.md | 2 +- .../core-concepts/xml-components/index.md | 2 +- docs/DEVELOPER/debugging/index.md | 12 +- .../debugging/socket-based-debugger.md | 50 ++-- .../javascript-library.md | 2 +- docs/DEVELOPER/dev-tools/brightscript-doc.md | 2 +- .../dev-tools/brightscript-profiler.md | 4 +- .../dev-tools/external-control-api.md | 2 +- .../command-line-utility.md | 2 +- .../discovery/continue-watching-cloud.md | 6 +- docs/DEVELOPER/discovery/continue-watching.md | 6 +- .../discovery/implementing-deep-linking.md | 12 +- docs/DEVELOPER/discovery/instant-signup.md | 4 +- ...g-authenticated-channels-in-roku-search.md | 10 +- .../architecture/channel-manifest.md | 2 +- .../architecture/content-metadata.md | 10 +- .../architecture/file-system.md | 6 +- docs/DEVELOPER/libraries/index.md | 22 +- docs/DEVELOPER/media-playback/bookmarking.md | 10 +- .../media-playback/closed-caption.md | 2 +- .../media-playback/fast-video-start.md | 2 +- .../media-playback/instant-resume.md | 6 +- .../trick-mode/bif-file-creation.md | 2 +- .../voice-controls/transport-controls.md | 8 +- .../voice-controls/voice-profile-selector.md | 8 +- .../performance-guide/data-management.md | 2 +- .../performance-guide/data-transfer-apis.md | 20 +- .../measuring-channel-performance.md | 6 +- .../optimization-techniques.md | 4 +- docs/DEVELOPER/release-notes/index.md | 2 +- .../release-notes/raf-release-notes.md | 2 +- .../on-device-upgrade-downgrade.md | 6 +- .../implementation/push-notifications-jwt.md | 2 +- .../implementation/push-notifications.md | 2 +- .../implementation/roku-web-service.md | 12 +- .../tracking-signup-abandonment.md | 2 +- .../implementation/tvod-app-catalog.md | 4 +- .../roku-pay/implementation/tvod-channel.md | 12 +- .../quickstart/add-ons-integration.md | 14 +- .../subscription-on-hold.md | 4 +- .../brightscript/components/roappinfo.md | 4 +- .../components/roassociativearray.md | 6 +- .../components/roaudiometadata.md | 2 +- .../brightscript/components/roaudioplayer.md | 2 +- .../components/roaudioresource.md | 6 +- .../brightscript/components/robitmap.md | 4 +- .../brightscript/components/robytearray.md | 2 +- .../brightscript/components/rocompositor.md | 2 +- .../components/rodatagramsocket.md | 2 +- .../brightscript/components/rodatetime.md | 2 +- .../brightscript/components/rodevicecrypto.md | 2 +- .../brightscript/components/rodeviceinfo.md | 4 +- .../brightscript/components/roevpdigest.md | 4 +- .../brightscript/components/rofont.md | 2 +- .../brightscript/components/rofontregistry.md | 4 +- .../brightscript/components/rohmac.md | 2 +- .../components/roimagemetadata.md | 4 +- .../brightscript/components/roinput.md | 2 +- .../brightscript/components/roint.md | 2 +- .../brightscript/components/rolist.md | 4 +- .../brightscript/components/rolocalization.md | 2 +- .../brightscript/components/ropath.md | 2 +- .../components/roregistrysection.md | 2 +- .../brightscript/components/roremoteinfo.md | 4 +- .../brightscript/components/rorsa.md | 4 +- .../brightscript/components/roscreen.md | 4 +- .../brightscript/components/rosgscreen.md | 2 +- .../brightscript/components/rostreamsocket.md | 4 +- .../components/rotexturemanager.md | 2 +- .../components/rotexturerequest.md | 6 +- .../brightscript/components/rotimespan.md | 2 +- .../brightscript/components/rourltransfer.md | 2 +- .../brightscript/components/roxmlelement.md | 8 +- .../brightscript/events/rocecstatusevent.md | 2 +- .../brightscript/events/rosgscreenevent.md | 2 +- .../brightscript/events/rovideoplayerevent.md | 2 +- .../brightscript/interfaces/ifappmanager.md | 8 +- .../interfaces/ifappmemorymonitor.md | 2 +- .../brightscript/interfaces/ifarrayjoin.md | 2 +- .../brightscript/interfaces/ifarrayslice.md | 2 +- .../brightscript/interfaces/ifarraysort.md | 6 +- .../interfaces/ifassociativearray.md | 2 +- .../brightscript/interfaces/ifbytearray.md | 4 +- .../brightscript/interfaces/ifchannelstore.md | 10 +- .../brightscript/interfaces/ifdevicecrypto.md | 2 +- .../brightscript/interfaces/ifdeviceinfo.md | 6 +- .../brightscript/interfaces/ifdraw2d.md | 4 +- .../brightscript/interfaces/ifdsa.md | 8 +- .../brightscript/interfaces/ifevpcipher.md | 4 +- .../brightscript/interfaces/ifevpdigest.md | 4 +- .../brightscript/interfaces/iffunction.md | 2 +- .../brightscript/interfaces/ifhmac.md | 2 +- .../brightscript/interfaces/ifregex.md | 10 +- .../brightscript/interfaces/ifregistry.md | 2 +- .../interfaces/ifrenderthreadqueue.md | 2 +- .../interfaces/ifsgnodeboundingrect.md | 2 +- .../interfaces/ifsgnodechildren.md | 2 +- .../brightscript/interfaces/ifsgnodedict.md | 6 +- .../brightscript/interfaces/ifsgnodefield.md | 18 +- .../brightscript/interfaces/ifsgscreen.md | 2 +- .../brightscript/interfaces/ifstring.md | 2 +- .../brightscript/interfaces/ifstringops.md | 52 ++-- .../brightscript/interfaces/iftimespan.md | 4 +- .../brightscript/interfaces/iftostr.md | 8 +- .../brightscript/interfaces/ifurltransfer.md | 2 +- .../brightscript/interfaces/ifutils.md | 6 +- .../language/component-architecture.md | 34 +-- .../language/conditional-compilation.md | 12 +- .../brightscript/language/error-handling.md | 38 +-- .../language/expressions-variables-types.md | 58 ++-- .../brightscript/language/format-strings.md | 2 +- .../language/global-string-functions.md | 32 +-- .../language/global-utility-functions.md | 24 +- .../language/program-statements.md | 60 ++-- .../language/runtime-functions.md | 16 +- .../language/statement-summary.md | 6 +- .../scenegraph/animation-nodes/animation.md | 2 +- .../scenegraph/component-functions/init.md | 2 +- .../component-functions/onkeyevent.md | 4 +- .../scenegraph/control-nodes/channelstore.md | 16 +- .../scenegraph/control-nodes/contentnode.md | 10 +- .../dynamic-custom-keyboard.md | 8 +- .../key-definition-file.md | 12 +- .../label-nodes/multi-style-label.md | 2 +- .../list-and-grid-nodes/targetlist.md | 8 +- docs/REFERENCES/scenegraph/scene.md | 2 +- .../sliding-panels-nodes/gridpanel.md | 2 +- .../scenegraph/sliding-panels-nodes/index.md | 2 +- .../sliding-panels-nodes/listpanel.md | 2 +- .../overhangpanelsetscene.md | 2 +- .../standard-dialog-framework-nodes/index.md | 6 +- .../std-dlg-multi-style-text-item.md | 2 +- .../scenegraph/typographic-nodes/font.md | 2 +- .../scenegraph/xml-elements/script.md | 2 +- .../media/content-protection.md | 10 +- docs/SPECIFICATIONS/media/index.md | 4 +- .../video-on-demand/delivery/index.md | 2 +- 156 files changed, 877 insertions(+), 569 deletions(-) create mode 100644 .github/scripts/docs-lint/lib/code-fence-classifier.mjs create mode 100644 .github/scripts/docs-lint/rules/code-fences.mjs diff --git a/.github/scripts/docs-lint/index.mjs b/.github/scripts/docs-lint/index.mjs index 8bce140b..1bc94b17 100644 --- a/.github/scripts/docs-lint/index.mjs +++ b/.github/scripts/docs-lint/index.mjs @@ -22,8 +22,9 @@ import remarkGfm from 'remark-gfm' import { Reporter, printReport } from './lib/report.mjs' import * as tables from './rules/tables.mjs' +import * as codeFences from './rules/code-fences.mjs' -const RULES = [tables] +const RULES = [tables, codeFences] const SYNC_PATHS = [ 'docs/**/*.md', diff --git a/.github/scripts/docs-lint/lib/code-fence-classifier.mjs b/.github/scripts/docs-lint/lib/code-fence-classifier.mjs new file mode 100644 index 00000000..06d2514b --- /dev/null +++ b/.github/scripts/docs-lint/lib/code-fence-classifier.mjs @@ -0,0 +1,270 @@ +/** + * Classify a code-fence body to a likely language. + * + * Returns: { lang, confidence, signals } + * lang: 'brightscript' | 'xml' | 'json' | 'c' | 'bash' | 'http' | 'text' | 'unknown' | 'empty' + * confidence: 0..1 -- only act on a classification when >= 0.7 + * signals: string[] -- explanations of what tipped the classifier + * + * Conservative by design: prefers 'unknown' over guessing. The + * `brightscript-fence-required` lint rule and the one-shot sweep tool + * both import this so they agree on what "looks like BRS" means. + */ + +// --------------------------------------------------------------------------- +// Hard, single-signal classifications run first. Their match is decisive. +// --------------------------------------------------------------------------- + +function tryHardSignals(text, lines) { + // Single URL line: bare http(s)://... with no other content + if (/^https?:\/\/\S+\s*$/.test(text) && lines.length === 1) { + return { lang: 'text', confidence: 0.95, signals: ['single URL line'] }; + } + + // Base64 / JWT / long token: one or two lines, all `[A-Za-z0-9+/=._-]`, >= 120 chars + const noWS = text.replace(/\s+/g, ''); + if (noWS.length >= 120 && /^[A-Za-z0-9+/=._-]+$/.test(noWS) && lines.length <= 3) { + return { lang: 'text', confidence: 0.9, signals: ['long base64-like token'] }; + } + + // XML declaration + if (/^\s*<\?xml/.test(text)) { + return { lang: 'xml', confidence: 1.0, signals: [' = { ... }`. Not XML. + // Match BEFORE the XML detector below so we don't misroute these. + if (/^\s*<\s*Component\s*:\s*\w+/.test(text)) { + return { + lang: 'text', + confidence: 0.9, + signals: [' BRS debug-dump (not XML)'], + }; + } + + // SceneGraph / known XML root tags. Require a real tag boundary + // (whitespace + attribute, or self-close, or close angle bracket) so we + // do NOT match `` BRS dumps. + const sgTagNames = [ + 'component', 'interface', 'script', 'children', 'field', 'customization', + 'MainScene', 'Group', 'Rectangle', 'Label', 'Poster', 'Animation', + 'StandardDialog', 'RowList', 'MarkupGrid', 'MarkupList', 'Task', + 'TimeGrid', 'ChannelStore', 'Scene', 'Overhang', 'Video', 'Audio', + 'Button', 'ButtonGroup', 'RadioButtonList', 'CheckList', 'Keyboard', + 'KeyboardDialog', 'MiniKeyboard', 'StandardMessageDialog', + 'StandardKeyboardDialog', 'StandardProgressDialog', 'MultiVoiceKey', + 'VoiceKey', 'TextEditBox', 'TextEditBoxDialog', 'VoiceTextEditBox', + 'VoiceTextEditBoxDialog', + ].join('|'); + const sgTagRE = new RegExp(`^\\s*<\\s*(${sgTagNames})(\\s+\\w+\\s*=|\\s*/?>|\\s*$)`, 'i'); + if (sgTagRE.test(text)) { + return { lang: 'xml', confidence: 0.95, signals: ['SceneGraph XML opener'] }; + } + + // Generic XML: a majority of non-empty lines look like opening or closing tags + const nonEmpty = lines.filter((l) => l.trim().length > 0); + if (nonEmpty.length >= 3) { + const xmlLines = nonEmpty.filter((l) => /^\s*<\/?\w/.test(l)).length; + if (xmlLines / nonEmpty.length >= 0.6) { + return { + lang: 'xml', + confidence: 0.85, + signals: [`${xmlLines}/${nonEmpty.length} XML-tag lines`], + }; + } + } + + // C struct / enum (used in DEVELOPER/debugging/socket-based-debugger.md) + if (/^\s*(struct|enum)\s+\w+\s*\{/m.test(text)) { + return { lang: 'c', confidence: 0.95, signals: ['C struct/enum declaration'] }; + } + + // Shebang or shell prompt + if (/^\s*#!\s*\//m.test(text) || /^\s*\$\s+\w/m.test(text)) { + return { lang: 'bash', confidence: 0.9, signals: ['shell prompt or shebang'] }; + } + + // Roku channel `manifest` file: every non-empty line is `key=value` AND at + // least one line is a known manifest key. + const MANIFEST_KEYS = /^(title|subtitle|major_version|minor_version|build_version|mm_icon_focus_(hd|fhd|uhd|sd)|splash_screen_(hd|fhd|uhd|sd)|splash_color|splash_min_time|ui_resolutions|hidden|requires_audioguide|supports_input_launch|bs_libs_required|sg_component_libs_required|usage_type|version|run_on_startup|game_keymap|playback_intent|requires_internet|requires_persistent_storage|launch_priority|requires_verimatrix_drm|requires_verimatrix_version|requires_widevine_drm|requires_playready_drm|drm_levels)\s*=/; + const nonEmptyLinesMan = lines.filter((l) => l.trim().length > 0); + if ( + nonEmptyLinesMan.length >= 1 && + nonEmptyLinesMan.every((l) => /^[a-zA-Z_][a-zA-Z0-9_]*\s*=/.test(l)) && + nonEmptyLinesMan.some((l) => MANIFEST_KEYS.test(l)) + ) { + return { lang: 'text', confidence: 0.85, signals: ['Roku manifest key=value line(s)'] }; + } + + // HTTP request line (path-form: `GET /foo` or URL-form: `POST https://...`) + if (/^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS)\s+(\/|https?:\/\/)\S/m.test(text)) { + return { lang: 'http', confidence: 0.9, signals: ['HTTP request line'] }; + } + + return null; +} + +// --------------------------------------------------------------------------- +// BrightScript: a single strong signal is enough. Many signals are unique to +// BRS (m.top, CreateObject("ro...), as String, end sub, BrightScript> REPL +// prompt) so false positives are rare. +// +// IMPORTANT: BRS check runs BEFORE the generic JSON check, because BRS +// associative-array literals can look JSON-ish ({ key: "val" }). We let any +// BRS signal short-circuit the JSON check. +// --------------------------------------------------------------------------- + +const BRS_PATTERNS = [ + [/\bsub\s+\w+\s*\(/i, 'sub keyword'], + [/\bfunction\s+\w+\s*\(/i, 'function keyword'], + [/\bend\s*sub\b/i, 'end sub'], + [/\bend\s*function\b/i, 'end function'], + [/\bend\s*if\b/i, 'endif'], + [/\bend\s*while\b/i, 'endwhile'], + [/\bend\s*for\b/i, 'endfor'], + [/\bas\s+(String|Integer|Boolean|Object|Dynamic|Float|Double|LongInteger|Void|Function|Interface)\b/, 'as Type annotation'], + [/\b[cC]reateObject\s*\(\s*"[Rr]o[A-Za-z]/, 'CreateObject("ro...")'], + [/\bm\.(top|global|video)\b/, 'm.top/global/video'], + [/(^|[^.\w])m\.\w+\s*=/m, 'm.field assignment'], + [/(^|[^.\w])m\.\w+\.\w+\s*\(/m, 'm.field.method() call'], + [/(^|[^.\w])m\.\w+/m, 'm. field reference'], + [/\bLibrary\s+"[\w./]+\.brs"/i, 'Library "...brs" statement'], + [/\bRoku_Ads(_SG)?\s*\(/, 'Roku_Ads() framework call'], + [/(^|[^.\w])tr\s*\(\s*"/, 'tr() translation call'], + [/\.observeFieldScoped\s*\(/i, 'observeFieldScoped'], + [/\.callFunc(tion)?\s*\(/i, 'callFunc()'], + [ + /\bro(SGNode|MessagePort|ByteArray|UrlTransfer|Regex|DeviceInfo|AppInfo|Timespan|FontRegistry|Screen|Bitmap|FileSystem|AssociativeArray|Region|VideoPlayer|AudioPlayer|RegistrySection|ChannelStore|Path|Sprite|Compositor|TextureManager|UniversalControlEvent|InputEvent|HdmiStatus|AudioGuide|TextToSpeech|TextToSpeechEvent|Font|XMLElement|DateTime|List|Array|String|Int|Float|Invalid|VideoEvent|AudioEvent|UrlEvent|ChannelStoreEvent|InvalidPort|AppManager|FileSystem|FilesystemEvent|SystemLog|SystemLogEvent|DeviceCryptoEvent|DeviceCrypto|DeviceInfoEvent|AppMemoryMonitor|AppMemoryMonitorEvent|EVPCipher|EVPDigest|HMAC|HttpAgent|Registry|Bitmap|RegionList|ProgramGuide|ImageMetadata|AudioMetadata|VideoMetadata|MetadataElement|ContentMetadata|MessageDialog|Dialog|TextWidget|TextScreen|ParagraphScreen|MessageBox|PinEntryDialog|GridScreen|PosterScreen|ListScreen|VideoScreen|AudioPlayerScreen|SearchScreen|SearchHistory|KeyboardScreen|SpringboardScreen|VirtualKeyboard|UrlTransfer|UrlEvent|StreamSocket|StreamSocketEvent|InternalAudioMixer|InternalAudio)\b/, + 'ro-prefixed object', + ], + [/\bBrightScript\s*>\s/, 'BRS REPL prompt'], + [/^\s*print\s+["'\w&]/im, 'print statement'], + [/^\s*'/m, "BRS comment '"], + [/\b&h[0-9a-fA-F]+\b/, 'hex literal &h...'], + [/\bwait\s*\(\s*\d/, 'wait()'], + [/^\s*Dim\s+\w+/m, 'Dim'], + [/\b[Tt]hrow\s/, 'THROW'], + [/\bfor\s+each\s+\w+\s+in\b/i, 'for each ... in'], + [/\bif\s+.+\s+then\b/i, 'if-then'], + [/\belse\s+if\b/i, 'else if'], + [/\b[Nn]ext\s*$/m, 'next'], + [/^\s*\w+\s*=\s*[cC]reateObject\s*\(/m, 'CreateObject assignment'], + [/\b(stop|STOP)\s*$/m, 'stop statement'], + [/\bonKeyEvent\b/, 'onKeyEvent handler'], + [/\b(observeField|unobserveField|observeFieldScoped|setField|getField|callFunc|callfunc)\b/, 'SceneGraph node method'], + [/\b(rsg|RSG)\.\w+/, 'rsg. namespace'], + [/\bobjFun\b/, 'objFun'], + [/^\s*[A-Za-z]\w*:\s*$/m, 'GOTO label'], +]; + +function tryBrightScript(text) { + // Skip BRS detection inside obvious non-BRS contexts (C struct, XML body). + // Those are already classified by tryHardSignals if applicable. + if (/\b(uint8|uint16|uint32|uint64|int8|int16|int32|int64|utf8z)\b/.test(text)) { + // C int types. Skip BRS unless there's an unambiguous BRS keyword too. + const hasStrongBRS = + /\b[cC]reateObject\s*\(\s*"ro/.test(text) || + /\bm\.(top|global|video)\b/.test(text) || + /\bend\s*sub\b/i.test(text) || + /\bend\s*function\b/i.test(text) || + /\bas\s+(String|Integer|Boolean|Object|Dynamic|Float|Double|Void)\b/.test(text); + if (!hasStrongBRS) return null; + } + + const hits = []; + for (const [pat, label] of BRS_PATTERNS) { + if (pat.test(text)) hits.push(label); + } + if (hits.length === 0) return null; + + // Two or more signals -> very confident. + // One signal -> confident only if the signal is high-specificity. + const HIGH_SPECIFICITY = [ + 'as Type annotation', + 'CreateObject("ro...")', + 'm.top/global/video', + 'm.field assignment', + 'm.field.method() call', + 'm. field reference', + 'ro-prefixed object', + 'BRS REPL prompt', + 'end sub', + 'end function', + 'sub keyword', + 'function keyword', + 'SceneGraph node method', + 'onKeyEvent handler', + "BRS comment '", + 'Library "...brs" statement', + 'Roku_Ads() framework call', + 'observeFieldScoped', + 'callFunc()', + ]; + const hasHighSpec = hits.some((h) => HIGH_SPECIFICITY.includes(h)); + let confidence; + if (hits.length >= 2) confidence = 0.95; + else if (hasHighSpec) confidence = 0.85; + else confidence = 0.6; // 1 weak signal: keep below the 0.7 act-threshold + + return { lang: 'brightscript', confidence, signals: hits }; +} + +// --------------------------------------------------------------------------- +// JSON: object/array literal with quoted keys. Runs AFTER BRS so BRS +// associative-array literals don't get misclassified. +// --------------------------------------------------------------------------- + +function tryJson(text) { + if (!/^\s*[\{\[]/.test(text)) return null; + // Need quoted keys, no BRS line comments (`'`). + if (!/"[\w$-]+"\s*:\s*/.test(text)) return null; + if (/^\s*'/m.test(text)) return null; + if (/^\s+'/.test(text)) return null; + return { lang: 'json', confidence: 0.85, signals: ['object/array with quoted keys'] }; +} + +// --------------------------------------------------------------------------- +// Bash: command-style content. +// --------------------------------------------------------------------------- + +function tryBashLight(text, lines) { + if (lines.length > 8) return null; + if (/^\s*(curl|wget|cd|ls|sudo|brew|npm|node|python3?|pip3?|export|chmod|mkdir|rm|cp|mv|tar|git)\s/m.test(text)) { + return { lang: 'bash', confidence: 0.8, signals: ['bash command'] }; + } + return null; +} + +// --------------------------------------------------------------------------- +// Public entry point. +// --------------------------------------------------------------------------- + +export function classifyFence(body) { + const text = (body ?? '').replace(/\s+$/, ''); + if (!text.trim()) return { lang: 'empty', confidence: 1.0, signals: [] }; + const lines = text.split('\n'); + + const hard = tryHardSignals(text, lines); + if (hard) return hard; + + const brs = tryBrightScript(text); + if (brs && brs.confidence >= 0.7) return brs; + + const json = tryJson(text); + if (json) return json; + + const bash = tryBashLight(text, lines); + if (bash) return bash; + + // BRS scored 1 weak signal -> still return brightscript with low confidence + // so callers can see it; sweep + lint both gate on >= 0.7. + if (brs) return brs; + + return { lang: 'unknown', confidence: 0.0, signals: [] }; +} + +/** Convenience helper used by the lint rule. */ +export function looksLikeBrightScript(body) { + const result = classifyFence(body); + return result.lang === 'brightscript' && result.confidence >= 0.7; +} diff --git a/.github/scripts/docs-lint/rules/code-fences.mjs b/.github/scripts/docs-lint/rules/code-fences.mjs new file mode 100644 index 00000000..f1977cdd --- /dev/null +++ b/.github/scripts/docs-lint/rules/code-fences.mjs @@ -0,0 +1,37 @@ +/** + * Code-fence rules for docs-lint. + * + * Rules and severity: + * error brightscript-fence-required Bare ``` fence whose body classifies as BrightScript. + * + * The classifier lives in ../lib/code-fence-classifier.mjs and is shared with + * the one-shot sweep tool that initially populated the BRS tags. + */ + +import { visit } from 'unist-util-visit'; +import { classifyFence } from '../lib/code-fence-classifier.mjs'; + +export const id = 'code-fences'; + +export function check({ file, mdast, reporter }) { + visit(mdast, 'code', (node) => { + // Bare fence = no info string (`lang` is null/empty after trim). + const lang = node.lang ? String(node.lang).trim() : ''; + if (lang) return; + + const body = node.value ?? ''; + const result = classifyFence(body); + + if (result.lang === 'brightscript' && result.confidence >= 0.7) { + const why = result.signals.slice(0, 3).join(', '); + reporter.add({ + file, + line: node.position?.start.line, + col: node.position?.start.column ?? 1, + rule: 'brightscript-fence-required', + severity: 'error', + message: `bare \`\`\` fence with BrightScript content; tag it as \`\`\`brightscript (${why})`, + }); + } + }); +} diff --git a/docs/DEVELOPER/advertising/csas.md b/docs/DEVELOPER/advertising/csas.md index 67c5c60d..e9e657ae 100644 --- a/docs/DEVELOPER/advertising/csas.md +++ b/docs/DEVELOPER/advertising/csas.md @@ -20,7 +20,7 @@ Once you have [enabled the RAF library](doc:integrating-roku-advertising-framewo The following code example demonstrates how to create a stitched stream: -``` +```brightscript screen = CreateObject("roSGScreen") scene = screen.CreateScene("MainScene") @@ -56,7 +56,7 @@ csasStream = m.adIface.constructStitchedStream(myContentNode, m.adPods) You can render a stitched stream using the [**renderStitchedStream()**](doc:raf-api) method. This method takes the playlist created via the [**constructStitchedStream()**](doc:raf-api) method and a renderable node to which the stitched stream can be attached. -``` +```brightscript ' render the stitched stream m.adIface.renderStitchedStream(csasStream, scene) ``` diff --git a/docs/DEVELOPER/advertising/integrating-roku-advertising-framework.md b/docs/DEVELOPER/advertising/integrating-roku-advertising-framework.md index b9550d06..0c46d940 100644 --- a/docs/DEVELOPER/advertising/integrating-roku-advertising-framework.md +++ b/docs/DEVELOPER/advertising/integrating-roku-advertising-framework.md @@ -35,7 +35,7 @@ any applications using the Roku Advertising Framework library: **Manifest entry** -``` +```text bs_libs_required=roku_ads_lib ``` @@ -44,19 +44,19 @@ as part of their own package file. Instead, the “Library” keyword is used. The following line should be the first entry in your `main.brs` file: -``` +```brightscript Library "Roku_Ads.brs" ``` The library interface is obtained by calling the constructor with no arguments: -``` +```brightscript adIface = Roku_Ads() ``` Configure the ad URL before making the ad request call: -``` +```brightscript adIface.setAdUrl(myAdUrl) ``` @@ -71,14 +71,14 @@ makes the initial request to the ad server, parses the server response, and returns the structure of ads to be rendered prior to, or during playback, of the selected content: -``` +```brightscript adPods = adIface.getAds() ``` Any preroll ads present in the returned set of ad pods can be immediately rendered by calling: -``` +```brightscript shouldPlayContent = adIface.showAds(adPods, invalid, adHolder) ``` @@ -96,7 +96,7 @@ ads: **Calling getAds() in a while loop** -``` +```brightscript while shouldPlayContent videoMsg = wait(0, contentVideoScreen.GetMessagePort()) adPods = adIface.getAds(videoMsg) @@ -119,7 +119,7 @@ retains control over the * button and will need to handle button presses on their own. To set the Video node in focus again, use the following code snippet: -``` +```brightscript sub init() m.top.setFocus(true) setVideo() @@ -142,7 +142,7 @@ URL (which currently provides only a single ad), the ad URL must be configured before requesting an ad pod: -``` +```brightscript Library "Roku_Ads.brs" adIface = Roku_Ads() @@ -177,7 +177,7 @@ its `renderSequence` attribute. Just call [showAds()](doc:raf-api) with the adPods value that the application obtained above: -``` +```brightscript shouldPlayContent = adIface.showAds(adPods) ``` @@ -199,7 +199,7 @@ occur: **Sequential ad pod rendering example** -``` +```brightscript shouldPlayContent = adIface.showAds(adPods) while shouldPlayContent videoMsg = wait(0, contentVideoScreen.GetMessagePort()) @@ -232,7 +232,7 @@ necessary: **Custom ad scheduling example** -``` +```brightscript adBreakSchedule = [adBreakTime1, adBreakTime2, adBreakTime3] scheduledPods = [] adBreakIndex = 0 @@ -260,7 +260,7 @@ rendering: **Complete ad rendering control example** -``` +```brightscript shouldPlayContent = true adBreakIndex = 0 while shouldPlayContent @@ -312,7 +312,7 @@ The impression tags fired when video ads are displayed on your app must include To enable ad measurement, call the [enableAdMeasurements()](doc:raf-api) method, and pass the required content metadata within the [setContentGenre()](doc:raf-api), [setContentId()](doc:raf-api), and [setContentLength()](doc:raf-api) methods. -``` +```brightscript adIface.enableAdMeasurements(true) adIface.setContentGenre(content.categories) adIface.setContentId(content.stream.contentid) @@ -335,7 +335,7 @@ Apps can use the [GetRIDA()](doc:ifdeviceinfo) API to get the RIDA of a device a **Retrieving RIDA example** -``` +```brightscript function getAdID() as String adId = "" dev_info = createObject("roDeviceInfo") @@ -408,7 +408,7 @@ The supported content meta-data attributes are: | Title | Center-aligned relative to and displayed below PosterUrl | "Title for custom buffering screen" | | Description | Left-aligned relative to PosterUrl | "Description for custom buffering screen" | -``` +```brightscript bufferScreenContent = {} bufferScreenContent.HDBackgroundImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Aspect-ratio-16x9.svg/1280px-Aspect-ratio-16x9.svg.png" bufferScreenContent.HDPosterUrl = "http://static.commentcamarche.net/ccm.net/faq/images/0-BX4VeV6H-resolution-comparison-s-.png" @@ -431,7 +431,7 @@ other roImageCanvas attributes. **Custom buffering screen using layers** -``` +```brightscript layers = [ {Url: BackgroundImageUrl} {Url: PosterUrl, TargetRect : {x : 405, y : 370, w : 467, h : 262}} @@ -468,7 +468,7 @@ first calling the [importAds()](doc:raf-api) method with the ad structure constructed externally by the client: -``` +```brightscript adIface.importAds(myAdPodArray) ``` @@ -521,7 +521,7 @@ As an example, if `ad` contains the [Ad structure](doc:integrating-roku-advertis video ad that the client application has just begun rendering, the `Impression` beacons for that ad could be fired with a single call: -``` +```brightscript adIface.fireTrackingEvents(ad, {type: "Impression"}) ``` @@ -530,14 +530,14 @@ variable `adProgressTime` holds a value representing the number of seconds since the ad began rendering, the quartile beacons can be sent via: -``` +```brightscript adIface.fireTrackingEvents(ad, {time: adProgressTime}) ``` If the ad were paused by the user, then the client app would fire the `Pause` beacons: -``` +```brightscript adIface.fireTrackingEvents(ad, {type: "Pause"}) ``` @@ -622,7 +622,7 @@ Scheduling and rendering is then initialized by first calling the [`stitchedAdsInit()`](doc:raf-api) method with the ad structure constructed by the client: -``` +```brightscript adIface.stitchedAdsInit(myAdPodArray) ``` @@ -637,7 +637,7 @@ logic: **Server side ad insertion example** -``` +```brightscript playContent = true while playContent msg = Wait(0, videoPlayer.GetMessagePort()) @@ -720,7 +720,7 @@ set: **setAdUrl example** -``` +```brightscript rokuAds = Roku_Ads() url = "http://my.ad.server.net/?my_first_param=MyFirstValue&my_app_id=ROKU_ADS_APP_ID&my_user_agent=ROKU_ADS_USER_AGENT&my_timestamp=ROKU_ADS_TIMESTAMP&other_param=SomeOtherValue" rokuAds.setAdUrl(url) diff --git a/docs/DEVELOPER/advertising/raf-api.md b/docs/DEVELOPER/advertising/raf-api.md index c1fbf783..93fcc363 100644 --- a/docs/DEVELOPER/advertising/raf-api.md +++ b/docs/DEVELOPER/advertising/raf-api.md @@ -311,7 +311,7 @@ Allows library client to set a callback function to be called when ad tracking e Callback functions must have the following signature: -``` +```brightscript sub CallbackFunc(obj = invalid as Dynamic, eventType = invalid as Dynamic, ctx = invalid as Dynamic) ``` diff --git a/docs/DEVELOPER/advertising/ssai-adapters.md b/docs/DEVELOPER/advertising/ssai-adapters.md index 14849566..b1c35d91 100644 --- a/docs/DEVELOPER/advertising/ssai-adapters.md +++ b/docs/DEVELOPER/advertising/ssai-adapters.md @@ -61,14 +61,14 @@ The following entry loads the adapter into your task: > At the beginning of the playback Task, instantiate the adapter with proper parameters and then initialize it. The valid values of the parameter name are uplynk, adobe, onceux, yospace, awsemt, and ggldai. -``` +```brightscript adapter = RAFX_SSAI({name:"uplynk"}) ' Supported: uplynk, adobeonceux, yospace, awsemt, ggldai adapter.init() ``` ### 2. Make an initial request to SSAI manifest server getting Ad metadata: Request Ad Metadata -``` +```brightscript request = { type: adapter.SreamType.VOD ' Required, VOD or LIVE url: "http://admanifest.ssai.com/api?assetid=abcdefg"' Ad metadata URL, provided by SSAI @@ -82,7 +82,7 @@ result = adapter.requestStream(request) The initial request to SSAI manifest servers returns content URL (like Adobe and Verizon Media Services). The following entry gets the content URL: -``` +```brightscript streamInfo = adapter.getStreamInfo() url = streamInfo["playURL"] ``` @@ -92,7 +92,7 @@ url = streamInfo["playURL"] Once the content playback URL is known, the adapter is ready to track Ads. Pass the adapter player object and observe the position event on the video node. The value of params.player is given to RAF internally as the second parameter of RAF.stitchedAdHandledEvent(). adapter.enableAds() parses Ad metadata and/or configure additional settings such as observing timedMetadata2 of given video node. It then calls RAF.stitchedAdsInit() when valid Ad metadata was found in the initial response from the SSAI manifest servers. -``` +```brightscript port = CreateObject("roMessagePort") params = {player: {sgnode:m.top.video, port:port}} adapter.enableAds(params) @@ -113,7 +113,7 @@ By default, params.useStitched is set to true. In this case: #### **a) Optional: enable ads without stitchedAdHandledEvent** -``` +```brightscript params = { player: {sgnode:m.top.video, port:port}, useStitched: false @@ -147,7 +147,7 @@ When params.useStitched = false, it is required to set callbacks and the app MUS **Setting the callback functions to the Adapter:** -``` +```brightscript ' Set adapter callback functions adapter.addEventListener(adapter.AdEvent.POD_START, rafxCallback) adapter.addEventListener(adapter.AdEvent.POD_END, rafxCallback) @@ -155,7 +155,7 @@ adapter.addEventListener(adapter.AdEvent.IMPRESSION, rafxCallback) ``` Example callback function: -``` +```brightscript function rafxCallback(eventInfo as object) as void if adapter.AdEvent.POD_START = eventInfo.event m.top.adPlaying = true @@ -173,7 +173,7 @@ When you are ready to start playback, you need to configure RAF by enabling ad m Note: It is recommended to use [enableAdMeasurements](doc:raf-api). -``` +```brightscript adIface = Roku_Ads() adIface.enableAdMeasurements(true) ' Required adIface.setContentGenre(...) ' Set app/content genre info @@ -185,7 +185,7 @@ adIface.setContentId(...) ' Set app/content specific info The developer can now start the playback and run the message loop: -``` +```brightscript video.control = "play" ' start playback while true diff --git a/docs/DEVELOPER/authentication/on-device-authentication.md b/docs/DEVELOPER/authentication/on-device-authentication.md index b5e7b8da..cc1ddd0b 100644 --- a/docs/DEVELOPER/authentication/on-device-authentication.md +++ b/docs/DEVELOPER/authentication/on-device-authentication.md @@ -84,7 +84,7 @@ To check for an active Roku subscription with the **ChannelStore API**, follow t `myChannelStore.command = "getAllPurchases"` 2. Get the transaction ID from the **purchaseId** field of the child content node. Find the subscription to be validated using the **code** or **productType** fields of the child content node. - ``` + ```brightscript if (myChannelStore.purchases <> invalid) count = myChannelStore.purchases.GetChildCount() for x = 0 to count - 1 @@ -139,7 +139,7 @@ To check for a valid access token in the device registry, follow these steps: * Call the [**ChannelStore.storeChannelCredData **](doc:channelstore#storechannelcreddata) command to store an access token in the Roku cloud. You can use the **status** and **response** fields of the **storeChannelCredDataStatus** content node to verify that the command was successful and that the access token stored in the Roku cloud has the specified value. - ``` + ```brightscript myChannelStore.channelCredData = "your access token" myChannelStore.command = "storeChannelCredData " @@ -237,7 +237,7 @@ To complete and validate the new subscription, follow these steps: 2. Once the customer selects a product, [create an order](doc:channelstore) that contains the product the customer is purchasing. To do this, you set the [**ChannelStore.order**](doc:channelstore#order) field to a **ContentNode** that has one child **ContentNode** for the item the customer is purchasing - ``` + ```brightscript myOrder = CreateObject("roSGNode", "ContentNode") itemPurchased = myOrder.createChild("ContentNode") itemPurchased.addFields({ "code": "UPC3L5A", "qty": 1}) @@ -273,7 +273,7 @@ If a customer is signing in, have them authenticate themselves in your app UI fo 1. After the user enters the sign-in flow, set the [**ChannelStore.requestedUserData**](doc:channelstore) field to "email" to ask the customer to share their email address, and set the [**ChannelStore.requestedUserDataInfo**](doc:channelstore) field to a ContentNode that has a **context** field set to "signin". - ``` + ```brightscript myChannelStore.requestedUserData("email") info = CreateObject("roSGNode", "ContentNode") info.addFields({context: "signin"}) diff --git a/docs/DEVELOPER/authentication/universal-authentication-protocol-for-single-sign-on.md b/docs/DEVELOPER/authentication/universal-authentication-protocol-for-single-sign-on.md index e5e2593e..f6230475 100644 --- a/docs/DEVELOPER/authentication/universal-authentication-protocol-for-single-sign-on.md +++ b/docs/DEVELOPER/authentication/universal-authentication-protocol-for-single-sign-on.md @@ -39,7 +39,7 @@ To check for a valid access token in the device registry, follow these steps: 1. Create an [**roRegistrySection**](doc:roregistrysection) object. This provides access to your section within the device registry to get and read your keys. When creating the registry section, pass in the name of your registry. This must be the same name used when the registry section was created. - ``` + ```brightscript reg_sec = CreateObject("roRegistrySection", "") ``` @@ -137,7 +137,7 @@ If both the device registry and Roku cloud do not contain a valid access token, > Any metadata within the access token related to its validity must be managed entirely by the publisher. - ``` + ```brightscript myChannelStore.channelCredData = "your access token" myChannelStore.command = "storeChannelCredData" diff --git a/docs/DEVELOPER/core-concepts/controlling-screen-program-flow.md b/docs/DEVELOPER/core-concepts/controlling-screen-program-flow.md index 83d19064..9cd91a55 100644 --- a/docs/DEVELOPER/core-concepts/controlling-screen-program-flow.md +++ b/docs/DEVELOPER/core-concepts/controlling-screen-program-flow.md @@ -205,7 +205,7 @@ Then we can write the \ element callback function `showfocus()` to indicate focus when the `focusPercent` \ field changes: -``` +```brightscript sub showfocus() m.itemcursor.opacity = m.top.focusPercent m.itemposter.opacity = m.top.focusPercent diff --git a/docs/DEVELOPER/core-concepts/data-scoping.md b/docs/DEVELOPER/core-concepts/data-scoping.md index 79d2ba8f..daa32223 100644 --- a/docs/DEVELOPER/core-concepts/data-scoping.md +++ b/docs/DEVELOPER/core-concepts/data-scoping.md @@ -36,7 +36,7 @@ reference. For example, the following creates and defines several fields for a `dialog` object that can only be accessed within the function in which it is created and defined: -``` +```brightscript dialog = createObject("RoSGNode","Dialog") dialog.backgroundUri = "pkg:/images/sgetdialogbg.9.png" dialog.title = "Example Dialog" @@ -52,7 +52,7 @@ file. For example, if you wanted to create the same `dialog` object above in one function, but define it, or otherwise access it, in another function in the same component XML file: -``` +```brightscript sub createdialog() m.dialog = createObject("RoSGNode", "Dialog") end sub @@ -76,7 +76,7 @@ file (which is the required usage of the Dialog node class), assign the `dialog` object to the `dialog` field using the `m.top` object reference: -``` +```brightscript dialog = createObject("RoSGNode", "Dialog") dialog.backgroundUri = "pkg:/images/sgetdialogbg.9.png" dialog.title = "Example Dialog" @@ -90,7 +90,7 @@ Likewise, if you want to use `findNode()` to find a SceneGraph node object anywhere in the SceneGraph tree for a component XML file, use the `m.top` reference to start at the top of the tree: -``` +```brightscript m.categorieslist = m.top.findNode("categorieslist") ``` @@ -113,7 +113,7 @@ m.categorieslist = m.top.findNode("categorieslist") For example: -``` +```brightscript screen = CreateObject("roSGScreen") m.port = CreateObject("roMessagePort") screen.setMessagePort(m.port) @@ -134,7 +134,7 @@ get its special global element: You will need to take the associative array, modify it and save it back into the field. -``` +```brightscript m.global.addFields({red: &hff0000ff, green: &h00ff00ff, blue: &h0000ffff}) ' ... diff --git a/docs/DEVELOPER/core-concepts/developing-scenegraph-applications.md b/docs/DEVELOPER/core-concepts/developing-scenegraph-applications.md index f30a8412..0b2fbbc0 100644 --- a/docs/DEVELOPER/core-concepts/developing-scenegraph-applications.md +++ b/docs/DEVELOPER/core-concepts/developing-scenegraph-applications.md @@ -43,7 +43,7 @@ below. The `manifest` file contains the following fields: -``` +```text title=application_title subtitle=application_subtitle major_version=major_version_number @@ -102,7 +102,7 @@ file. **Manifest file example** -``` +```text title=Test Application subtitle=A SceneGraph Test major_version=1 @@ -146,7 +146,7 @@ directory](doc:developing-scenegraph-applications)). **Example main.brs file** -``` +```brightscript sub Main() showChannelSGScreen() end sub @@ -183,7 +183,7 @@ For example: Similarly, you can control the flow of scenes through your application by creating and showing scenes as needed: -``` +```brightscript screen = CreateObject("roSGScreen") m.port = CreateObject("roMessagePort") screen.setMessagePort(m.port) diff --git a/docs/DEVELOPER/core-concepts/downloading-server-content.md b/docs/DEVELOPER/core-concepts/downloading-server-content.md index 5dd6deaa..fce67260 100644 --- a/docs/DEVELOPER/core-concepts/downloading-server-content.md +++ b/docs/DEVELOPER/core-concepts/downloading-server-content.md @@ -119,7 +119,7 @@ downloaded: **Example Task node configuration and launch** -``` +```brightscript m.getHomeOptionsList = createObject("roSGNode", "getLabelListContent") m.getHomeOptionsList.setField("uri", "http://www.sdktestinglab.com/homeoptionslistcontent.xml") m.getHomeOptionsList.observeField("content", "showhomeoptionslist") diff --git a/docs/DEVELOPER/core-concepts/event-loops.md b/docs/DEVELOPER/core-concepts/event-loops.md index a8b05474..af5e8069 100644 --- a/docs/DEVELOPER/core-concepts/event-loops.md +++ b/docs/DEVELOPER/core-concepts/event-loops.md @@ -20,7 +20,7 @@ An event is a thing like an on-screen button press, a remote button press, a vid A script will normally interact with events via an event loop. At a high level, an event loop is a piece of code with this structure: -``` +```brightscript while true ' wait for an event ' process the event @@ -43,7 +43,7 @@ Normally a script will have a structure like this: Here is an example of a simple script that processes events. -``` +```brightscript port = CreateObject("roMessagePort") screen = CreateObject("roSGScreen") scene = screen.CreateScene("Scene") @@ -69,7 +69,7 @@ end while Real-time games which use the [ifDraw2D ](doc:ifdraw2d)interface typically cannot wait like this for a message in their event loop, because the screen may need to be updated with new animation frames even if no buttons are pressed or other events occur. One way to deal with this is to use a timeout as the first parameter of the call to wait: -``` +```brightscript msg = wait(5, port) ``` @@ -77,7 +77,7 @@ This waits for a message, but if no message is received within 5 milliseconds, t However, an approach that usually offers more predictable performance is to use [ifMessagePort.GetMessage](doc:ifmessageport) instead of wait. This is because GetMessage will return immediately if no message is available, while the actual amount of time before a timed wait returns can vary depending on various factors. A game script is often structured like this. -``` +```brightscript port = CreateObject("roMessagePort") screen = CreateObject("roScreen") screen.SetMessagePort(port) ' instruct screen to send events to port @@ -97,7 +97,7 @@ Note that in this case, it is the call to SwapBuffers, not GetMessage, that caus Sometimes you may wish to have certain code executed periodically, or a certain amount of time after another event has occurred. The best way to handle this is usually to incorporate the handling of the timed event into your main event loop, and use an roTimespan object as a clock to determine when it is time to perform the next action. For example, this loop is similar to the Springboard screen event loop shown above, but it also calls the function DoSomething once every 5 seconds. -``` +```brightscript clock = CreateObject("roTimespan") next_call = clock.TotalMilliseconds() + 5000 while true @@ -126,13 +126,13 @@ Notice that the first parameter of wait has been changed so that it returns afte Different Brightscript components generate different types of messages. For example, the component "roSpringboardScreen" sends event messages of type "roSpringboardScreenEvent". In general, a Brightscript function dealing with a specific component should only react to events generated by that component. For example, as in the example above, code that deals with events generated by an roSpringboardScreen should be inside an if statement like this: -``` +```brightscript if type(message) = "roSpringboardScreenEvent" ``` When a message of the desired type is received, the code will process it. For example, one might be looking for a "button pressed" event type. The example above shows that the way to test for this is to call the method isButtonPressed: -``` +```brightscript if message.isButtonPressed() ``` @@ -141,7 +141,7 @@ An event loop needs to be aware of the possible event classes and types which it The following is the list of tests for event types. If new types are added, these tests will remain valid. -``` +```brightscript isListItemSelected() as Boolean isScreenClosed() as Boolean isListFocused() as Boolean diff --git a/docs/DEVELOPER/core-concepts/handling-application-events.md b/docs/DEVELOPER/core-concepts/handling-application-events.md index ed6ec57f..bd6c97c7 100644 --- a/docs/DEVELOPER/core-concepts/handling-application-events.md +++ b/docs/DEVELOPER/core-concepts/handling-application-events.md @@ -20,7 +20,7 @@ You can pass data between threads without incurring rendezvous or blocking a Tas #### Task thread -``` +```brightscript my_array = { str_key: "my_string", int_key: 42 } rtq = CreateObject("roRenderThreadQueue") rtq.PostMessage("result_array", my_array) @@ -29,7 +29,7 @@ print my_array This will result in the following being printed to the console. The array is empty because passing it to `PostMessage()` caused its contents to be moved to the Render thread. Also note that the print happens immediately and is not blocked by the handler running on the Render thread. -``` +```text = { } @@ -39,7 +39,7 @@ This will result in the following being printed to the console. The array is emp Setting up a message handler is very similar to setting up a field observer. -``` +```brightscript rtq = CreateObject("roRenderThreadQueue") rtq.AddMessageHandler("result_array", "OnTaskResultArrayRTQ") @@ -51,7 +51,7 @@ end sub This will result in the following being printed to the console. The data parameter will contain the same values that were passed to `PostMessage()` on the Task thread. -``` +```text = { int_key: 42 @@ -63,7 +63,7 @@ This will result in the following being printed to the console. The data paramet **Nested functions example** -``` +```brightscript function init() m.top.observeField("f1", "c1") m.top.observeField("f2", "c2") @@ -149,7 +149,7 @@ The following `onKeyEvent()` example handles supported remote control key presse **onKeyEvent() event handling example** -``` +```brightscript function onKeyEvent(key as String, press as Boolean) as Boolean handled = false if press then @@ -181,13 +181,13 @@ There are two [ifSGNodeField](doc:ifsgnodefield) methods that allow you to creat `observeField()` is an overloaded method with two versions, useful for different purposes. The first allows you to trigger a specified callback function in response to any change in the value of the observed node field. For example, to set up an observer of a [Timer](doc:timer) node `fire` field that calls a `handleexampletimerfire()` event handler function that you write: -``` +```brightscript exampletimer.ObserveField("fire", "handleexampletimerfire") ``` Once this observer is set up, the component will continuously monitor the `exampletimer` node object `fire` field for the remaining existence of the component or node, or until `unobserveField()` is called (perhaps as part of the event handler function itself): -``` +```brightscript exampletimer.unobserveField("fire") ``` @@ -229,7 +229,7 @@ Here is an example of a field observer and the associated event handler function The second version of `observeField()` lets you specify a message port to notify when the observed field changes: -``` +```brightscript m.texttimer.ObserveField("fire", m.port) ``` diff --git a/docs/DEVELOPER/core-concepts/localization.md b/docs/DEVELOPER/core-concepts/localization.md index 9cc74d0b..a7d4de11 100644 --- a/docs/DEVELOPER/core-concepts/localization.md +++ b/docs/DEVELOPER/core-concepts/localization.md @@ -64,13 +64,13 @@ string in the `translations.xml` file, then finds the corresponding string translation in the file for the current locale. To use the `tr()` function to localize a specific *source* string: -``` +```brightscript tr(String source) as String ``` For example, to translate the string "hello world" in BrightScript: -``` +```brightscript m.greetinglabel.text = tr("hello world") ``` @@ -86,7 +86,7 @@ assigned to the `text` field. The `tr()` function also supports string substitutions. For example: -``` +```brightscript text = tr("Video will start in %1 seconds").Replace("%1", numSeconds.ToStr()) ``` @@ -140,7 +140,7 @@ graphical image. For example: -``` +```brightscript localize = createObject("RoLocalization") bannerposter = m.top.findNode("bannerPoster") bannerposter.uri = localize.GetLocalizedAsset("images", "banner.png") @@ -148,7 +148,7 @@ bannerposter.uri = localize.GetLocalizedAsset("images", "banner.png") Is equivalent to: -``` +```brightscript bannerposter = m.top.findNode("bannerPoster") bannerposter.uri = "pkg:/locale/images/banner.png" ``` diff --git a/docs/DEVELOPER/core-concepts/playing-videos.md b/docs/DEVELOPER/core-concepts/playing-videos.md index e45c3e2a..83297324 100644 --- a/docs/DEVELOPER/core-concepts/playing-videos.md +++ b/docs/DEVELOPER/core-concepts/playing-videos.md @@ -169,7 +169,7 @@ and partially defined in XML markup, you must use the `findNode()` function to declare the node object and access the internal retrieving bar node fields: -``` +```brightscript m.video = m.top.findNode("channel_video_node_id") ... m.video.retrievingBar.internal_node_field = internal_node_field_value @@ -203,7 +203,7 @@ the `control` field in a callback function triggered by the screen focus event as follows: -``` +```brightscript sub setDetailsScreenFocus() if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.videoPlayer.hasFocus() then m.buttons.setFocus(true) @@ -216,7 +216,7 @@ end sub Then write the callback function for the playback button press event that includes: -``` +```brightscript m.videoPlayer.control = "start" ``` @@ -240,7 +240,7 @@ assign the ContentNode to the `content` field of the Video node, then set the Video node `control` field value to `play` to start the video. For example: -``` +```brightscript videoContent = createObject("RoSGNode", "ContentNode") videoContent.url = "video_URI" videoContent.streamformat = "hls" diff --git a/docs/DEVELOPER/core-concepts/scenegraph-brightscript/index.md b/docs/DEVELOPER/core-concepts/scenegraph-brightscript/index.md index b393efe8..6aa2e374 100644 --- a/docs/DEVELOPER/core-concepts/scenegraph-brightscript/index.md +++ b/docs/DEVELOPER/core-concepts/scenegraph-brightscript/index.md @@ -18,7 +18,7 @@ Two BrightScript objects, [roSGScreen](doc:rosgscreen) and [roSGNode](doc:rosgno Currently, a fairly strict ordering must be used in BrightScript to create a screen and set up its Scene node. -``` +```brightscript screen = CreateObject("roSGScreen") ' create the roSGScreen m.port = CreateObject("roMessagePort") screen.setMessagePort(m.port) diff --git a/docs/DEVELOPER/core-concepts/threads.md b/docs/DEVELOPER/core-concepts/threads.md index 658cc7f7..16781e9b 100644 --- a/docs/DEVELOPER/core-concepts/threads.md +++ b/docs/DEVELOPER/core-concepts/threads.md @@ -74,7 +74,7 @@ Since Task nodes are owned by the Render thread, setting Task node fields from a #### Render Thread -``` +```brightscript my_task = CreateObject("roSGNode", "MyTask") ' setting fields from the Render thread WILL NOT rendezvous my_task.my_field = "some value" @@ -84,7 +84,7 @@ my_task.ObserveField("my_field", "OnMyFieldChanged") #### Task Thread -``` +```brightscript ' setting fields from the Task thread WILL rendezvous m.top.my_field = "some value" cn = CreateObject("roSGNode", "ContentNode") diff --git a/docs/DEVELOPER/core-concepts/xml-components/creating-custom-components.md b/docs/DEVELOPER/core-concepts/xml-components/creating-custom-components.md index b0d4b383..eb004b59 100644 --- a/docs/DEVELOPER/core-concepts/xml-components/creating-custom-components.md +++ b/docs/DEVELOPER/core-concepts/xml-components/creating-custom-components.md @@ -94,7 +94,7 @@ focus. **MainScene.brs file** -``` +```brightscript function init() as void customView = CreateObject("roSGNode", "CustomView") m.top.appendChild(customView) diff --git a/docs/DEVELOPER/core-concepts/xml-components/index.md b/docs/DEVELOPER/core-concepts/xml-components/index.md index d75ede3d..b9ea7675 100644 --- a/docs/DEVELOPER/core-concepts/xml-components/index.md +++ b/docs/DEVELOPER/core-concepts/xml-components/index.md @@ -30,7 +30,7 @@ created by either declaring it in another XML component file: Or using the `createObject()` function to create an [**roSGNode**](doc:rosgnode) object: -``` +```brightscript createObject("roSGNode", "Gizmo") ``` diff --git a/docs/DEVELOPER/debugging/index.md b/docs/DEVELOPER/debugging/index.md index 14f301cd..687c8e30 100644 --- a/docs/DEVELOPER/debugging/index.md +++ b/docs/DEVELOPER/debugging/index.md @@ -108,7 +108,7 @@ threads. All threads will be listed with the following information: The current selected thread will be marked with an `*`. -``` +```brightscript BrightScript Micro Debugger. Enter any BrightScript statement, debug commands, or HELP. Suspending threads... @@ -231,7 +231,7 @@ This usually means that a BrightScript variable has been incorrectly spelled aft This message will often coincide with a blank screen. The line number at which the error is detected will be flagged with an asterisk, and the message will provide the name of the file in which the error was detected: -``` +```brightscript 020:* smallexamplesize = smallexample.localBoundingRect() ... 'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...pkg:/components/smallexamplescene.xml(20) @@ -240,7 +240,7 @@ This message will often coincide with a blank screen. The line number at which t This message will appear if a component by that name has either not been created, or an attempt is made to access a component member using an incorrectly spelled component name. Check the backtrace information supplied by the debugger for the component objects and variables used at the time of the error, and note the component objects listed as invalid: -``` +```brightscript Backtrace: #0 Function init() As Void file/line: ...pkg:/components/smallexamplescene.xml(20) @@ -257,7 +257,7 @@ centery Note also the variables that were assigned values from interface functions on invalid component objects will be listed as \. Typically in Roku SceneGraph applications, the problem is caused by attempting to create a component object for a component class name that is not in either the built-in node classes, or extended node classes declared in the application package components directory. To fix this error, scroll up in the debugger output to the point at which the component object creation error occurred, which will have the following error message: -``` +```brightscript BRIGHTSCRIPT: ERROR: roSGNode: Failed to create roSGNode with type Rectangleexample: ...pkg:/components/smallexamplescene.xml(16) ``` @@ -267,7 +267,7 @@ This shows the file and line number where the actual component object creation e This often indicates that the ContentNode assigned to the content field of the list or grid either does not exist, or was assigned after focus was set on the list or grid. Ensure that the ContentNode has been created successfully at the time it is assigned to the list or grid content field. Then check that focus was set on the list or grid after the content field is assigned a valid ContentNode. Since you will generally be generating a ContentNode by parsing data from an XML or JSON file downloaded from your server in a Task node (or possibly downloaded as "singleton" at the time the SceneGraph app was created in the main.brs file and converted), make sure you set the content field and focus on the list or grid in this way: -``` +```brightscript sub showvideolist() m.videolist.content = m.readVideoContentTask.videocontent m.videolist.setFocus(true) @@ -278,7 +278,7 @@ This is a typical callback function that is triggered by the ContentNode being c Also, if you are having problems with a callback function not assigning a valid ContentNode, carefully check that the field observers were set before the Task node was configured and launched (but after the Task node object was created). For example, for the above example, the Task node object should have been created, had the field observers set, configured, and launched, in that order: -``` +```brightscript m.readVideoContentTask = createObject("RoSGNode","MetaDataCR") m.readVideoContentTask.observeField("videocontent","showvideolist") m.readVideoContentTask.metadatauri = "pkg:/server/videometadata.xml" diff --git a/docs/DEVELOPER/debugging/socket-based-debugger.md b/docs/DEVELOPER/debugging/socket-based-debugger.md index 3a019484..5e657ba5 100644 --- a/docs/DEVELOPER/debugging/socket-based-debugger.md +++ b/docs/DEVELOPER/debugging/socket-based-debugger.md @@ -53,7 +53,7 @@ The network format of the protocol adheres to the following rules: After an app is launched with a request to enable remote debugging, the firmware waits for a connection from the remote debugger client. Immediately after a connection is established, an initial handshake is then performed. The handshake consists of the following data being sent by each end of the connection: -``` +```c struct HandshakeToDVP { // DVP = Digital Video Player (Roku device) uint64 magic_number; // 0x0067756265647362LU }; @@ -152,7 +152,7 @@ The behavior after the handshake has been executed, depends on the version of th Remote debugging clients can send a debugger request to the debugging target (for example, the script group) using the following packet structure for the network byte stream: -``` +```c struct DebuggerRequest { uint32 packet_length; uint32 request_id; @@ -268,7 +268,7 @@ struct DebuggerRequest { The debugger sends responses to DebuggerRequest messages in the following format: -``` +```c struct DebuggerResponse { uint32 packet_length; uint32 request_id; @@ -388,7 +388,7 @@ struct DebuggerResponse { The debugger sends an update message when a state change occurs in the application being debugged, which may or may not have been requested by the debugging client or user. DebuggerUpdate messages have a similar format as DebuggerResponse messages, except that the **request_id** is always **0**, and it includes an **update_type** field, which specifies the type of update being sent. -``` +```c struct DebuggerUpdate { uint32 packet_length; uint32 request_id; @@ -553,7 +553,7 @@ struct DebuggerUpdate { If the **update_type** in a DebuggerUpdate message is set to ALL_THREADS_STOPPED, the **data** field contains a structure named **AllThreadsStoppedUpdateData** that provides the reason for the stop. The **AllThreadsStoppedUpdateData** structure has the following syntax: -``` +```c struct AllThreadsStoppedUpdateData{ int32 primary_thread_index; uint8 stop_reason; @@ -639,7 +639,7 @@ struct AllThreadsStoppedUpdateData{ If the **update_type** in a DebuggerUpdate message is set to THREAD_ATTACHED, the **data** field contains a structure named **ThreadAttachedUpdateData** that provides the reason for the stop. The **ThreadAttachedUpdateData** structure has the following syntax (see [AllThreadsStopped](#allthreadsstopped) for the details of each field): -``` +```c struct ThreadAttachedUpdateData{ int32 thread_index; uint8 stop_reason; @@ -651,7 +651,7 @@ struct ThreadAttachedUpdateData{ A BREAKPOINT_ERROR is sent if a compilation or runtime error occurs while evaluating the cond_expr of a conditional breakpoint. In this case, the **update_type** field in a DebuggerUpdate message is set to BREAKPOINT_ERROR, and the **data** field contains a structure named **BreakpointErrorUpdateData** that provides the reason for the error. The **BreakpointErrorUpdateData** structure has the following syntax: -``` +```c struct BreakpointErrorUpdateData { uint32 flags; uint32 breakpoint_id; @@ -679,7 +679,7 @@ struct BreakpointErrorUpdateData { A COMPILE_ERROR is sent if a compilation error occurs. In this case, the **update_type** field in a DebuggerUpdate message is set to COMPILE_ERROR, and the **data** field contains a structure named **CompileErrorUpdateData** that provides the reason for the error. The **CompileErrorUpdateData** structure has the following syntax: -``` +```c struct CompileErrorUpdateData { uint32 flags; utf8z error_string; @@ -703,7 +703,7 @@ _Available since [Roku OS 12.0](doc:release-notes#roku-os-120)_ A BREAKPOINT_VERIFIED message is sent when a breakpoint has successfully been applied to an executable line of code. Breakpoints may be added at any time; however, the changes may not be applied immediately if the debug target is running. In this case, the **update_type** field in a DebuggerUpdate message is set to BREAKPOINT_VERIFIED, and the **data** field contains a structure named **BreakpointVerifiedUpdateData** that provides the ID assigned to the verified breakpoint. The **BreakpointVerifiedUpdateData** structure has the following syntax: -``` +```c struct BreakpointVerifiedUpdateData { uint32 flags // Reserved for future use uint32 num_breakpoints @@ -711,7 +711,7 @@ struct BreakpointVerifiedUpdateData { } ``` -``` +```c struct VerifiedBreakpointInfo { uint32 breakpoint_id } @@ -767,14 +767,14 @@ _Available since [Roku OS 12.0](doc:release-notes#roku-os-120)_ A PROTOCOL_ERROR message is sent when an unrecoverable error has occurred on the protocol stream. As a result, the debug target is terminated. In this case, the **update_type** field in a DebuggerUpdate message is set to PROTOCOL_ERROR, and the **data** field contains a structure named **ProtocolErrorUpdateData** that provides the reason for the protocol error. The **ProtocolErrorUpdateData** structure has the following syntax: -``` +```c struct ProtocolErrorUpdateData { uint32 flags // Reserved for future use uint32 protocol_error_code } ``` -``` +```c enum ProtocolErrorCode { UNDEFINED = 0, IO_CONSOLE_FAIL = 1 @@ -829,7 +829,7 @@ enum ProtocolErrorCode { An EXCEPTION_BREAKPOINT_ERROR is sent if a compilation or runtime error occurs while evaluating the cond_expr of an exception breakpoint. In this case, the **update_type** field in a DebuggerUpdate message is set to EXCEPTION_BREAKPOINT_ERROR, and the **data** field contains a structure named **ExceptionBreakpointErrorUpdateData** that provides the reason for the error. The **ExceptionBreakpointErrorUpdateData** structure has the following syntax: -``` +```c struct ExceptionBreakpointErrorUpdateData { uint32 flags; uint32 filter_id; @@ -951,7 +951,7 @@ The BrightScript debugger supports the following debug commands: The **ThreadsResponse** struct has the following syntax: -``` +```c struct ThreadsResponse{ uint32 threads_count; ThreadInfo[] threads; @@ -1082,7 +1082,7 @@ struct ThreadsResponse{ The **StackTraceReponse** struct has the following syntax: -``` +```c struct StackTraceResponse{ uint32 stack_size; StackEntry[] entries; @@ -1225,7 +1225,7 @@ struct StackTraceResponse{ The **VariablesResponse** struct has the following syntax: -``` +```c struct VariablesResponse{ uint32 num_variables; VariableInfo[] variables; @@ -1439,7 +1439,7 @@ Dynamic breakpoints enable developers to navigate through the app, inspect its s The **AddBreakpointsRequestArgs** struct has the following syntax: -``` +```c struct AddBreakpointsRequestArgs { uint32 num_breakpoints; BreakpointSpec[] breakpoints; @@ -1504,7 +1504,7 @@ struct AddBreakpointsRequestArgs { The **AddBreakpointsResponseData** struct has the following syntax: -``` +```c struct AddBreakpointsResponseData { uint32 num_breakpoints; BreakpointInfo[] breakpoint_responses; @@ -1589,7 +1589,7 @@ struct AddBreakpointsResponseData { The **ListBreakpointsResponseData** struct has the following syntax: -``` +```c struct ListBreakpointsResponseData { uint32 num_breakpoints; BreakpointInfo[] breakpoints; @@ -1676,7 +1676,7 @@ struct ListBreakpointsResponseData { The **RemoveBreakpointsRequestArgs** struct has the following syntax: -``` +```c struct RemoveBreakpointsRequestArgs { uint32 num_breakpoints; uint32[] breakpoint_ids; @@ -1692,7 +1692,7 @@ struct RemoveBreakpointsRequestArgs { The **RemoveBreakpointsResponseData** struct has the following syntax: -``` +```c struct RemoveBreakpointsResponseData { uint32 num_breakpoints; BreakpointInfo[] breakpoint_infos; @@ -1783,7 +1783,7 @@ Use the LIST_BREAKPOINTS debugging command to get the existing conditional break The **AddConditonalBreakpointsRequestArgs** struct has the following syntax: -``` +```c struct AddBreakpointsRequestArgs { uint32 flags; uint32 num_breakpoints; @@ -1860,7 +1860,7 @@ struct AddBreakpointsRequestArgs { The **AddConditonalBreakpointsResponseData** struct has the following syntax: -``` +```c struct AddConditonalBreakpointsResponseData { uint32 num_breakpoints; ConditionalBreakpointInfo[] breakpoint_responses; @@ -1951,7 +1951,7 @@ Exception breakpoints enable developers to pause the debugger whenever a runtime The **SetExceptionBreakpointsRequestArgs** struct has the following syntax: -``` +```c struct SetExceptionBreakpointsRequestArgs { uint32 num_breakpoints; ExceptionBreakpointSpec[] breakpoints; @@ -2030,7 +2030,7 @@ struct SetExceptionBreakpointsRequestArgs { The **SetExceptionBreakpointsResponseData** struct has the following syntax: -``` +```c struct SetExceptionBreakpointsResponseData { uint32 num_breakpoints; ExceptionBreakpointInfo[] breakpoint_responses; diff --git a/docs/DEVELOPER/dev-tools/automated-channel-testing/javascript-library.md b/docs/DEVELOPER/dev-tools/automated-channel-testing/javascript-library.md index 9c7095a8..a8162a5a 100644 --- a/docs/DEVELOPER/dev-tools/automated-channel-testing/javascript-library.md +++ b/docs/DEVELOPER/dev-tools/automated-channel-testing/javascript-library.md @@ -415,7 +415,7 @@ const result = library.getChildNodes(rowList, searchData); - **locator** (optional): An array containing search criteria for the child nodes to be retrieved. The locator has the following syntax: - ``` + ```brightscript "using" ("attr", "tag", "text") : specify locator type "value": tag or attribute value "attribute"(only for "attr" type): specify attribute diff --git a/docs/DEVELOPER/dev-tools/brightscript-doc.md b/docs/DEVELOPER/dev-tools/brightscript-doc.md index a088f957..62648136 100644 --- a/docs/DEVELOPER/dev-tools/brightscript-doc.md +++ b/docs/DEVELOPER/dev-tools/brightscript-doc.md @@ -148,7 +148,7 @@ The field portion is optional, refers to variables within the specified function ## Example -``` +```brightscript ' Gets a false value in a convoluted way ' @deprecated Replaced by {@link .Foo2 Foo2} as of version 11.42 function Foo() as BooLean diff --git a/docs/DEVELOPER/dev-tools/brightscript-profiler.md b/docs/DEVELOPER/dev-tools/brightscript-profiler.md index cb5652b8..70ec7637 100644 --- a/docs/DEVELOPER/dev-tools/brightscript-profiler.md +++ b/docs/DEVELOPER/dev-tools/brightscript-profiler.md @@ -307,7 +307,7 @@ functions as a whole or for individuals lines of code in the functions If any of these metrics appear in a call path, they are specific to that call path. For example, in this call path: -``` +```brightscript : cpu.self=0,cpu.callees=14700,tm.self=0.000,tm.callees=1.989,mem.self=0,mem.callees=324452,calls=0 +- func1(): pkg:/components/file1.brs:83,cpu.self=200,cpu.callees=14500,tm.self=0.728,tm.callees=1.261,mem.self=5840,mem.callees=318612,calls=1 @@ -319,7 +319,7 @@ The metrics for func2() are specific to when it is called from func1(). However, in the table below: -``` +```brightscript ------------- BEGIN: TOP CONSUMERS: CPU.SELF ----------------- 1: func1(): pkg:/components/file1.brs:83,cpu.self=300,cpu.total=450,tm.self=0.001,tm.total=0.001,mem.self=0,mem.total=0,calls=5 diff --git a/docs/DEVELOPER/dev-tools/external-control-api.md b/docs/DEVELOPER/dev-tools/external-control-api.md index a5ab5f58..6506e210 100644 --- a/docs/DEVELOPER/dev-tools/external-control-api.md +++ b/docs/DEVELOPER/dev-tools/external-control-api.md @@ -794,7 +794,7 @@ The standard for deep linking uses parameters: You trigger deep linking by doing an HTTP post to port 8060 on your Roku device. The general form is -``` +```brightscript http://:8060/launch/[dev | channeID]?contentId=&MediaType= ``` diff --git a/docs/DEVELOPER/dev-tools/static-analysis-tool/command-line-utility.md b/docs/DEVELOPER/dev-tools/static-analysis-tool/command-line-utility.md index 6ef67121..1c75b81e 100644 --- a/docs/DEVELOPER/dev-tools/static-analysis-tool/command-line-utility.md +++ b/docs/DEVELOPER/dev-tools/static-analysis-tool/command-line-utility.md @@ -26,7 +26,7 @@ This utility supports Windows, Mac and Linux and requires Java to be installed i The static analysis utility is distributed as a ZIP file. The contents of the ZIP as as follows: -``` +```brightscript . └── sca-cmd ├── bin diff --git a/docs/DEVELOPER/discovery/continue-watching-cloud.md b/docs/DEVELOPER/discovery/continue-watching-cloud.md index 9928ffb8..df72b9d4 100644 --- a/docs/DEVELOPER/discovery/continue-watching-cloud.md +++ b/docs/DEVELOPER/discovery/continue-watching-cloud.md @@ -333,13 +333,13 @@ Handling deep links sent to your app from the Continue Watching row is essential **Syntax:** -``` +```text http://:8060/launch|input/?contentId=&mediaType=&profileId= ``` **Example:** -``` +```text http://192.168.1.4:8060/input/581251?contentId=dev-summit-21-keynote&mediaType=movie&profileId=12345 ``` @@ -347,7 +347,7 @@ http://192.168.1.4:8060/input/581251?contentId=dev-summit-21-keynote&mediaType=m To call the Continue Watching APIs, the app must include BrightScript code that adds the following HTTP headers (see the [**ifHttpAgent.addHeader()** function](doc:ifhttpagent) for more information). You must set the endpoint first before providing the headers. -``` +```brightscript 'SetUrl needs to be called first request.SetUrl("https://userdata.sr.roku.com/user-data/v1/content/continueWatching") request.AddHeader("Content-Type","application/json") diff --git a/docs/DEVELOPER/discovery/continue-watching.md b/docs/DEVELOPER/discovery/continue-watching.md index 7b83871b..c07b3697 100644 --- a/docs/DEVELOPER/discovery/continue-watching.md +++ b/docs/DEVELOPER/discovery/continue-watching.md @@ -251,13 +251,13 @@ Handling deep links sent to your app from the Continue Watching row is essential **Syntax:** -``` +```text http://:8060/launch|input/?contentId=&mediaType=&profileId= ``` **Example:** -``` +```text http://192.168.1.4:8060/input/581251?contentId=dev-summit-21-keynote&mediaType=movie&profileId=12345 ``` @@ -265,7 +265,7 @@ http://192.168.1.4:8060/input/581251?contentId=dev-summit-21-keynote&mediaType=m To call the Continue Watching APIs, the app must include BrightScript code that adds the following HTTP headers (see the [**ifHttpAgent.addHeader()** function](doc:ifhttpagent) for more information). You must set the endpoint first before providing the headers. -``` +```brightscript 'SetUrl needs to be called first request.SetUrl("https://userdata.sr.roku.com/user-data/v1/content/continueWatching") request.AddHeader("Content-Type","application/json") diff --git a/docs/DEVELOPER/discovery/implementing-deep-linking.md b/docs/DEVELOPER/discovery/implementing-deep-linking.md index 9c4ebb8a..3ec36c5e 100644 --- a/docs/DEVELOPER/discovery/implementing-deep-linking.md +++ b/docs/DEVELOPER/discovery/implementing-deep-linking.md @@ -42,13 +42,13 @@ Deep link requests contain two key parameters: **contentid** and **mediaType**. The following example demonstrates a deep link request sent to an app. The [**source** parameter](doc:dev-environment#source-parameter) specifies the origin of the deep link request (in this case, it is from [Roku Search](doc:implementing-search)): -``` +```text http://192.168.1.114:8060/launch/50000?contentId=myAwesomeShow|Season=1|Episode=1&mediaType=series&source=hs-search ``` The app receives the deep link parameters as an associative array as demonstrated in the following example (see [Implementing Deep Linking](#implementing-deep-linking) for more information on handling these parameters; see [Using the debug console for troubleshooting deep linking parameters](#using-the-debug-console-for-troubleshooting-deep-linking-parameters) for how to check the deep linking parameters being sent to your app): -``` +```text = { action: "display" @@ -168,7 +168,7 @@ Deep linking is implemented by passing launch parameters to your app's Main() fu 3. If the contentId and mediaType are valid, launch the specified content item using the appropriate [launch behavior for the mediaType](doc:implementing-deep-linking). If either the contentId or mediaType are invalid, launch the app home page. - ``` + ```brightscript if (args.mediaType = "movie" or args.mediaType = "episode" or args.mediaType = "shortFormVideo" or args.mediaType = "series" or args.mediaType = "tvSpecial") if valid_contentId(contentId) ' You define this function in your back-end 'play content directly, starting at last bookmarked position @@ -195,7 +195,7 @@ Deep linking is implemented by passing launch parameters to your app's Main() fu See [Sample app](doc:implementing-deep-linking) to download and install a sample app that demonstrates how to use [roInputEvent](doc:roinputevent) to handle deep links while your app is running. - ``` + ```brightscript '... screen = CreateObject("roSGScreen") m.port = CreateObject("roMessagePort") @@ -263,7 +263,7 @@ You can test deep linking in an app by sending ECP commands via cURL to your Rok To test deep linking using ECP/cURL, send an HTTP POST request to port 8060 on your Roku device using the following syntax: -``` +```text http://:8060//?contentId=&mediaType= ``` @@ -331,7 +331,7 @@ This is useful when troubleshooting deep links because it helps you identify the The following example demonstrates how to output the associative array containing the deep linking parameters: -``` +```brightscript sub Main(args) '... if (args.mediaType <> invalid) and (args.contentId <> invalid) diff --git a/docs/DEVELOPER/discovery/instant-signup.md b/docs/DEVELOPER/discovery/instant-signup.md index e8abc61e..6bb7bb05 100644 --- a/docs/DEVELOPER/discovery/instant-signup.md +++ b/docs/DEVELOPER/discovery/instant-signup.md @@ -443,7 +443,7 @@ Apps can leverage the [ChannelStore](doc:channelstore) APIs and [Roku Pay web se 2. Get the transaction ID from the **purchaseId** field of the child content node. Find the subscription to be validated using the **code** or **productType** fields of the child content node. - ``` + ```brightscript if (myChannelStore.purchases <> invalid) count = myChannelStore.purchases.GetChildCount() for x = 0 to count - 1 @@ -481,7 +481,7 @@ Apps can leverage the [ChannelStore](doc:channelstore) APIs and [Roku Pay web se * Call the [**ChannelStore.storeChannelCredData **](doc:channelstore) command to store the access token in the Roku cloud. You can use the **status** and **response** fields of the **storeChannelCredDataStatus** content node to verify that the command was successful and that the access token stored in the Roku cloud has the specified value. - ``` + ```brightscript myChannelStore.channelCredData = "your access token" myChannelStore.command = "storeChannelCredData " diff --git a/docs/DEVELOPER/discovery/search/prioritizing-authenticated-channels-in-roku-search.md b/docs/DEVELOPER/discovery/search/prioritizing-authenticated-channels-in-roku-search.md index daca84d8..8017e66c 100644 --- a/docs/DEVELOPER/discovery/search/prioritizing-authenticated-channels-in-roku-search.md +++ b/docs/DEVELOPER/discovery/search/prioritizing-authenticated-channels-in-roku-search.md @@ -36,7 +36,7 @@ To use the Roku Event Dispatcher in your app's authentication workflow to send a 1. Enable the RED library in your app by adding the following line to the [manifest](doc:channel-manifest) file: - ``` + ```brightscript sg_component_libs_required=roku_analytics ``` @@ -50,7 +50,7 @@ To use the Roku Event Dispatcher in your app's authentication workflow to send a The following example demonstrates how to send authentication events: - ``` + ```brightscript sub Notify_Roku_UserIsLoggedIn(rsgScreen = invalid as Object) ' get the global node if type(m.top) = "roSGNode" ' was called from a component script @@ -83,17 +83,17 @@ To use the RAF **fireRokuMarketingPixel()** method to send authentication events 1. Enable the RAF library in your app by adding the following line to the [manifest](doc:channel-manifest) file: - ``` + ```brightscript bs_libs_required=roku_ads_lib ``` 2. Instantiate the RAF library in the app: - ``` + ```brightscript adIface = Roku_Ads() ``` 3. When an authenticated customer launches your app, call the **fireRokuMarketingPixel()** method using the following syntax: - ``` + ```brightscript adIface.fireRokuMarketingPixel("Roku_Authenticated") \ No newline at end of file diff --git a/docs/DEVELOPER/getting-started/architecture/channel-manifest.md b/docs/DEVELOPER/getting-started/architecture/channel-manifest.md index e0cc320d..5f01bacf 100644 --- a/docs/DEVELOPER/getting-started/architecture/channel-manifest.md +++ b/docs/DEVELOPER/getting-started/architecture/channel-manifest.md @@ -37,7 +37,7 @@ These attributes include but are not limited to the following: ## Example manifest file -``` +```brightscript # Channel Details title=HeroGridChannel major_version=1 diff --git a/docs/DEVELOPER/getting-started/architecture/content-metadata.md b/docs/DEVELOPER/getting-started/architecture/content-metadata.md index 0f25df7d..a9830acb 100644 --- a/docs/DEVELOPER/getting-started/architecture/content-metadata.md +++ b/docs/DEVELOPER/getting-started/architecture/content-metadata.md @@ -404,7 +404,7 @@ Developers looking to pass custom HTTP headers with a licensing request can now ### Example of configuring a dash stream with Widevine DRM -``` +```brightscript contMeta = { HDPosterUrl:"pkg:/images/BigBuckBunny.jpg" SDPosterUrl:"pkg:/images/BigBuckBunny.jpg" @@ -426,7 +426,7 @@ contMeta = { The following code demonstrates how you can wrap the Widevine license challenge payload in the request format (JSON or XML) required by your license server proxy. -``` +```brightscript ' set the content type ' for json it may be set to "application/json ' for xml it may be set to "text/xml" or "application/xml" @@ -1014,7 +1014,7 @@ Content Delivery Networks (CDNs) can be switched during playback to load balance **Example** -``` +```brightscript this.cur_clip.CDNConfig = [ { URLFilter:"http://cdn1.xyz.com/abc/", ContentFilter, "testProgram", priority: 1, weight: 50, serviceLocation: "west" }, { URLFilter:"http://cdn2.xyz.com/abc/", ContentFilter, "testProgram", priority: 1, weight: 50, serviceLocation: "east" }, @@ -1039,7 +1039,7 @@ set to only apply to your Audio and Video nodes, create a unique instance of roHttpAgent for them and assign it directly. For example, for a Video node you should do the following: -``` +```brightscript 'Assume video is a valid Video node instance httpAgent = CreateObject("roHttpAgent") video.setHttpAgent(httpAgent) @@ -1093,7 +1093,7 @@ of requests. Once you have created your agent, you can set the Video node's `drmHttpAgent` field directly to designate that the special agent is to supersede any currently-set agent in the case of DRM key and license requests. The `drmHttpAgent` field must be configured before setting the content in the Video node. -``` +```brightscript ' Configure the DRM HttpAgent before setting content in the Video node httpAgent = CreateObject("roHttpAgent") httpAgent.AddHeader("DRM-Specific-1", "weqweqweqweqweqweqeqeqeqeqwe") diff --git a/docs/DEVELOPER/getting-started/architecture/file-system.md b/docs/DEVELOPER/getting-started/architecture/file-system.md index 245fade4..bae834aa 100644 --- a/docs/DEVELOPER/getting-started/architecture/file-system.md +++ b/docs/DEVELOPER/getting-started/architecture/file-system.md @@ -51,7 +51,7 @@ in [ifFileSystem](doc:iffilesystem) methods, as well as in other components which use files. A Pathname is a string with the following format: -``` +```brightscript device:/dir1/dir2/…/filename ``` @@ -78,7 +78,7 @@ format above. The filename components in a pathname may not contain any of these characters: -``` +```brightscript < > : " / | ? * ``` @@ -88,7 +88,7 @@ nor any whitespace or non-printable character. **Example of path names used from BrightScript** -``` +```brightscript theme.OverhangSliceSD = "pkg:/images/Overhang_Slice_SD43.png" http.Http.GetToFile("tmp:/categorylist") DeleteFile("tmp:/categorylist") diff --git a/docs/DEVELOPER/libraries/index.md b/docs/DEVELOPER/libraries/index.md index 2a74b9b2..f893fa0c 100644 --- a/docs/DEVELOPER/libraries/index.md +++ b/docs/DEVELOPER/libraries/index.md @@ -113,7 +113,7 @@ Analytics vendors using Model #2 use `trackEvent` rather than `setContentMetadat #### Example: -``` +```brightscript m.global.RSG_analytics.init = { ga4: { api_secret: "apisecret_value", @@ -135,7 +135,7 @@ m.global.RSG_analytics.init = { Manifest entry to use RACL: -``` +```text sg_component_libs_required=Roku_Analytics ``` @@ -155,7 +155,7 @@ set** at the end of mid-roll ads. To use RACL, add a field, "RSG_analytics," to `m.global` and then create an roSGNode object like so: -``` +```brightscript m.global.addField("RSG_analytics", "node", false) m.global.RSG_analytics = CreateObject("roSGNode", "Roku_Analytics:AnalyticsNode") ``` @@ -176,7 +176,7 @@ vendor-specific configuration data. **Example:** -``` +```brightscript m.global.RSG_analytics.init = { IQ : { PCODE : "pcode_value" @@ -205,7 +205,7 @@ method needs to be set each time a new Video node is created. **Example:** -``` +```brightscript m.global.RSG_analytics.initVideoPlayer = { video: m.video } @@ -223,7 +223,7 @@ for analytics providers and are optional. **Example with only Roku content meta-data:** -``` +```brightscript myContent = { streamFormat: "mp4", streamUrl: "www.mycontent.com/video.mp4" @@ -236,7 +236,7 @@ m.global.RSG_analytics.setContentMetadata = { **Example with Roku content meta-data and additional analytics provider information:** -``` +```brightscript myContent = { streamFormat: "mp4", streamUrl: "www.mycontent.com/video.mp4" @@ -271,7 +271,7 @@ after a mid-roll ad). **Example:** -``` +```brightscript sub onVideoState() closeStates = { finished : "", @@ -317,7 +317,7 @@ Developers can track events from the [standard GA4 events](https://developers.go **Example:** -``` +```brightscript m.global.RSG_analytics.trackEvent = { GA4: { events: [ @@ -348,7 +348,7 @@ displayed in the console). **Example:** -``` +```brightscript m.global.RSG_analytics.debug = true ``` @@ -359,7 +359,7 @@ m.global.RSG_analytics.debug = true Following is a simple example of using RACL with a service that supports Model #1. -``` +```brightscript sub VerySimpleShowVideo(item) m.global.addField("RSG_analytics","node",false) m.global.RSG_analytics = CreateObject("roSGNode","Roku_Analytics:AnalyticsNode") diff --git a/docs/DEVELOPER/media-playback/bookmarking.md b/docs/DEVELOPER/media-playback/bookmarking.md index fa501456..e615a77c 100644 --- a/docs/DEVELOPER/media-playback/bookmarking.md +++ b/docs/DEVELOPER/media-playback/bookmarking.md @@ -22,7 +22,7 @@ This guide provides simple instructions on two different ways to bookmark media It is important to know that video playback position (or "timestamp") can be retrieved via the position field in the video node. -``` +```brightscript m.video = m.top.findNode("MyVideo") TimeStamp = m.video.position ``` @@ -35,7 +35,7 @@ To do this, the app must first retrieve the timestamp as outlined above, then ma It is recommended that the app makes the request to store this timestamp on the backend once every 30 seconds, but the frequency can be increased on devices with more memory. This concept is very similar to beacons fired by the Roku Ad Framework. The best way to approach this is through roUrlTransfer. -``` +```brightscript url = ('url with timestamp to send to developer end') curl = createObject("roUrlTransfer") curl.setUrl(url) @@ -50,7 +50,7 @@ While it is ideal to store timestamps in your backend service, it is also possib To write to the registry, use the [roRegistrySection](doc:roregistrysection) component. -``` +```brightscript sec = createObject("roRegistrySection", "MySection") if sec.Exists("PlaybackBookmark") BookmarkTime = sec.Read("PlaybackBookmark") @@ -59,7 +59,7 @@ To write to the registry, use the [roRegistrySection](doc:roregistrysection) com If the roku device has a previously stored value that matches the PlaybackBookmark key, then it will return the value stored inside the registry. The function below shows how to create a key value pair to store the timestamp of a bookmark. The timestamp must be done in seconds. -``` +```brightscript TimeStamp = 360 sec = createObject("roRegistrySection", "MySection") sec.Write("PlaybackBookmark", TimeStamp) @@ -68,7 +68,7 @@ If the roku device has a previously stored value that matches the PlaybackBookma This will save the media playback position inside the registry and the Flush() method will save it to persistent storage in the case of a reboot. Note that if you are running this multiple times on a timer, it will overwrite any previous value associated with the same key. Once this is done, all that's left is to find run the seek() function from the video node to resume playback from the last point. -``` +```brightscript m.video = m.top.findNode("MyVideo") m.video.content = videoContent m.video.control = "play" diff --git a/docs/DEVELOPER/media-playback/closed-caption.md b/docs/DEVELOPER/media-playback/closed-caption.md index fbb10e12..3870ed9f 100644 --- a/docs/DEVELOPER/media-playback/closed-caption.md +++ b/docs/DEVELOPER/media-playback/closed-caption.md @@ -63,7 +63,7 @@ fired, and the **[Video node](doc:video)** is playing full screen and setFocus is enabled i.e., the Video node is in focus, as displayed in the following code example: -``` +```brightscript sub init() m.top.setFocus(true) setVideo() diff --git a/docs/DEVELOPER/media-playback/fast-video-start.md b/docs/DEVELOPER/media-playback/fast-video-start.md index fd75b4b6..d484d9fc 100644 --- a/docs/DEVELOPER/media-playback/fast-video-start.md +++ b/docs/DEVELOPER/media-playback/fast-video-start.md @@ -51,7 +51,7 @@ effect. The following code demonstrates this use case. -``` +```brightscript port = CreateObject( "roMessagePort" ) content = { diff --git a/docs/DEVELOPER/media-playback/instant-resume.md b/docs/DEVELOPER/media-playback/instant-resume.md index 2b1e3a84..5855d01b 100644 --- a/docs/DEVELOPER/media-playback/instant-resume.md +++ b/docs/DEVELOPER/media-playback/instant-resume.md @@ -81,7 +81,7 @@ In the SceneGraph XML file of the app's Scene node, insert `customization suspen The following BrightScript code demonstrates how to execute the `customSuspend` and `customResume` handlers in the Scene. The **customResume** handler includes logic for managing the playback experience, which includes handling any deep link requests sent to the app upon relaunch. Details for each of these handlers, including the tasks to be performed within them, are provided after. -``` +```brightscript function customSuspend(arg as dynamic) for each key in arg print " " key "=" arg[key] @@ -144,7 +144,7 @@ Once an Instant Resume app is suspended, it should return the user to the Roku h To enable an Instant Resume app to execute background tasks, set the **allowBackgroundTask** field of the **Scene** node. The following BrightScript code demonstrates how to do this: -``` +```brightscript scene = screen.CreateScene("BackgroundTaskTestScene") scene.allowBackgroundTask = true ``` @@ -208,7 +208,7 @@ It is recommended that apps use a basic implementation for the playback of VOD c The following code snippet illustrates logic that could be used to resume an app when a video node has already been created and is on the screen stack. In this case, it closes the video node, removes it from the screen stack, and switches focus on the previous screen, which is typically the Details Screen. -``` +```brightscript ' Callback function when the app is suspended from an app exit. ' In this example, we are only printing to the brightscript console ' that the app is being suspended. diff --git a/docs/DEVELOPER/media-playback/trick-mode/bif-file-creation.md b/docs/DEVELOPER/media-playback/trick-mode/bif-file-creation.md index 3451e87f..a22528af 100644 --- a/docs/DEVELOPER/media-playback/trick-mode/bif-file-creation.md +++ b/docs/DEVELOPER/media-playback/trick-mode/bif-file-creation.md @@ -143,7 +143,7 @@ Three types of `` are allowed: Available options: -``` +```brightscript --target arg The file(s) or directory on which to operate. -t [ --timestamp-multiplier ] arg The absolute presentation timestamp (PTS) in milliseconds is the filename multiplied diff --git a/docs/DEVELOPER/media-playback/voice-controls/transport-controls.md b/docs/DEVELOPER/media-playback/voice-controls/transport-controls.md index b4662625..5fbab82d 100644 --- a/docs/DEVELOPER/media-playback/voice-controls/transport-controls.md +++ b/docs/DEVELOPER/media-playback/voice-controls/transport-controls.md @@ -46,7 +46,7 @@ these steps: 1. Create an **roInput** object, and set the [**roMessagePort**](doc:romessageport) for receiving events. - ``` + ```brightscript input = CreateObject("roInput") port = CreateObject("roMessagePort") input.SetMessagePort(port) @@ -55,7 +55,7 @@ these steps: 2. Register the **roInput** component for voice commands by calling its [**EnableTransportEvents()**](/dev/docs/ifinput#enabletransportevents-as-boolean) function. This tells the Roku OS that your app can handle voice commands sent to the **roInput** object. Once this is set, your app will receive **roInput** events for every voice command on this **roInput** object. - ``` + ```brightscript input.enableTransportEvents() ``` @@ -68,7 +68,7 @@ these steps: 3. This method takes an AssociativeArray with two fields: **id** and **status**. The **id** field specifies the transport ID event; the **status** specifies whether the event was handled, handled with an error, or unhandled. 4. This method should be called immediately after a voice command is received. If your application does not handle a transport event (or the command is unknown or not implemented in your app), mark it as "error.generic" or "unhandled". See [Error handling](#error-handling) for the complete list of error messages to which the **status** field can be set. c. Optionally, for better modularization, you can pass the captured voice command to a function for handing. - ``` + ```brightscript while m.isPlaying msg = wait(0, port) if type(msg) = "roInputEvent" then @@ -90,7 +90,7 @@ these steps: 4. Add business logic for handling each voice command. In this example, a function is used to receive the voice command and implement the required behavior. As a best practice, set the **ret.status** field to "unhandled" by default, and then update it to "success" if your app handles the command, or "error.generic" if the app cannot fulfill it. Setting the status to "error.generic" displays "That is not available" in the Roku Voice heads-up display. The default "unhandled" status results in the Roku OS executing the default behavior. - ``` + ```brightscript function handleTransport(evt) cmd = evt.command ret = {status: "unhandled"} diff --git a/docs/DEVELOPER/media-playback/voice-controls/voice-profile-selector.md b/docs/DEVELOPER/media-playback/voice-controls/voice-profile-selector.md index 3a6447d1..be2d61ab 100644 --- a/docs/DEVELOPER/media-playback/voice-controls/voice-profile-selector.md +++ b/docs/DEVELOPER/media-playback/voice-controls/voice-profile-selector.md @@ -26,7 +26,7 @@ To implement voice support for a profile selection screen, integrate the followi Before calling the **StartVoiceActionSelectionRequest()** function, developers can call the [roDeviceInfo.HasFeature("handsfree_voice")](doc:ifdeviceinfo#hasfeaturefeature-as-string-as-boolean) function to check whether a Roku device is paired with a hands-free Roku remote control. - ``` + ```brightscript appMgr = CreateObject("roAppManager") deviceInfo = CreateObject("roDeviceInfo") ' channel is launched and profile selection screen is displayed @@ -37,7 +37,7 @@ To implement voice support for a profile selection screen, integrate the followi * **Profile selection via registered/matched text strings**. Apps can call the [roAppManager.SetVoiceActionStrings()](doc:ifappmanager) function to register a list of text strings, such as user profile names, that can be matched to voice requests. - ``` + ```brightscript appMgr = CreateObject("roAppManager") profile1 = { text: "kids", link: "d46ge-i8Y5-192"} profile2 = { text: "Jane", link: "2a2Nu-u1D4-555"} @@ -50,7 +50,7 @@ To implement voice support for a profile selection screen, integrate the followi When the name uttered by the user matches the registered text string, the matched text string is provided to the app via the [roInput voice command handler](doc:ifinput). Specifically, if the **command** received by the handler is "action", the associative array returned by the [**roInputEvent.GetInfo()**](doc:roinputevent) method includes a **text** field that is set to the matched text string. - ``` + ```brightscript function handleTransport(evt) cmd = evt.command ret = {status: "unhandled"} @@ -68,7 +68,7 @@ To implement voice support for a profile selection screen, integrate the followi Specifically, if the **command** received by the handler is "select", the associative array returned by the [**roInputEvent.GetInfo()**](doc:roinputevent) method includes a **ordinal** field that is set to a numerical value corresponding to the ordinal number spoken by the user. Values may range between 1–6 (one-based indexing is used). - ``` + ```brightscript function handleTransport(evt) cmd = evt.command ret = {status: "unhandled"} diff --git a/docs/DEVELOPER/performance-guide/data-management.md b/docs/DEVELOPER/performance-guide/data-management.md index baac3491..fe8eca0a 100644 --- a/docs/DEVELOPER/performance-guide/data-management.md +++ b/docs/DEVELOPER/performance-guide/data-management.md @@ -30,7 +30,7 @@ next: Given the rendezvous penalties, don't repeatedly reference the same fields in `m.global` to get data subsections. Use temporaries to hold references to successive parts of the tree. For example, assume that you have a large set of app configuration data stored in `m.global.config`. This data is a large web with elements (AAs or node trees) for settings, analytics, etc.: -``` +```brightscript m.global { config diff --git a/docs/DEVELOPER/performance-guide/data-transfer-apis.md b/docs/DEVELOPER/performance-guide/data-transfer-apis.md index ba7571fe..648f1793 100644 --- a/docs/DEVELOPER/performance-guide/data-transfer-apis.md +++ b/docs/DEVELOPER/performance-guide/data-transfer-apis.md @@ -56,7 +56,7 @@ The number of nested objects within an object that were copied, rather than move #### Example -``` +```brightscript ' Can be on Task thread or render thread n = CreateObject("roSGNode", "Node") n.AddField("aa_field", "assocarray", true) @@ -68,7 +68,7 @@ The number of nested objects within an object that were copied, rather than move This code will output the following on the port 8085 console: -``` +```text = { key: "value" @@ -100,7 +100,7 @@ The associative array that was moved from the source field. #### Example -``` +```brightscript n = CreateObject("roSGNode", "ContentNode") n.AddField("aa_field", "assocarray", true) n.aa_field = { key: "value"}' or use moveIntoField() @@ -123,7 +123,7 @@ print my_aa ' contents of aa_field > > The following example is the same as the above, except a nested object contains an external reference. As a result, the nested object is **copied** to the destination rather than being moved. > -> ``` +> ```brightscript > sub_array = [1, 2, 3] > aa = {foo: "hello", bar: sub_array} > ' At this point, there is an external reference into aa @@ -197,7 +197,7 @@ This function returns a reference to the field’s value. This function returns #### Example -``` +```brightscript ' on render thread: n = CreateObject("roSGNode", "Node") n.AddField("aa_field", "assocarray", true) @@ -211,7 +211,7 @@ This function returns a reference to the field’s value. This function returns This code will output the following on the port 8085 console: -``` +```text = { key: "value" @@ -249,7 +249,7 @@ This function returns a copy of the specified object. #### Example -``` +```brightscript utils = CreateObject("roUtils") di = CreateObject("roDeviceInfo") aa = { a: 1, b: { b1: 42 }, c: di } @@ -262,7 +262,7 @@ utils = CreateObject("roUtils") This code will output the following on the port 8085 console: -``` +```brightscript IsSameObject false new_aa.a 1 new_aa.b = @@ -291,7 +291,7 @@ Returns true if **data1** and **data2** reference the same object; otherwise, th #### Example -``` +```brightscript shared = {} aa = {"a": shared, "b": shared} utils = CreateObject("roUtils") @@ -308,7 +308,7 @@ shared = {} Use the following syntax to define message handlers: -``` +```brightscript sub MyMessagehandler(data, msgInfo) ``` diff --git a/docs/DEVELOPER/performance-guide/measuring-channel-performance.md b/docs/DEVELOPER/performance-guide/measuring-channel-performance.md index ca62935e..af27b023 100644 --- a/docs/DEVELOPER/performance-guide/measuring-channel-performance.md +++ b/docs/DEVELOPER/performance-guide/measuring-channel-performance.md @@ -29,7 +29,7 @@ Apps must fire an **AppLaunchComplete** beacon when the app home page is fully r To fire the **AppLaunchComplete** beacon from the app, call the **signalBeacon()** function on any node as demonstrated in the following example: -``` +```brightscript myScene.signalBeacon("AppLaunchComplete") ``` @@ -43,7 +43,7 @@ These beacons, which were introduced in [Roku OS 9.3](doc:release-notes#roku-os- To fire the **AppDialogInitiate**/**AppDialogComplete** beacons from the app, call the **signalBeacon()** function on any node as demonstrated in the following example: -``` +```brightscript myScene.signalBeacon("AppDialogInitiate") myScene.signalBeacon("AppDialogComplete") ``` @@ -54,7 +54,7 @@ myScene.signalBeacon("AppDialogComplete") If your app contains an EPG, the application must also fire beacons when the user initiates a keypress to display the EPG (**EPGLaunchInitiate**) and when the EPG is fully rendered and navigable (**EPGLaunchComplete**). The following example demonstrates how to do this: -``` +```brightscript myEPGComponent.signalBeacon("EPGLaunchInitiate") m.top.signalBeacon("EPGLaunchComplete") ``` diff --git a/docs/DEVELOPER/performance-guide/optimization-techniques.md b/docs/DEVELOPER/performance-guide/optimization-techniques.md index 62357dc1..41b7ffcc 100644 --- a/docs/DEVELOPER/performance-guide/optimization-techniques.md +++ b/docs/DEVELOPER/performance-guide/optimization-techniques.md @@ -36,13 +36,13 @@ For example, accessing a 5.6MB AA can take hundreds of milliseconds. If this cop When copying nodes, do not simply call: -``` +```brightscript node2.setFields(node1.getFields()) ``` Setting nonexistent fields in a node will invoke additional internal verification and warning outputs to the debug console, causing UI lag. Instead, do something like: -``` +```brightscript function cloneNode(oldNode as Object) as Object newNode = createObject("roSGNode",oldNode.subtype()) 'subtyped node should automatically have all the fields of the original node newNode.setFields(oldNode.getFields()) diff --git a/docs/DEVELOPER/release-notes/index.md b/docs/DEVELOPER/release-notes/index.md index eae9f03d..5846869a 100644 --- a/docs/DEVELOPER/release-notes/index.md +++ b/docs/DEVELOPER/release-notes/index.md @@ -1340,7 +1340,7 @@ ReadAsciiFile() now supports UTF-16 files ([**Global Utility Functions**](doc:gl Example: -``` +```brightscript aa = { a: 2, b: 1, c: 3 } for each x in aa print x;" from ";aa diff --git a/docs/DEVELOPER/release-notes/raf-release-notes.md b/docs/DEVELOPER/release-notes/raf-release-notes.md index f769b810..73ebafa1 100644 --- a/docs/DEVELOPER/release-notes/raf-release-notes.md +++ b/docs/DEVELOPER/release-notes/raf-release-notes.md @@ -97,7 +97,7 @@ next: RAF would print a warning: - ``` + ```brightscript [RAF.err] roUrlTransfer.setURL("some invalid URL") rejected argument - invalid chars? (space and "<>\^\`{|} must be %-encoded) ``` - Bug fixes and performance improvements diff --git a/docs/DEVELOPER/roku-pay/implementation/on-device-upgrade-downgrade.md b/docs/DEVELOPER/roku-pay/implementation/on-device-upgrade-downgrade.md index ba05adbc..c1bc205d 100644 --- a/docs/DEVELOPER/roku-pay/implementation/on-device-upgrade-downgrade.md +++ b/docs/DEVELOPER/roku-pay/implementation/on-device-upgrade-downgrade.md @@ -52,7 +52,7 @@ To send a [**doOrder command**](doc:channelstore#doorder) to upgrade or downgrad 1. Set the `order.action` field to `Upgrade` or `Downgrade` (the required values are case-sensitive; do not pass "upgrade" or "downgrade" in the `action` field). - ``` + ```brightscript m.channelStore = CreateObject("roSGNode","ChannelStore") myOrder = CreateObject("roSGNode", "ContentNode") myItem = myOrder.createChild("ContentNode") @@ -77,7 +77,7 @@ To call the [**SetOrder()** function](doc:ifchannelstore#setorderorder-as-object 1. Set the `orderInfo.action` field to `Upgrade` or `Downgrade` (the required values are case-sensitive; do not pass "upgrade" or "downgrade" in the `action` field). - ``` + ```brightscript m.store = CreateObject("roChannelStore") ' Populate myOrderItems myOrderInfo.action = "Upgrade" @@ -85,7 +85,7 @@ To call the [**SetOrder()** function](doc:ifchannelstore#setorderorder-as-object 2. Call the [**SetOrder()** function](doc:ifchannelstore#setorderorder-as-object-orderinfo-as-object-as-void) to have the customer confirm the upgrade/downgrade. The **myOrderItems** parameter specifies the in-channel product to which the customer is upgrading/downgrading; the **myOrderInfo** parameter whether the transaction is an upgrade or downgrade. - ``` + ```brightscript m.store.setOrder(myOrderItems, myOrderInfo) ``` diff --git a/docs/DEVELOPER/roku-pay/implementation/push-notifications-jwt.md b/docs/DEVELOPER/roku-pay/implementation/push-notifications-jwt.md index ca7afc81..d92986b6 100644 --- a/docs/DEVELOPER/roku-pay/implementation/push-notifications-jwt.md +++ b/docs/DEVELOPER/roku-pay/implementation/push-notifications-jwt.md @@ -85,7 +85,7 @@ The JOSE header and the set of JWT claims are each base64url-encoded. The two ar The encoded, period-concatenated JOSE header, payload, and JWS signature form the full HTTP message body: -``` +```text eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9. eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ. dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk diff --git a/docs/DEVELOPER/roku-pay/implementation/push-notifications.md b/docs/DEVELOPER/roku-pay/implementation/push-notifications.md index de540a85..259bdf1b 100644 --- a/docs/DEVELOPER/roku-pay/implementation/push-notifications.md +++ b/docs/DEVELOPER/roku-pay/implementation/push-notifications.md @@ -24,7 +24,7 @@ Roku Pay push notifications can not be redirected in any way. Requests time out Push notifications include transaction data and a `responseKey`. -``` +```json { ... transaction data fields "responseKey":"abcdabcd6b1649f681a408f1beebabcd" diff --git a/docs/DEVELOPER/roku-pay/implementation/roku-web-service.md b/docs/DEVELOPER/roku-pay/implementation/roku-web-service.md index da5b3ea5..e3cd52be 100644 --- a/docs/DEVELOPER/roku-pay/implementation/roku-web-service.md +++ b/docs/DEVELOPER/roku-pay/implementation/roku-web-service.md @@ -106,7 +106,7 @@ For TVOD apps, the `isEntitled` flag is set to "false"; therefore, your entitle #### Request example: -``` +```http GET https://apipub.roku.com/listen/transaction-service.svc/validate-transaction/{partnerAPIKey}/{transactionid} ``` @@ -303,7 +303,7 @@ The `validate-refund` API is used to verify that a Roku Pay purchase has been re **Request syntax:** -``` +```http GET https://apipub.roku.com/listen/transaction-service.svc/validate-refund/{partnerAPIKey}/{refundId} ``` @@ -379,7 +379,7 @@ The `cancel-subscription` API cancels the subscription corresponding to the spec **Method/URL** -``` +```http POST https://apipub.roku.com/listen/transaction-service.svc/cancel-subscription ``` @@ -452,7 +452,7 @@ The sum of all partial refunds applied against any given transaction cannot exce **Method/URL** -``` +```http POST https://apipub.roku.com/listen/transaction-service.svc/refund-subscription ``` @@ -516,7 +516,7 @@ Set the `newBillCycleDate` to the updated date on which the user should be bille **Method/URL** -``` +```http POST https://apipub.roku.com/listen/transaction-service.svc/update-bill-cycle ``` @@ -578,7 +578,7 @@ The response will include a `partnerReferenceId` that can be used later to find **Request example:** -``` +```http POST https://apipub.roku.com/listen/transaction-service.svc/issue-service-credit ``` diff --git a/docs/DEVELOPER/roku-pay/implementation/tracking-signup-abandonment.md b/docs/DEVELOPER/roku-pay/implementation/tracking-signup-abandonment.md index da80fc83..b32fd27e 100644 --- a/docs/DEVELOPER/roku-pay/implementation/tracking-signup-abandonment.md +++ b/docs/DEVELOPER/roku-pay/implementation/tracking-signup-abandonment.md @@ -102,7 +102,7 @@ To use the Roku Event Dispatcher in your app's signup workflow to send events, f The following example demonstrates how to send signup events: - ``` + ```brightscript sub Notify_Roku_UserIsLoggedIn(rsgScreen = invalid as Object) ' get the global node if type(m.top) = "roSGNode" ' was called from a component script diff --git a/docs/DEVELOPER/roku-pay/implementation/tvod-app-catalog.md b/docs/DEVELOPER/roku-pay/implementation/tvod-app-catalog.md index 4a7458f9..ea2a9c97 100644 --- a/docs/DEVELOPER/roku-pay/implementation/tvod-app-catalog.md +++ b/docs/DEVELOPER/roku-pay/implementation/tvod-app-catalog.md @@ -59,7 +59,7 @@ To update your app with the new **DoOrder** API, follow these steps: 1. Initialize the ChannelStore API generic request framework. The following code monitors the **channelStore.requestStatus** field and fires the **onRequestStatus()** callback function when changes to the **requestStatus** field occur. The **onRequestStatus()** function determines which command was sent and sends the results to the dedicated parser for the command. - ``` + ```brightscript function init() m.store = m.parent.FindNode("channelStore") m.store.observeField("requestStatus", "onRequestStatus") @@ -99,7 +99,7 @@ To update your app with the new **DoOrder** API, follow these steps: 2. Send the **DoOrder** command to purchase the transactional content, and then check the order status. - ``` + ```brightscript sub makeTVODPurchase(requestData as dynamic) print "calling makeTVODPurchase" 'myOrder = { "code": request.productCode, "name": request.productName, "qty": 1} diff --git a/docs/DEVELOPER/roku-pay/implementation/tvod-channel.md b/docs/DEVELOPER/roku-pay/implementation/tvod-channel.md index bdd10b8f..7e594512 100644 --- a/docs/DEVELOPER/roku-pay/implementation/tvod-channel.md +++ b/docs/DEVELOPER/roku-pay/implementation/tvod-channel.md @@ -55,7 +55,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow * **code**. The uniqueID specified for the product in the **In-App Products** page. Use the **addField()** method to add the **code** field to the **ContentNode**. * **title** (optional). The title of the product being purchased (for example, the name of a movie rental). - ``` + ```brightscript m.orderInfo = createObject("roSGNode", "contentNode") m.orderInfo.priceDisplay = "5.99" m.orderInfo.price = "3.99" @@ -71,7 +71,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow 2. Set the **ContentNode** to the ChannelStore node's **requestPartnerOrder** field. - ``` + ```brightscript m.channelStore.requestPartnerOrder = m.orderInfo m.channelStore.command = "requestPartnerOrder" ``` @@ -80,7 +80,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow If the **status** field is set to **failure**, display an error message. - ``` + ```brightscript m.store.observeField("requestPartnerOrderStatus", "requestPartnerOrderStatusChanged") 'callback function @@ -104,7 +104,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow * **contentKey**. The publisher's SKU (or other unique identifier) for the product. * **code**. The uniqueID specified for the product in the **In-Channel Products** page. Use the **addField()** method to add the **code** field to the **ContentNode**. - ``` + ```brightscript m.confirmOrderInfo = CreateObject("roSGNode", "ContentNode") m.confirmOrderInfo.orderId = m.store.requestPartnerOrderStatus.orderID m.confirmOrderInfo.title = "TV Show 1" @@ -123,7 +123,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow 5. Set the **ContentNode** to the ChannelStore node's **confirmPartnerOrder** field. This will prompt the user to complete the transaction. - ``` + ```brightscript 'Set the ContentNode to the ChannelStore node m.store.confirmPartnerOrder = m.confirmOrderInfo @@ -135,7 +135,7 @@ To send the **requestPartnerOrder** and **confirmPartnerOrder** commands, follow If the **status** field is set to **failure**, display an error message explaining why the transaction could not be completed. - ``` + ```brightscript m.store.observeField("confirmPartnerOrderStatus", "confirmPartnerOrderStatusChanged") 'callback function diff --git a/docs/DEVELOPER/roku-pay/quickstart/add-ons-integration.md b/docs/DEVELOPER/roku-pay/quickstart/add-ons-integration.md index 9b319bd2..888aeb34 100644 --- a/docs/DEVELOPER/roku-pay/quickstart/add-ons-integration.md +++ b/docs/DEVELOPER/roku-pay/quickstart/add-ons-integration.md @@ -157,7 +157,7 @@ To update your app with the new Channel Store APIs, follow these steps: 1. Initialize the ChannelStore API generic request framework. The following code monitors the **channelStore.requestStatus** field and fires the **onRequestStatus()** callback function when changes to the **requestStatus** field occur. The **onRequestStatus()** function determines which command was sent and sends the results to the dedicated parser for the command. - ``` + ```brightscript function init() m.store = m.parent.FindNode("channelStore") m.store.observeField("requestStatus", "onRequestStatus") @@ -203,7 +203,7 @@ To update your app with the new Channel Store APIs, follow these steps: 2. Send the **GetCatalog** command to get the list of purchase options. In all the requests within the add-on API workflow, the version field must be set to **2**. - ``` + ```brightscript sub GetCatalog() request = {} request.command = "GetCatalog" @@ -216,7 +216,7 @@ To update your app with the new Channel Store APIs, follow these steps: 3. From the **OnGetCatalog()** callback function, store the **purchaseOptionsMap** and **productsMap** collections returned by the **GetCatalog** command. - ``` + ```brightscript sub onGetCatalog(requestResult as object) print "requestResult.status", requestResult.status print "requestResult.statusMessage", requestResult.statusMessage @@ -234,7 +234,7 @@ To update your app with the new Channel Store APIs, follow these steps: 4. Use the **QueryPurchaseOptions** command to offer the customer base and bundle purchase options in the UI. The following example creates a map of base and bundle purchase options: - ``` + ```brightscript sub queryBasePurchaseOptions() query = [ {"billingType":"Subscription","base":true}, @@ -271,7 +271,7 @@ To update your app with the new Channel Store APIs, follow these steps: 5. Offer the customer add-on purchase options in the UI. The following example creates a map of add-on purchase options that are available for the specified SKU of a base purchase option: - ``` + ```brightscript sub queryAddonPurchaseOptions() query = [ {"referenceSku":m.base,"addon":true} @@ -292,7 +292,7 @@ To update your app with the new Channel Store APIs, follow these steps: 6. Send the **DoOrder** command to purchase the base prerequisite product and any add-ons, and then check the order status. - ``` + ```brightscript sub DoOrder() request = {} request.command = "DoOrder" @@ -363,7 +363,7 @@ To update your app with the new Channel Store APIs, follow these steps: 7. Send the **GetAllPurchases** command to query the customer's purchases, and then check the order status. The response includes three arrays: **purchases**, **products**, and **entitlements**. If a cross-partner bundle subscription was purchased, its information is in the **entitlements** list. - ``` + ```brightscript sub GetAllPurchases() request = {} request.command = "GetPurchases" diff --git a/docs/DEVELOPER/roku-pay/subscription-recovery/subscription-on-hold.md b/docs/DEVELOPER/roku-pay/subscription-recovery/subscription-on-hold.md index f03e25e1..4c7cda21 100644 --- a/docs/DEVELOPER/roku-pay/subscription-recovery/subscription-on-hold.md +++ b/docs/DEVELOPER/roku-pay/subscription-recovery/subscription-on-hold.md @@ -283,7 +283,7 @@ This reference summarizes the **request** and **requestStatus** fields used by t The following code demonstrates how to use the ChannelStore node (SDK 2) to display the Roku Pay subscription renewal dialog and configure it so it blocks access to content: -``` +```brightscript function DoRecovery() request = {} request.command = "DoRecovery" @@ -315,7 +315,7 @@ end function The following code demonstrates how to use the roChannelStore node (SDK 1) to display the Roku Pay subscription renewal dialog and block access to content. A **DoRequest()** method, which takes the **request** object, is required for sending the DoRecovery request. -``` +```brightscript function DoRecovery() as void request = {} request.command = "DoRecovery" diff --git a/docs/REFERENCES/brightscript/components/roappinfo.md b/docs/REFERENCES/brightscript/components/roappinfo.md index 2d336efe..9ebc9162 100644 --- a/docs/REFERENCES/brightscript/components/roappinfo.md +++ b/docs/REFERENCES/brightscript/components/roappinfo.md @@ -19,7 +19,7 @@ This object is created with no parameters. **Implementation** -``` +```brightscript brush: vb; gutter: false; theme: Confluence appInfo = CreateObject("roAppInfo") @@ -33,7 +33,7 @@ print "MajVers: " ; appInfo.GetValue("major_version") **Output** -``` +```brightscript brush: plain; gutter: false; theme: Confluence ' ID: 41089_bd3a ' IsDev: false diff --git a/docs/REFERENCES/brightscript/components/roassociativearray.md b/docs/REFERENCES/brightscript/components/roassociativearray.md index 3b56d223..61b66c1c 100644 --- a/docs/REFERENCES/brightscript/components/roassociativearray.md +++ b/docs/REFERENCES/brightscript/components/roassociativearray.md @@ -14,7 +14,7 @@ next: An associative array (also known as a map, dictionary or hash table) allows objects to be associated with string keys. Associative arrays are built into the language. They can be accessed implicitly by using the dot or bracket operators, or by calling functions from the [ifAssociativeArray](doc:ifassociativearray) interface. For example, the last three lines in this example are equivalent: -``` +```brightscript aa = { one : 1, two : 2, three : 3 } x = aa["two"] x = aa.two @@ -23,7 +23,7 @@ x = aa.Lookup("two") This object is created with no parameters: -``` +```brightscript CreateObject("roAssociativeArray") ``` @@ -33,7 +33,7 @@ Starting from [Roku OS 8](doc:release-notes#roku-os-8), the quoted keys in Assoc **Example** -``` +```brightscript ' Creation of associative arrays aa1 = CreateObject("roAssociativeArray") ' Explicitly aa2 = {} ' Implicitly diff --git a/docs/REFERENCES/brightscript/components/roaudiometadata.md b/docs/REFERENCES/brightscript/components/roaudiometadata.md index d7452534..aa107520 100644 --- a/docs/REFERENCES/brightscript/components/roaudiometadata.md +++ b/docs/REFERENCES/brightscript/components/roaudiometadata.md @@ -24,7 +24,7 @@ This object is created without any arguments: **Example** -``` +```brightscript ' printAA() is from generalUtils.brs in our sample apps ' and used to print an associative Array diff --git a/docs/REFERENCES/brightscript/components/roaudioplayer.md b/docs/REFERENCES/brightscript/components/roaudioplayer.md index 7613d5a7..ab347da1 100644 --- a/docs/REFERENCES/brightscript/components/roaudioplayer.md +++ b/docs/REFERENCES/brightscript/components/roaudioplayer.md @@ -22,7 +22,7 @@ This object is created with no parameters: **Example** -``` +```brightscript sub Main() audioPlayer = CreateObject("roAudioPlayer") port = CreateObject("roMessagePort") diff --git a/docs/REFERENCES/brightscript/components/roaudioresource.md b/docs/REFERENCES/brightscript/components/roaudioresource.md index a249a25f..60c64f1b 100644 --- a/docs/REFERENCES/brightscript/components/roaudioresource.md +++ b/docs/REFERENCES/brightscript/components/roaudioresource.md @@ -22,7 +22,7 @@ This object is created with a filename parameter that is a path to the sound res The filename must be the name of a local file and cannot be a URL. To use a URL, you may download the file to the application's "tmp:" file system using [roUrlTransfer](doc:rourltransfer) and pass a filename of the form "tmp:/file.wav" to CreateObject. -``` +```brightscript sound = CreateObject("roAudioResource", "pkg:/sounds/beep1.wav") sound.Trigger(75) ``` @@ -36,7 +36,7 @@ An object can also be created using the name of a system sound effect: Note that system sound effects are played at the volume selected in the user's settings, or not played at all if the user has turned sound effects off, regardless of the volume value passed to Trigger. -``` +```brightscript sound = CreateObject("roAudioResource", "select") sound.Trigger(50) ``` @@ -44,7 +44,7 @@ sound.Trigger(50) Mult iple sounds can be mixed and played at the same time: -``` +```brightscript sound1 = CreateObject("roAudioResource", "pkg:/sounds/beep1.wav") sound2 = CreateObject("roAudioResource", "select") sound1.Trigger(50, 0) diff --git a/docs/REFERENCES/brightscript/components/robitmap.md b/docs/REFERENCES/brightscript/components/robitmap.md index 465945c9..0bfbbf56 100644 --- a/docs/REFERENCES/brightscript/components/robitmap.md +++ b/docs/REFERENCES/brightscript/components/robitmap.md @@ -34,7 +34,7 @@ An roBitmap can also load its image data from a file: **Example** -``` +```brightscript ' Draw three bitmaps as fast as we can ' Screen=CreateObject("roScreen") @@ -52,7 +52,7 @@ end while **Example: Double buffering with roBitmap** -``` +```brightscript screen1=CreateObject("roScreen") off=CreateObject("roBitmap", {width:1280, height:720, AlphaEnable:false}) off.Clear(white) diff --git a/docs/REFERENCES/brightscript/components/robytearray.md b/docs/REFERENCES/brightscript/components/robytearray.md index 858f301c..5701b128 100644 --- a/docs/REFERENCES/brightscript/components/robytearray.md +++ b/docs/REFERENCES/brightscript/components/robytearray.md @@ -19,7 +19,7 @@ roByteArray supports the [ifArray](doc:ifarray) interface, and so can be accesse **Example** -``` +```brightscript ba=CreateObject("roByteArray") ba.FromAsciiString("leasure.") if ba.ToBase64String()<>"bGVhc3VyZS4=" then stop diff --git a/docs/REFERENCES/brightscript/components/rocompositor.md b/docs/REFERENCES/brightscript/components/rocompositor.md index 71143b27..42c1696a 100644 --- a/docs/REFERENCES/brightscript/components/rocompositor.md +++ b/docs/REFERENCES/brightscript/components/rocompositor.md @@ -18,7 +18,7 @@ This object can create and manage roSprites in a z-ordered list. The sprites can **Example: Scrolling a bitmap** -``` +```brightscript Library "v30/bslCore.brs" function main() diff --git a/docs/REFERENCES/brightscript/components/rodatagramsocket.md b/docs/REFERENCES/brightscript/components/rodatagramsocket.md index 6a85b912..699dc194 100644 --- a/docs/REFERENCES/brightscript/components/rodatagramsocket.md +++ b/docs/REFERENCES/brightscript/components/rodatagramsocket.md @@ -20,7 +20,7 @@ This object is created without any arguments: **Example** -``` +```brightscript ' UDP 2-way peer-to-peer asynchronous comm on port 54321 ' periodically sends out a message to a specific address and port ' prints any message it receives diff --git a/docs/REFERENCES/brightscript/components/rodatetime.md b/docs/REFERENCES/brightscript/components/rodatetime.md index a6a2be22..a87633f5 100644 --- a/docs/REFERENCES/brightscript/components/rodatetime.md +++ b/docs/REFERENCES/brightscript/components/rodatetime.md @@ -24,7 +24,7 @@ The date/time of the object is set to the current system time when the object is **Example** -``` +```brightscript date = CreateObject("roDateTime") print "The date is now "; date.AsDateString("long-date") ``` diff --git a/docs/REFERENCES/brightscript/components/rodevicecrypto.md b/docs/REFERENCES/brightscript/components/rodevicecrypto.md index da64efd0..c53897e9 100644 --- a/docs/REFERENCES/brightscript/components/rodevicecrypto.md +++ b/docs/REFERENCES/brightscript/components/rodevicecrypto.md @@ -25,7 +25,7 @@ roDeviceCrypto has two methods: `Encrypt()` and `Decrypt()`. Both methods take a Both methods return a `roByteArray` so that you can encrypt plaintext on a Roku device and then decode it, as demonstrated in the following example: -``` +```brightscript ' store plaintext to be encrypted in an roByteArray ba = CreateObject("roByteArray") ba.FromAsciiString("plain text1") diff --git a/docs/REFERENCES/brightscript/components/rodeviceinfo.md b/docs/REFERENCES/brightscript/components/rodeviceinfo.md index cbb18c44..1d7b8981 100644 --- a/docs/REFERENCES/brightscript/components/rodeviceinfo.md +++ b/docs/REFERENCES/brightscript/components/rodeviceinfo.md @@ -21,7 +21,7 @@ This object is created with no parameters: **Example** -``` +```brightscript di = CreateObject("roDeviceInfo") print di.GetModel() print di.GetVersion() @@ -32,7 +32,7 @@ print di.GetChannelClientId() The output from the above code would like the following: -``` +```brightscript N1000 999.99E99999X 20E825000036 diff --git a/docs/REFERENCES/brightscript/components/roevpdigest.md b/docs/REFERENCES/brightscript/components/roevpdigest.md index 7210f734..75e965f7 100644 --- a/docs/REFERENCES/brightscript/components/roevpdigest.md +++ b/docs/REFERENCES/brightscript/components/roevpdigest.md @@ -29,7 +29,7 @@ roEVPDigest processes an arbitrary amount of data and generates a hash of the da **Example: SHA1 Message Digest with roEVPDigest** -``` +```brightscript ba = CreateObject("roByteArray") ' ...populate bytearray... digest = CreateObject("roEVPDigest") @@ -40,7 +40,7 @@ print result **Example: MD5 Message Digest with roEVPDigest** -``` +```brightscript ba1 = CreateOjbect("roByteArray") ' ...populate ba1... ba2 = CreateObject("roByteArray") diff --git a/docs/REFERENCES/brightscript/components/rofont.md b/docs/REFERENCES/brightscript/components/rofont.md index 3d33a62b..1f9e749b 100644 --- a/docs/REFERENCES/brightscript/components/rofont.md +++ b/docs/REFERENCES/brightscript/components/rofont.md @@ -16,7 +16,7 @@ It is used in conjunction with [roFontRegistry](doc:rofontregistry) to create an **Example** -``` +```brightscript screen = CreateObject("roScreen") white = &hFFFFFFFF blue = &h0000FFFF diff --git a/docs/REFERENCES/brightscript/components/rofontregistry.md b/docs/REFERENCES/brightscript/components/rofontregistry.md index 48a41a3a..44925da1 100644 --- a/docs/REFERENCES/brightscript/components/rofontregistry.md +++ b/docs/REFERENCES/brightscript/components/rofontregistry.md @@ -20,7 +20,7 @@ This object is created with no parameters: **Example** -``` +```brightscript reg = CreateObject("roFontRegistry") font = reg.GetDefaultFont(30, false, false) screen = CreateObject("roScreen") @@ -29,7 +29,7 @@ screen.DrawText("hello world", 100, 100, &hFFFFFFFF, font) **Example using a font file** -``` +```brightscript reg.Register("pkg:/fonts/myfont.ttf") font = reg.GetFont("MyFont", 30, false, false) screen = CreateObject("roScreen") diff --git a/docs/REFERENCES/brightscript/components/rohmac.md b/docs/REFERENCES/brightscript/components/rohmac.md index 96128b62..f85413b8 100644 --- a/docs/REFERENCES/brightscript/components/rohmac.md +++ b/docs/REFERENCES/brightscript/components/rohmac.md @@ -22,7 +22,7 @@ The supported digest algorithms are the same as those supported by [roEVPDigest] **Example** -``` +```brightscript hmac = CreateObject("roHMAC") signature_key = CreateObject("roByteArray") signature_key.fromAsciiString(getKey()) diff --git a/docs/REFERENCES/brightscript/components/roimagemetadata.md b/docs/REFERENCES/brightscript/components/roimagemetadata.md index 88326f82..72782131 100644 --- a/docs/REFERENCES/brightscript/components/roimagemetadata.md +++ b/docs/REFERENCES/brightscript/components/roimagemetadata.md @@ -56,7 +56,7 @@ For reference here are all the fields from an image taken from my camera (with t The format is IFD#, Tag#[Tag Name], Data Format, Value. The Value is a string representation of data. -``` +```brightscript 0, 272[ Model], ASCII,Canon PowerShot SD700 IS 0, 274[ Orientation], Short,top - left 0, 283[ YResolution], Rational,180.00 @@ -114,7 +114,7 @@ The format is IFD#, Tag#[Tag Name], Data Format, Value. The Value is a string re **Example** -``` +```brightscript ' printAA() is from generalUtils.brs in our sample apps ' and used to print an associative Array sub SaveExifImage(filename as String) diff --git a/docs/REFERENCES/brightscript/components/roinput.md b/docs/REFERENCES/brightscript/components/roinput.md index 66b5d3f4..551eaaf2 100644 --- a/docs/REFERENCES/brightscript/components/roinput.md +++ b/docs/REFERENCES/brightscript/components/roinput.md @@ -43,7 +43,7 @@ The following will be printed: **roInput Example** -``` +```brightscript msgPort = CreateObject("roMessagePort") input = CreateObject("roInput") diff --git a/docs/REFERENCES/brightscript/components/roint.md b/docs/REFERENCES/brightscript/components/roint.md index e17426d1..c001bfc1 100644 --- a/docs/REFERENCES/brightscript/components/roint.md +++ b/docs/REFERENCES/brightscript/components/roint.md @@ -32,7 +32,7 @@ This is useful in the following situations: **Example** -``` +```brightscript BrightScript> o=CreateObject("roInt") BrightScript> o.SetInt(555) BrightScript> print o diff --git a/docs/REFERENCES/brightscript/components/rolist.md b/docs/REFERENCES/brightscript/components/rolist.md index 8e7d1ff4..780210a7 100644 --- a/docs/REFERENCES/brightscript/components/rolist.md +++ b/docs/REFERENCES/brightscript/components/rolist.md @@ -18,7 +18,7 @@ The list object implements the interfaces: ifList, ifArray, ifEnum and therefore Implementation: -``` +```brightscript list = CreateObject("roList") list.AddTail("a") list.AddTail("b") @@ -37,7 +37,7 @@ print list[2] Output: -``` +```brightscript a b c diff --git a/docs/REFERENCES/brightscript/components/rolocalization.md b/docs/REFERENCES/brightscript/components/rolocalization.md index e69a8457..b2080acc 100644 --- a/docs/REFERENCES/brightscript/components/rolocalization.md +++ b/docs/REFERENCES/brightscript/components/rolocalization.md @@ -22,7 +22,7 @@ It is created with no parameters: **Example** -``` +```brightscript loc = CreateObject("roLocalization") image = loc.GetLocalizedAsset("images", "splash.png") ``` diff --git a/docs/REFERENCES/brightscript/components/ropath.md b/docs/REFERENCES/brightscript/components/ropath.md index 35724930..60ff97db 100644 --- a/docs/REFERENCES/brightscript/components/ropath.md +++ b/docs/REFERENCES/brightscript/components/ropath.md @@ -24,7 +24,7 @@ This object is created with a string that represents the initial path: **Example** -``` +```brightscript path = CreateObject("roPath", filename) parts = path.Split() if parts.phy = "tmp:" then print "this is a temp file" diff --git a/docs/REFERENCES/brightscript/components/roregistrysection.md b/docs/REFERENCES/brightscript/components/roregistrysection.md index 35229da0..7924ea60 100644 --- a/docs/REFERENCES/brightscript/components/roregistrysection.md +++ b/docs/REFERENCES/brightscript/components/roregistrysection.md @@ -22,7 +22,7 @@ This object must be supplied with a "section" name on creation. If no such secti **Example: Get and set some user authentication in the registry** -``` +```brightscript function GetAuthData() as Dynamic sec = CreateObject("roRegistrySection", "Authentication") if sec.Exists("UserRegistrationToken") diff --git a/docs/REFERENCES/brightscript/components/roremoteinfo.md b/docs/REFERENCES/brightscript/components/roremoteinfo.md index e1d4ffdb..a8d8787e 100644 --- a/docs/REFERENCES/brightscript/components/roremoteinfo.md +++ b/docs/REFERENCES/brightscript/components/roremoteinfo.md @@ -20,7 +20,7 @@ This object is created with no parameters: **Example** -``` +```brightscript remoteInfo = CreateObject("roRemoteInfo") print remoteInfo.GetModel(0) print remoteInfo.IsAwake(0) @@ -31,7 +31,7 @@ print remoteInfo.hasFeature("voicecapture", 0) The output from the above code could be as follows: -``` +```brightscript 538 false true diff --git a/docs/REFERENCES/brightscript/components/rorsa.md b/docs/REFERENCES/brightscript/components/rorsa.md index 00182219..6c6838b1 100644 --- a/docs/REFERENCES/brightscript/components/rorsa.md +++ b/docs/REFERENCES/brightscript/components/rorsa.md @@ -21,7 +21,7 @@ Typically, you would use the roEVPDigest component to create a message digest, t **Example: RSA signing using SHA1** -``` +```brightscript ba = CreateObject("roByteArray") ' ...populate bytearray... @@ -41,7 +41,7 @@ signature = rsa.Sign(hashBA) **Example: RSA verification using SHA1** -``` +```brightscript rsa = CreateObject("roRSA") rsa.SetPublicKey("tmp:/publicKey.txt") rsa.SetDigestAlgorithm("sha1") diff --git a/docs/REFERENCES/brightscript/components/roscreen.md b/docs/REFERENCES/brightscript/components/roscreen.md index eb6fb135..194815dd 100644 --- a/docs/REFERENCES/brightscript/components/roscreen.md +++ b/docs/REFERENCES/brightscript/components/roscreen.md @@ -67,7 +67,7 @@ If four parameters are passed, the last two specify the screen's resolution. The **Example: Display an image** -``` +```brightscript Screen=CreateObject("roScreen") dfDrawImage(screen, "myphoto.jpg",0,0) Screen.Finish() @@ -75,7 +75,7 @@ Screen.Finish() **Example: Alpha blending** -``` +```brightscript white=&hFFFFFFFF screen0=CreateObject("roScreen") screen0.SetAlphaEnable(true) diff --git a/docs/REFERENCES/brightscript/components/rosgscreen.md b/docs/REFERENCES/brightscript/components/rosgscreen.md index ea67feda..9d684f4d 100644 --- a/docs/REFERENCES/brightscript/components/rosgscreen.md +++ b/docs/REFERENCES/brightscript/components/rosgscreen.md @@ -25,7 +25,7 @@ to `CreateScene().` **roSGScreen typical usage example** -``` +```brightscript screen = CreateObject("roSGScreen") scene = screen.CreateScene("Scene") screen.show() diff --git a/docs/REFERENCES/brightscript/components/rostreamsocket.md b/docs/REFERENCES/brightscript/components/rostreamsocket.md index b6ff98fb..2155e7e7 100644 --- a/docs/REFERENCES/brightscript/components/rostreamsocket.md +++ b/docs/REFERENCES/brightscript/components/rostreamsocket.md @@ -22,7 +22,7 @@ This object is created without any arguments: **Example: Open TCP Connection to Server** -``` +```brightscript sendAddress = CreateObject("roSocketAddress") sendAddress.SetAddress("www.google.com:80") socket = CreateObject("roStreamSocket") @@ -34,7 +34,7 @@ end if **Example: Echo Server** -``` +```brightscript function main() messagePort = CreateObject("roMessagePort") connections = {} diff --git a/docs/REFERENCES/brightscript/components/rotexturemanager.md b/docs/REFERENCES/brightscript/components/rotexturemanager.md index f9732933..9587b821 100644 --- a/docs/REFERENCES/brightscript/components/rotexturemanager.md +++ b/docs/REFERENCES/brightscript/components/rotexturemanager.md @@ -18,7 +18,7 @@ The Texture Manager provides a set of API's for managing an roBitmap cache. **Example: Requesting an roBitmap from the roTextureManager** -``` +```brightscript sub Main() mgr = CreateObject("roTextureManager") msgport = CreateObject("roMessagePort") diff --git a/docs/REFERENCES/brightscript/components/rotexturerequest.md b/docs/REFERENCES/brightscript/components/rotexturerequest.md index f8e9129f..8b8accfb 100644 --- a/docs/REFERENCES/brightscript/components/rotexturerequest.md +++ b/docs/REFERENCES/brightscript/components/rotexturerequest.md @@ -22,7 +22,7 @@ An roTextureRequest object is created using the CreateObject() method and passin **Example: Requesting a URL from the roTextureManager** -``` +```brightscript sub Main() mgr = CreateObject("roTextureManager") msgport = CreateObject("roMessagePort") @@ -51,7 +51,7 @@ end sub **Example: Requesting a scaled image from the roTextureManager** -``` +```brightscript sub Main() mgr = CreateObject("roTextureManager") msgport = CreateObject("roMessagePort") @@ -67,7 +67,7 @@ end sub **Example: Making an HTTPS request from the roTextureManager** -``` +```brightscript sub Main() mgr = CreateObject("roTextureManager") msgport = CreateObject("roMessagePort") diff --git a/docs/REFERENCES/brightscript/components/rotimespan.md b/docs/REFERENCES/brightscript/components/rotimespan.md index 20271413..1e277189 100644 --- a/docs/REFERENCES/brightscript/components/rotimespan.md +++ b/docs/REFERENCES/brightscript/components/rotimespan.md @@ -18,7 +18,7 @@ The Timespan object provides an interface to a simple timer for tracking the dur **Example: Timing an activity** -``` +```brightscript ' ****************************************************** ' Compute the number of millisecs to perform a task ' ****************************************************** diff --git a/docs/REFERENCES/brightscript/components/rourltransfer.md b/docs/REFERENCES/brightscript/components/rourltransfer.md index 0a850693..ffef074e 100644 --- a/docs/REFERENCES/brightscript/components/rourltransfer.md +++ b/docs/REFERENCES/brightscript/components/rourltransfer.md @@ -32,7 +32,7 @@ The web server can authenticate that the requested connection is from a Roku Str In order for your web server to perform the steps above to authenticate your Roku Streaming Player, your application needs to call the following functions before performing any https requests: -``` +```brightscript object.SetCertificatesFile("common:/certs/ca-bundle.crt") object.AddHeader("X-Roku-Reserved-Dev-Id", "") object.InitClientCertificates() diff --git a/docs/REFERENCES/brightscript/components/roxmlelement.md b/docs/REFERENCES/brightscript/components/roxmlelement.md index b8c8e316..db5861a5 100644 --- a/docs/REFERENCES/brightscript/components/roxmlelement.md +++ b/docs/REFERENCES/brightscript/components/roxmlelement.md @@ -21,7 +21,7 @@ For instance, Would parse such that: -``` +```brightscript Name = "tag1" Attributes = invalid Body = roString with "this is some text" @@ -35,7 +35,7 @@ Body = roString with "this is some text" Would parse such that: -``` +```brightscript Name = "emptytag" Attributes = roAssociativeArray, with one entry { caveman: "barney" } Body = invalid @@ -51,7 +51,7 @@ GenXML() takes one parameter (boolean) that indicates whether the generated ` > Use the following syntax to define message handlers: > -> ``` +> ```brightscript > sub MyMessagehandler(data, msgInfo) > ``` > diff --git a/docs/REFERENCES/brightscript/interfaces/ifsgnodeboundingrect.md b/docs/REFERENCES/brightscript/interfaces/ifsgnodeboundingrect.md index 84482e3d..8b8569ac 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifsgnodeboundingrect.md +++ b/docs/REFERENCES/brightscript/interfaces/ifsgnodeboundingrect.md @@ -247,7 +247,7 @@ We start with the following code example: The scene has the following parenting structure: -``` +```xml Scene RectangleGroup Rectangle (Green) diff --git a/docs/REFERENCES/brightscript/interfaces/ifsgnodechildren.md b/docs/REFERENCES/brightscript/interfaces/ifsgnodechildren.md index 6c4f4484..4edefa56 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifsgnodechildren.md +++ b/docs/REFERENCES/brightscript/interfaces/ifsgnodechildren.md @@ -323,7 +323,7 @@ Takes the key-value pairs in an roAssociativeArray and maps the values to the re The following example demonstrates how to use this method: -``` +```brightscript aa = {"a":"1", "b":"2", "c":"3", "d":"4"} cn = createObject("roSGNode", "contentNode") cn.addfield("a","string",false) diff --git a/docs/REFERENCES/brightscript/interfaces/ifsgnodedict.md b/docs/REFERENCES/brightscript/interfaces/ifsgnodedict.md index 73b6b081..bb6c383d 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifsgnodedict.md +++ b/docs/REFERENCES/brightscript/interfaces/ifsgnodedict.md @@ -104,7 +104,7 @@ A flag indicating whether the nodes refer to the same SceneGraph node object. The following example should print "same": -``` +```brightscript n = createObject("roSGNode", "Node") c = n.createChild("Node") if c.isSameNode(n.getChild(0)) then print "same" @@ -159,7 +159,7 @@ To call the function, use the `callFunc` field with the required method signatur **Function definition** -``` +```brightscript function addSomeValue(params as Object) as Object passedDataLabel = m.top.findNode("passedDataLabel") passedDataLabel.text = params.passedString @@ -173,7 +173,7 @@ end function **callFunc with parameters** -``` +```brightscript params = {passedString:"", passedInt:12} result = node.callFunc("addSomeValue", params) ``` diff --git a/docs/REFERENCES/brightscript/interfaces/ifsgnodefield.md b/docs/REFERENCES/brightscript/interfaces/ifsgnodefield.md index bb309479..1c2bdb6e 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifsgnodefield.md +++ b/docs/REFERENCES/brightscript/interfaces/ifsgnodefield.md @@ -212,7 +212,7 @@ Calls a function when a field of the subject node changes. The function called m Optionally, this form can pass an [roSGNodeEvent](doc:rosgnode) message to the callback function by specifying the message object as an argument to the callback function. The following sample demonstrates how to do this: -``` +```brightscript sub callback_function(message as Object) ... end sub @@ -407,7 +407,7 @@ The number of nested objects within an object that were copied, rather than move #### Example -``` +```brightscript ' Can be on Task thread or render thread n = CreateObject("roSGNode", "Node") n.AddField("aa_field", "assocarray", true) @@ -419,7 +419,7 @@ The number of nested objects within an object that were copied, rather than move This code will output the following on the port 8085 console: -``` +```text = { key: "value" @@ -453,7 +453,7 @@ The associative array that was moved from the source field. #### Example -``` +```brightscript n = CreateObject("roSGNode", "ContentNode") n.AddField("aa_field", "assocarray", true) n.aa_field = {key: "value"}' or use moveIntoField() @@ -476,7 +476,7 @@ print my_aa ' contents of aa_field > > The following example is the same as the above, except a nested object contains an external reference. As a result, the nested object is **copied** to the destination rather than being moved. > -> ``` +> ```brightscript > sub_array = [1, 2, 3] > aa = {foo: "hello", bar: sub_array} > ' At this point, there is an external reference into aa @@ -546,7 +546,7 @@ This function returns true a reference to the field’s value. This function ret #### Example -``` +```brightscript ' on render thread: n = CreateObject("roSGNode", "Node") n.AddField("aa_field", "assocarray", true) @@ -560,7 +560,7 @@ This function returns true a reference to the field’s value. This function ret This code will output the following on the port 8085 console: -``` +```text = { key: "value" @@ -584,7 +584,7 @@ A runtime debugging method for helping minimize Rendezvous spread. This method The following example demonstrates the information returned by this method: -``` +```brightscript { node: { type: "XXComponent", id: "XXID", address: 0x123XXX, @@ -619,7 +619,7 @@ Starting in [Roku OS 9.3](doc:release-notes#roku-os-93), if the app UI displays To fire signal beacons within your application, call the `signalBeacon()` function on any node as demonstrated in the following examples: -``` +```brightscript myScene.signalBeacon("AppLaunchComplete") myEPGComponent.signalBeacon("EPGLaunchInitiate") m.top.signalBeacon("EPGLaunchComplete") diff --git a/docs/REFERENCES/brightscript/interfaces/ifsgscreen.md b/docs/REFERENCES/brightscript/interfaces/ifsgscreen.md index d3d55f5f..9c8dad82 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifsgscreen.md +++ b/docs/REFERENCES/brightscript/interfaces/ifsgscreen.md @@ -55,7 +55,7 @@ A global reference object. #### Example: Starting Scene Graph Applications -``` +```brightscript sub showChannelSGScreen() print "in showChannelSGScreen" screen = CreateObject("roSGScreen") diff --git a/docs/REFERENCES/brightscript/interfaces/ifstring.md b/docs/REFERENCES/brightscript/interfaces/ifstring.md index bb5f54fe..e4dc2ab4 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifstring.md +++ b/docs/REFERENCES/brightscript/interfaces/ifstring.md @@ -61,7 +61,7 @@ A flag indicating whether the string is empty (true), or contains characters (fa #### Example -``` +```brightscript a = "myString" b = "" diff --git a/docs/REFERENCES/brightscript/interfaces/ifstringops.md b/docs/REFERENCES/brightscript/interfaces/ifstringops.md index 80c55841..6a12e8e3 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifstringops.md +++ b/docs/REFERENCES/brightscript/interfaces/ifstringops.md @@ -174,7 +174,7 @@ A copy of the string with all the instances #### Example -``` +```brightscript print "a-b-c".Replace("-", "/") ' result is "a/b/c" @@ -261,35 +261,35 @@ An array of the split token strings (not including the delimiter). #### Examples -``` +```brightscript a = "".Split("") 'creates the array equivalent to a = [] ``` -``` +```brightscript a = "123".Split("") 'creates the array equivalent to a = ["1", "2", "3"] ``` -``` +```brightscript a = "123".Split("/") 'creates the array equivalent to a = ["123"] ``` -``` +```brightscript a = "/123/".Split("/") 'creates the array equivalent to a = ["", "123", ""] ``` -``` +```brightscript a = "one, two, three".Split(", ") 'creates the array equivalent to @@ -361,7 +361,7 @@ The URL-encoded version of the specified string. #### Example -``` +```brightscript s = "@&=+/#!*" t = s.Escape() print """" + t + """" @@ -392,7 +392,7 @@ The URL-decoded string. #### Example -``` +```brightscript t = "%3B%3F%3A%24%2C%28%29" s = t.Unescape() print """" + s + """" @@ -411,7 +411,7 @@ The provided string encoded as a Uniform Resource Identifier (URI). #### Example -``` +```brightscript s = "http://roku.com/my test.asp?first=jane&last=doe" t = s.EncodeUri() print """" + t + """" @@ -430,7 +430,7 @@ An unencoded version of the provided encoded Uniform Resource Identifier (URI). #### Example -``` +```brightscript t = "http://roku.com/my%20test.asp?first=jane&last=doe" s = t.DecodeUri() print """" + s + """" @@ -449,7 +449,7 @@ The provided string encoded as a Uniform Resource Identifier (URI). #### Example -``` +```brightscript s = "http://roku.com/my test.asp?first=jane&last=doe" t = s.EncodeUriComponent() print """" + t + """" @@ -468,7 +468,7 @@ An unencoded version of the provided encoded Uniform Resource Identifier (URI). #### Example -``` +```brightscript t = "http%3A%2F%2Froku.com%2Fmy%20test.asp%3Ffirst%3Djane%26last%3Ddoe" s = t.DecodeUriComponent() print """" + s + """" @@ -485,7 +485,7 @@ A flag indicating whether a matching substring was found. #### Example -``` +```brightscript s = "Roku Rocks" print s.StartsWith("Roku") ' => true print s.StartsWith("roku") ' => false @@ -501,7 +501,7 @@ A flag indicating whether a matching substring was found. #### Example -``` +```brightscript s = "Roku Rocks" print s.StartsWith("Rocks", 5) ' => true print s.StartsWith("Roku", 5) ' => false @@ -517,7 +517,7 @@ A flag indicating whether a matching substring was found. #### Example -``` +```brightscript s = "Roku Rocks" print s.EndsWith("Rocks") ' => true print s.EndsWith("roku") ' => false @@ -533,7 +533,7 @@ A flag indicating whether a matching substring was found. #### Example -``` +```brightscript s = "Roku Rocks" print s.EndsWith("Roku", 4) ' => true ``` @@ -560,7 +560,7 @@ Format support (the `ifStringOps` interface) is implemented by the following typ ##### Mixed -``` +```brightscript '* example of mixed parameters s = "Roku" + " " + "rocks!" print "The length of '%s' is %d.".Format(s, s.Len()) @@ -569,7 +569,7 @@ print "The length of '%s' is %d.".Format(s, s.Len()) ##### Integer (Decimal) -``` +```brightscript '* example of decimal integers print "%d * %d = %d".Format(-13, 21, -13 * 21) '=> "-13 * 21 = -273" @@ -581,7 +581,7 @@ print "%04d-%02d-%02d".Format(17, 3, 99) ##### Integer (Hexadecimal) -``` +```brightscript '* example of hexadecimal integer with left-side 0-padding print "%07x".Format(&hFACE1) '=> "00face1" @@ -604,7 +604,7 @@ print "%0*x".Format(8, &hFACE1) ##### Floating Point -``` +```brightscript '* example of floating point formatting pi = 3.1415 : r = 2.5 print "r=%4.2f => c=%4.2f".Format(r, 2 * pi * r) @@ -613,7 +613,7 @@ print "r=%4.2f => c=%4.2f".Format(r, 2 * pi * r) ##### String -``` +```brightscript '* example plain string formatting print "%s, %s".Format("Fields", "Sally") '=> "Fields, Sally" @@ -626,7 +626,7 @@ print "[%-3s:%3s]".Format("A", "B") ##### Character -``` +```brightscript '* example of character formatting print "(%c%c%c)".Format(&h7B, 64, &h7D) '=> "({@})" @@ -652,7 +652,7 @@ The resulting string after all eligible placeholder replacements have been made. ### Examples -``` +```brightscript title = "Princess" name = "Leia" salutation = "Hello %1 %2!".Arg(title, name) @@ -661,14 +661,14 @@ print salutation ' Hello Princess Leia! ``` -``` +```brightscript s = "%2 and %4 (or %4 and %2)".Arg("first", "second") print s ' => ' first and second (or second and first) ``` -``` +```brightscript first_name = "Jack" last_name = "Reacher" listing = "%2, %1".Arg(first_name, last_name) @@ -677,7 +677,7 @@ print listing ' Reacher, Jack ``` -``` +```brightscript text = "a=%3 b=%1 c=%2" text = text.Arg("banana") print text diff --git a/docs/REFERENCES/brightscript/interfaces/iftimespan.md b/docs/REFERENCES/brightscript/interfaces/iftimespan.md index 4723e1d4..940438f3 100644 --- a/docs/REFERENCES/brightscript/interfaces/iftimespan.md +++ b/docs/REFERENCES/brightscript/interfaces/iftimespan.md @@ -60,13 +60,13 @@ The number of seconds. #### Example -``` +```brightscript x = timespan.TotalSeconds() ``` is equivalent to -``` +```brightscript x = Int(timespan.TotalMilliseconds() / 1000) ``` diff --git a/docs/REFERENCES/brightscript/interfaces/iftostr.md b/docs/REFERENCES/brightscript/interfaces/iftostr.md index ecef9eb1..4627a532 100644 --- a/docs/REFERENCES/brightscript/interfaces/iftostr.md +++ b/docs/REFERENCES/brightscript/interfaces/iftostr.md @@ -70,7 +70,7 @@ Format-string support (the `ifToStr` interface) is implemented by the following ##### Integer (Decimal) -``` +```brightscript print 123.ToStr("%d") '=> "123" @@ -93,7 +93,7 @@ print month.ToStr("%-4d") ##### Integer (Hexadecimal) -``` +```brightscript hexy = 32767 - 1 print hexy.ToStr("%08X") '=> "00007FFE" @@ -108,7 +108,7 @@ print big_num.ToStr("%d = 0x%0X") ##### Float -``` +```brightscript f = 3.141592 print f.ToStr("%f") '=> "3.141592" @@ -122,7 +122,7 @@ print f.ToStr("%4.2f") ##### String -``` +```brightscript s = "123" print s.ToStr("[%s]") '=> "[123]" diff --git a/docs/REFERENCES/brightscript/interfaces/ifurltransfer.md b/docs/REFERENCES/brightscript/interfaces/ifurltransfer.md index dc38424b..b434c7a1 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifurltransfer.md +++ b/docs/REFERENCES/brightscript/interfaces/ifurltransfer.md @@ -38,7 +38,7 @@ A unique number for the object. #### Example -``` +```brightscript function Setup() m.pendingXfers = {} end function diff --git a/docs/REFERENCES/brightscript/interfaces/ifutils.md b/docs/REFERENCES/brightscript/interfaces/ifutils.md index 395be99c..068cf47b 100644 --- a/docs/REFERENCES/brightscript/interfaces/ifutils.md +++ b/docs/REFERENCES/brightscript/interfaces/ifutils.md @@ -38,7 +38,7 @@ This function returns a copy of the specified object. #### Example -``` +```brightscript utils = CreateObject("roUtils") di = CreateObject("roDeviceInfo") aa = { a: 1, b: { b1: 42 }, c: di } @@ -51,7 +51,7 @@ utils = CreateObject("roUtils") This code will output the following on the port 8085 console: -``` +```brightscript IsSameObject false new_aa.a 1 new_aa.b = @@ -80,7 +80,7 @@ Returns true if **data1** and **data2** reference the same object; otherwise, th #### Example -``` +```brightscript shared = {} aa = {"a": shared, "b": shared} utils = CreateObject("roUtils") diff --git a/docs/REFERENCES/brightscript/language/component-architecture.md b/docs/REFERENCES/brightscript/language/component-architecture.md index 57b6efe2..9ab7fd8b 100644 --- a/docs/REFERENCES/brightscript/language/component-architecture.md +++ b/docs/REFERENCES/brightscript/language/component-architecture.md @@ -103,7 +103,7 @@ type results in two copies of the same value, which can be modified independently of each other. -``` +```brightscript a = 42 ' a contains an intrinsic Integer b = a ' b contains a copy of a a = 43 ' does not modify b @@ -126,7 +126,7 @@ intrinsic variables are "passed by value", while object variables are **Example** -``` +```brightscript function Modify(a as Integer, b as Object) as Void a = 43 b.first = 6 @@ -150,7 +150,7 @@ is destroyed. **Example** -``` +```brightscript a = CreateObject("roArray") ' array has a ref count of 1 b = a ' array has a ref count of 2 a = invalid ' array has a ref count of 1 (a no longer refers to it) @@ -177,7 +177,7 @@ object is sometimes referred to as "autoboxing". **Example** -``` +```brightscript function Main() MyFunA(4) MyFunB(4) @@ -194,7 +194,7 @@ end function **Will Print:** -``` +```brightscript A 4 roInt B 4 Integer @@ -203,7 +203,7 @@ Integer **Example** -``` +```brightscript print 5.tostr()+"th" ' prints 5th print "5".toint()+5 ' prints 10 if type(5.tostr())<> "String" then stop @@ -281,7 +281,7 @@ For example, if the file "example.xml" contains the following: Then -``` +```brightscript rsp=CreateObject("roXMLElement") rsp.Parse(ReadAsciiFile("tmp:/example.xml")) ``` @@ -305,26 +305,26 @@ For example, if the variable booklist contains this roXMLElement: then -``` +```brightscript print booklist.book.gettext() ``` Will print "The Dawn of Man", and -``` +```brightscript print booklist.book@lang ``` will print -``` +```brightscript "eng" ``` **Example: flikr** -``` +```brightscript ' Interestingness ' pass an (optional) page of value 1 - 5 to get 100 photos ' starting at 0/100/200/300/400 @@ -415,7 +415,7 @@ collection). **Example** -``` +```brightscript i=roCreateObject("roInt") j=i ' reference incremented i=invalid ' reference decremented @@ -434,7 +434,7 @@ type roFilesystemEvent. **Example** -``` +```brightscript fs = CreateObject("roFilesystem") port = CreateObject("roMessagePort") fs.SetMessagePort(port) @@ -523,7 +523,7 @@ AssociativeArray object. **Example** -``` +```brightscript function Main() obj = ConstructMyObject() obj.Set("hi!") @@ -545,7 +545,7 @@ end function Output: -``` +```brightscript hi\! \-------- value: hi\! @@ -574,7 +574,7 @@ Library "v30/bslCore.brs" The common library file sources can be viewed from the debug console: -``` +```brightscript BrightScript> bslCore = ReadAsciiFile("common:/LibCore/v30/bslCore.brs") BrightScript> print bslCore @@ -726,7 +726,7 @@ If spriteMap.xml contains the following: Then -``` +```brightscript BrightScript> xml = ReadAsciiFile("pkg:/images/map.xml") BrightScript> bitmapset = dfNewBitmapSet(xml) BrightScript> cellwidth=app.bitmapset.extrainfo.cellsize.toint() diff --git a/docs/REFERENCES/brightscript/language/conditional-compilation.md b/docs/REFERENCES/brightscript/language/conditional-compilation.md index 589588c2..99792e70 100644 --- a/docs/REFERENCES/brightscript/language/conditional-compilation.md +++ b/docs/REFERENCES/brightscript/language/conditional-compilation.md @@ -25,7 +25,7 @@ and has the form: **Examples of valid expressions** -``` +```brightscript #const someFlag = true #const anotherFlag = false #const someOtherFlag = someFlag @@ -66,7 +66,7 @@ There are a variety of ways Conditional compilation can be used: **Example demonstrating use of manifest constants** -``` +```brightscript #if someFlag 'code to execute when someFlag is true #else if anotherFlag @@ -77,7 +77,7 @@ There are a variety of ways Conditional compilation can be used: **Example demonstrating locally scoped constants** -``` +```brightscript #const FeatureA = true #const FeatureB = false @@ -96,7 +96,7 @@ An `#error` constant can also be used to force a compilation error with an error **Example demonstrating usage of \#error constant** -``` +```brightscript #const FeatureAImplemented = true #if FeatureAImplemented @@ -114,7 +114,7 @@ Conditional compilation can also be used to form block comments. Previously, eac **Example of code block comments** -``` +```brightscript #if false This is a function that does nothing. This function takes no parameters. @@ -129,7 +129,7 @@ end function **Example of commenting out code** -``` +```brightscript #if false function Order66() as void 'code for Order66 diff --git a/docs/REFERENCES/brightscript/language/error-handling.md b/docs/REFERENCES/brightscript/language/error-handling.md index d101dbe3..cba620f6 100644 --- a/docs/REFERENCES/brightscript/language/error-handling.md +++ b/docs/REFERENCES/brightscript/language/error-handling.md @@ -28,7 +28,7 @@ It is important for the developer to view BrightScript's exception trapping feat The code that handles an exceptional situation resides in a `TRY`/`CATCH` block. Here is an example: -``` +```brightscript print "I'm about to try something that might not work" try do_something_that_might_throw_an_exception() @@ -60,7 +60,7 @@ When an exception is caught, information concerning the circumstances is collect The number is the same as printed when a program crashes. For example, consider this code: -``` +```brightscript sub main() x = 1 print x.foo @@ -69,13 +69,13 @@ end sub Execution produces the following output, due to an exception that is *not* caught: -``` +```brightscript Syntax Error. (runtime error &h02) in /tmp/dev/example.brs(3) ``` Note that the system's standard error reporting format may not provide information that is most meaningful to the user, or present it in the most useful format. The following version of `main()` is written to catch exceptions and report them to the user in a form that the programmer has defined: -``` +```brightscript sub main() x = 1 try @@ -88,7 +88,7 @@ end sub Here is the "programmer-approved" output produced by the enhanced `main()`: -``` +```brightscript 2 Syntax Error. ``` @@ -106,7 +106,7 @@ Element 0 of the array is the outermost function; element `count()-1` is the inn The `function` prototype text ("signature") will be something like `"main() As Void"` or `"foo(x As Float, y As Float) As Float"`. Here is an example of custom error display code that extracts the function name for a more concise display: -``` +```brightscript CATCH e prototype = e.backtrace[e.backtrace.count()-1].function name = LEFT(prototype,INSTR(prototype,"(")-1) @@ -120,13 +120,13 @@ The collection of keys present in the backtrace array may vary. The function pro The app may *throw* an exception to indicate something unexpected has gone wrong in app code. The simplest form is: -``` +```brightscript THROW "One of the cross beams has gone out of skew on the treadle." ``` This causes an exception with error number `ERR_USER` (`&h28`) as the number, and the supplied string as the message. If not caught, it will reach the crash dump or debugger, as with any other error: -``` +```brightscript Current Function: 001: SUB demo() 002:* THROW "One of the cross beams has gone out of skew on the treadle" @@ -154,13 +154,13 @@ A `roAssociativeArray` that describes the exception is also an acceptable argume Consider this example, which produces a division by zero error, along with a message that helpfully directs the user to the assumed source of fault: -``` +```brightscript THROW {number: ERR_DIV_ZERO, message: "Division by zero in complex number library"} ``` The ability to `THROW` an associative array, coupled with the system's default assumptions about the values of missing elements in such arrays, implies that the two following `THROW` statements are equivalent: -``` +```brightscript THROW "My error message" THROW {message: "My error message"} ``` @@ -179,7 +179,7 @@ Note that execution will *never* continue past a `THROW`; the statement will eit The following are just a few examples of invalid throws: -``` +```brightscript THROW 1 THROW [] THROW { number: "I am not a number!" } @@ -192,7 +192,7 @@ THROW { backtrace: [ {function: "main()", line_number: "Five"} ] } Custom information fields can be added to an exception without invalidating the `THROW`, so long as system-defined fields are left undisturbed. The custom fields can then be read by the `CATCH`-block that handles the exception. Roku recommends that any custom fields have names that begin with "`custom`"; fields with such names will not accidentally overwrite either existing system-defined fields, or any fields that Roku may eventually add to exception objects. -``` +```brightscript try fetch_web_page() catch e @@ -210,7 +210,7 @@ An exception object that has been caught is a valid argument to `THROW`. This is #### Reacting to an error without handling it -``` +```brightscript try if m.already_failed_once <> true then do_something_which_might_fail() catch e @@ -221,7 +221,7 @@ end try #### Handling only some errors -``` +```brightscript LIBRARY "v30/bslCore.brs" sub main() @@ -263,7 +263,7 @@ For example, `TRY`/`CATCH` blocks can be nested arbitrarily to provide multiple Below, although calling `reciprocal(0)` causes a division by zero, the function handles that exception itself, so the `TRY`/`CATCH` block in `main` *never* catches anything: -``` +```brightscript function reciprocal(x) try return 1/x @@ -287,7 +287,7 @@ end sub Here is an alternative that calculates the reciprocal directly in `main`: -``` +```brightscript sub main() print "Starting" try @@ -307,7 +307,7 @@ end sub An outer `TRY`/`CATCH` block can handle errors caused in an inner `CATCH`: -``` +```brightscript sub main() print "Starting" x = "I'm not an array" @@ -327,7 +327,7 @@ end sub Here is a variation, in which a `CATCH` itself contains a `TRY`/`CATCH` block, which, in turn catches any errors that *it* produces: -``` +```brightscript sub main() print "Starting" x = "I'm not an array" @@ -346,7 +346,7 @@ end sub Extracting the diagnostic portion into a separate subroutine yields the same results: -``` +```brightscript sub diagnose(x) try print "I think that failed because ";x[0];" isn't a number" diff --git a/docs/REFERENCES/brightscript/language/expressions-variables-types.md b/docs/REFERENCES/brightscript/language/expressions-variables-types.md index 02f77d14..a052297c 100644 --- a/docs/REFERENCES/brightscript/language/expressions-variables-types.md +++ b/docs/REFERENCES/brightscript/language/expressions-variables-types.md @@ -35,7 +35,7 @@ functions or interfaces (appear after a ".")) have the following rules. For example: -``` +```brightscript a boy5 super_man$ @@ -187,7 +187,7 @@ literals (constants), or expressions. **Example** -``` +```brightscript myarray = [] ' empty array myarray = [ 1, 2, 3 ] ' array of three members @@ -199,7 +199,7 @@ Arrays can be specified in multi-line form: **Example** -``` +```brightscript a = [ "able" "baker" @@ -208,7 +208,7 @@ a = [ **OR** -``` +```brightscript a = [ 3.1415, 2.71828 @@ -221,7 +221,7 @@ The { } operator can be used to define an Associative Array. It can contain lite **Example** -``` +```brightscript aa = { } aa = { key1: "value", key2: 55, key3: 5+3 } ``` @@ -232,7 +232,7 @@ Key names can be specified as string literals. **Example** -``` +```brightscript aa = { "Jane Doe": 1001, "John Doe": 1002 } ``` @@ -240,7 +240,7 @@ Associative Arrays can be specified in multi-line form: **Example** -``` +```brightscript aa = { Myfunc1: aFunction Myval1: "the value" @@ -249,7 +249,7 @@ aa = { **OR** -``` +```brightscript aa = { alpha: 1, zulu: 26 @@ -263,7 +263,7 @@ example, in the case when there is no object to return). In which case, the variable accepting the result must be dynamic, since it may get "invalid" or it may get an "object". -``` +```brightscript l=[] a$=l.pop() ``` @@ -443,7 +443,7 @@ The function call operator "( )" can be used to call a function. When used on a function name, function literal, or variable containing a function reference, it calls the function. -``` +```brightscript function five() as Integer return 5 end function @@ -466,7 +466,7 @@ interface or a member function. **Example** -``` +```brightscript i = CreateObject("roInt") i.ifInt.SetInt(5) @@ -489,7 +489,7 @@ they are not dynamic (unlike the Lookup() or AddReplace() functions). **Example** -``` +```brightscript aa = CreateObject("roAssociativeArray") aa.newkey = "the value" ' same as: aa.AddReplace("newkey", "the value") @@ -501,7 +501,7 @@ When used for lookups, the dot operator is always case insensitive, even if ifAssociativeArray.SetModeCaseSensitive() has been called. By convention, a statement like: -``` +```brightscript aa.NewKey = 55 ``` @@ -509,13 +509,13 @@ will actually create the Associative Array entry in all lower case ("newkey"). Similarly, an AssociativeArray literal like this will also create the entry in lower case: -``` +```brightscript aa = { NewKey: 55 } ``` To create mixed case keys, use the array operator or the ifAssociativeArray.AddReplace method: -``` +```brightscript aa["NewKey"] = 55 aa.AddReplace("NewKey", 55) @@ -531,7 +531,7 @@ It can also be used as a synonym for the dot operator to access an AssociativeArray (except that the dot operator is case insensitive as described above). -``` +```brightscript array = CreateObject("roArray", 10, true) array[2] = "two" print array[2] @@ -547,7 +547,7 @@ operator can be used in situations where dot cannot, such as when the value of the index contains a character which is invalid in a variable name. -``` +```brightscript aa = {} aa.name = 1 aa["name"] = 1 ' same as previous line @@ -562,7 +562,7 @@ the same: **Example** -``` +```brightscript dim array[5,5,5] item = array[1][2][3] @@ -585,7 +585,7 @@ The following example demonstrates how the BrightScript optional chaining operat ##### With optional chaining operators -``` +```brightscript x = array?[3]?.foo?.bar?() ``` @@ -593,7 +593,7 @@ In this example, the `?` variant checks whether the left-hand side of the expres ##### No optional chaining operators -``` +```brightscript if array <> invalid then el = array[3] if el <> invalid then @@ -728,7 +728,7 @@ Increment (++) and decrement (–) operators are available to allow integer increment and decrement to have effect on a variable. A few examples: -``` +```brightscript x=1 x++ ' x = 2 @@ -759,7 +759,7 @@ and bitshift operations that take a numeric operand: A few examples: -``` +```brightscript x=1 x+=1 ' x = 2 @@ -796,7 +796,7 @@ A runtime error is generated if the shift value is out of range. Example: -``` +```brightscript print 2 << 10 '= 2048 print 7 >> 1 '= 3 @@ -826,7 +826,7 @@ expressions and for bit manipulation. If the arguments to these operators are Boolean, then they perform a logical operation. If the arguments are numeric, they perform bitwise operations. -``` +```brightscript x = 1 and 2 ' x is zero y = true and false ' y is false @@ -839,14 +839,14 @@ evaluated from left to right, and only the necessary amount of the expression is executed (a feature sometimes called "minimal evaluation" or "short-circuit evaluation"). For example: -``` +```brightscript if true or func()=0 then print "ok" ``` The above statement will print "ok" but will not call func, since the expression is true no matter what func returns. On the other hand -``` +```brightscript if false or func()=0 then print "ok" ``` @@ -854,14 +854,14 @@ will call func and print ok only if func returns a value of zero. This feature can be used to write statements such as -``` +```brightscript if count > 0 and (total / count) > 33 then ... ``` Because of minimal evaluation, this will work correctly even when count is zero, while the following similar expression would not: -``` +```brightscript if (total / count) > 33 and count > 0 then ... ' runtime error when count = 0 ``` @@ -869,7 +869,7 @@ if (total / count) > 33 and count > 0 then ... ' runtime error when count = 0 "=" is used for both assignment and comparison. -``` +```brightscript a=5 if a=5 then print "a is 5" diff --git a/docs/REFERENCES/brightscript/language/format-strings.md b/docs/REFERENCES/brightscript/language/format-strings.md index 6c01e767..e2ce7bf7 100644 --- a/docs/REFERENCES/brightscript/language/format-strings.md +++ b/docs/REFERENCES/brightscript/language/format-strings.md @@ -26,7 +26,7 @@ The `flags`, `width`, and `precision` fields are optional, and they may control ##### Example -``` +```brightscript "%02x%02x%02x".Format(255, 0, 128) ' returns "ff0080" ``` diff --git a/docs/REFERENCES/brightscript/language/global-string-functions.md b/docs/REFERENCES/brightscript/language/global-string-functions.md index 3e40bc1b..684b7979 100644 --- a/docs/REFERENCES/brightscript/language/global-string-functions.md +++ b/docs/REFERENCES/brightscript/language/global-string-functions.md @@ -17,7 +17,7 @@ next: Converts the string to all upper case. -``` +```brightscript print UCase("Hello") ' prints: HELLO ``` @@ -25,7 +25,7 @@ Converts the string to all upper case. Converts the string to all lower case. -``` +```brightscript print LCase("Hello") ' prints: hello ``` @@ -36,7 +36,7 @@ specified string. An empty string argument will return 0. -``` +```brightscript print Asc("C") ' prints: 67 ``` @@ -48,7 +48,7 @@ whose character has the specified Unicode value. Returns empty string if the specified value is 0 or an invalid Unicode value. -``` +```brightscript print Chr(67) ' prints: C ``` @@ -56,7 +56,7 @@ By using Chr, you can create strings containing characters which cannot be contained in quotes, such as newline or the quote character itself. -``` +```brightscript print (Chr(34) + "hello" + Chr(34)) ' prints: "hello" ``` @@ -68,7 +68,7 @@ starting at the specified start position. Returns 0 if the substring is not found. Unlike the ifString.Instr() method, the first position is 1. -``` +```brightscript print Instr(1, "this is a test", "t") ' prints: 1 print Instr(2, "this is a test", "t") ' prints: 11 print Instr(1, "this is a test", "is") ' prints: 3 @@ -78,7 +78,7 @@ method, the first position is 1. Returns the first *n* characters of *s.* -``` +```brightscript print Left("timothy", 3) ' prints: tim ``` @@ -86,7 +86,7 @@ Returns the first *n* characters of *s.* Returns the number of characters in the specified string. -``` +```brightscript print Len("timothy") ' prints: 7 ``` @@ -100,7 +100,7 @@ the end of the string is returned. Unlike the [ifStringOps.Mid()](doc:ifstringops) method, the first character in the string is position 1. -``` +```brightscript print mid("timothy", 4, 3) ' prints: oth ``` @@ -108,7 +108,7 @@ position 1. Returns the last n characters of s. -``` +```brightscript print right("timothy", 3) ' prints: thy ``` @@ -145,7 +145,7 @@ lowercase letters to represent those digits in bases greater than 10. For example: -``` +```brightscript print StrI(255, 16) '= "ff" print StrI(9, 2) '= "1001" @@ -158,7 +158,7 @@ concatenated together. For example, -``` +```brightscript print String(4, "ab") ' prints: abababab ``` @@ -169,7 +169,7 @@ value is the second argument. For example, -``` +```brightscript print StringI(5, 67) ' prints: CCCCC ``` @@ -196,7 +196,7 @@ valid. For example: -``` +```brightscript print Val("0x80", 0) '= 128 print Val("FF", 16) '= 255 @@ -210,7 +210,7 @@ Replaces all instances of {0} or \^0 in a string with arg0. Similarly, replaces **Example** -``` +```brightscript thing = "book" color = "red" print Substitute("My {0} is {1}.", thing, color) ' prints "My book is red." @@ -222,6 +222,6 @@ Replaces %*n* placeholders (for example, %1, %2, etc.) with arg1, arg2, and so o **Example** -``` +```brightscript currentPlanText = Substitute(tr("Current plan: %1 %2 %3/%4", tierDisplayName, LCase(getPlanName(currentPlan.productType)), cost, currentPlan.renewalPeriodNounTextAbbrv) ``` diff --git a/docs/REFERENCES/brightscript/language/global-utility-functions.md b/docs/REFERENCES/brightscript/language/global-utility-functions.md index 6d4a94b5..32721be9 100644 --- a/docs/REFERENCES/brightscript/language/global-utility-functions.md +++ b/docs/REFERENCES/brightscript/language/global-utility-functions.md @@ -23,7 +23,7 @@ This function causes the script to pause for the specified time, without wasting CPU cycles. There are 1000 milliseconds in one second. -``` +```brightscript sleep(1000) ' sleep for 1 second sleep(200) ' sleep 2/10 of a second sleep(3000) ' sleep three seconds @@ -39,7 +39,7 @@ are received. In this case, Wait returns a type "invalid". **Example** -``` +```brightscript p = CreateObject("roMessagePort") s = CreateObject("roScreen") s.SetPort(p) @@ -63,7 +63,7 @@ function, or invalid if not found. For example: -``` +```brightscript print FindMemberFunction({}, "Count") '= ``` @@ -83,7 +83,7 @@ specified. For example: -``` +```brightscript BrightScript> l=ListDir("pkg:/movies") BrightScript> print l test_movie_3.vob @@ -103,7 +103,7 @@ An empty string is returned if the file can not be read. For example: -``` +```brightscript text=ReadAsciiFile("tmp:/config.txt") ``` @@ -119,7 +119,7 @@ The function returns true if the file was successfully written. For example: -``` +```brightscript WriteAsciiFile("tmp:/config.txt", "the text to write") ``` @@ -158,7 +158,7 @@ The pattern may contain certain special characters: For example: -``` +```brightscript files = MatchFiles(".", "*.mpg") ``` @@ -192,7 +192,7 @@ this function. For example: -``` +```brightscript BrightScript Debugger> a=[] BrightScript Debugger> a[0]=a BrightScript Debugger> a=invalid @@ -242,7 +242,7 @@ list of photo URLs: } ``` -``` +```brightscript searchRequest = CreateObject("roUrlTransfer") searchRequest.SetURL("http://api.example.com/services/rest/getPhotos") response = ParseJson(searchRequest.GetToString()) @@ -278,7 +278,7 @@ character value. ##### Example -``` +```brightscript euroStr = Chr(&h20AC) '* By default, non-ASCII Unicode characters are escaped in JSON style @@ -300,7 +300,7 @@ print FormatJSON(euroStr, &h0001) ##### Example -``` +```brightscript list = CreateObject("roList") obj = {list:list, n:1} @@ -343,7 +343,7 @@ value returned from the Tr() lookup. For example: -``` +```brightscript `text = Tr("Video will start in %1 seconds").Replace("%1", numSeconds.ToStr())` ``` diff --git a/docs/REFERENCES/brightscript/language/program-statements.md b/docs/REFERENCES/brightscript/language/program-statements.md index be225bc5..41d05670 100644 --- a/docs/REFERENCES/brightscript/language/program-statements.md +++ b/docs/REFERENCES/brightscript/language/program-statements.md @@ -21,19 +21,19 @@ passed to Dim is the index of the maximum entry to be allocated (the array initial size = dimension+1); the array will be resized larger automatically if needed. -``` +```brightscript Dim array[5] ``` Is the same as: -``` +```brightscript array=CreateObject("roArray",6,true) ``` Note that x\[a,b\] is the same as x\[a\]\[b\]. -``` +```brightscript dim c[5, 4, 6] for x = 1 to 5 for y = 1 to 4 @@ -65,7 +65,7 @@ value. **Example** -``` +```brightscript a$="a rose is a rose" b1=1.23 x=x-z1 @@ -92,7 +92,7 @@ on a line by itself. For example: -``` +```brightscript mylabel: print "Anthony was here!" Goto mylabel @@ -135,7 +135,7 @@ assumed. For example: -``` +```brightscript for i = 10 to 1 Step -1 print i end for @@ -143,7 +143,7 @@ end for `NEXT` is supported as an alternative terminator to `END FOR` for legacy compatibility, but `END FOR` is the preferred form: -``` +```brightscript for i=10 to 1 step -1 print i next @@ -169,7 +169,7 @@ roMessagePort. For example: -``` +```brightscript aa = { joe: 10, fred: 11, sue:9 } for each n in aa @@ -180,7 +180,7 @@ end for As with `FOR`, `NEXT` is supported as an alternative terminator to `END FOR` for legacy compatibility, but `END FOR` is the preferred form: -``` +```brightscript for each n in aa print n;aa[n] next @@ -194,7 +194,7 @@ prematurely. For example: -``` +```brightscript k = 0 while k = 0 k = 1 @@ -217,7 +217,7 @@ The "continue" statement terminates the execution of the statements in the curre For example: -``` +```brightscript fruits = ["orange", "lemon", "lime"] for each fruit in fruits if fruit = "lemon" then continue for @@ -239,7 +239,7 @@ end while Use to trap exceptions, which enables the implementation of error handling in BrightScript programs. Schematically, the syntax is as follows: -``` +```brightscript try ' Zero or more statements ("TRY block") catch exception_object_variable_name @@ -255,7 +255,7 @@ The TRY block of statements is executed. If and only if an error occurs, the CAT The variable name specified as the *exception object* in the CATCH clause must refer to a *simple variable*. It cannot be an array element, for example. The following are **not** legal as exception object references in the CATCH clause: -``` +```brightscript CATCH ' no object variable at all -- an object must always be specified CATCH someArray[23] ' array element is bad exception object CATCH bill.ted ' object field is bad exception object @@ -285,7 +285,7 @@ Information about the exception is contained within an exception object that is The following example sends an error message, including the contents of the exception record, to the debug console. -``` +```brightscript try print 1/0 catch e @@ -303,7 +303,7 @@ end try TRY/CATCH statements can be nested within TRY or CATCH blocks, as needed. Here is an example: -``` +```brightscript print "Starting" x = "I'm not an array" try @@ -334,7 +334,7 @@ The expression given in the THROW statement should evaluate to an exception obje **Example code** -``` +```brightscript function reciprocal(x) return 1/x end function @@ -369,7 +369,7 @@ REM. For example: -``` +```brightscript Rem ** this remark introduces the program ** ' this too is a remark ``` @@ -386,7 +386,7 @@ program line. For example: -``` +```brightscript if x > 127 then print "out of range" if caveman = "fred" then print "flintstone" else print "rubble" ``` @@ -398,7 +398,7 @@ THEN is optional in the above and similar statements. The multi-line or block form of IF THEN ELSE is more flexible. It has the form: -``` +```brightscript if BooleanExpression then statements elseif BooleanExpression then @@ -414,7 +414,7 @@ words: "else if". For example: -``` +```brightscript msg = wait(0, p) if type(msg) = "roVideoPlayerEvent" then if debug then print "video event" @@ -449,7 +449,7 @@ strings. For example: -``` +```brightscript x=5:print 25; " is equal to"; x^2 25 is equal to 25 @@ -469,7 +469,7 @@ zone 1 zone 2 zone 3 zone 4 Each print zone is 16 char wide. The cursor moves to the next print zone each time a comma is encountered. -``` +```brightscript print "print statement #1 "; "print statement #2" Output: print statement #1 print statement #2 @@ -477,7 +477,7 @@ Output: print statement #1 print statement #2 Semi-colons can be dropped in some cases. For example, this is legal: -``` +```brightscript print "this is a five " 5 "!!" ``` @@ -491,7 +491,7 @@ objects: **Printing Enumerable Objects** -``` +```brightscript print {} ' this will print: = { } @@ -511,7 +511,7 @@ Moves the cursor to the specified position on the current line (modulo the width of your console if you specify TAB positions greater than the console width). TAB may be used several times in a PRINT list. -``` +```brightscript print tab(5)"tabbed 5";tab(25)"tabbed 25" ``` @@ -525,7 +525,7 @@ Returns a number from 0 to window width, indicating the current cursor position on the cursor. Requires a "dummy argument" (any numeric expression). -``` +```brightscript print tab(40) pos(0) 'prints 40 at position 40 print "these" tab(pos(0)+5)"words" tab(pos(0)+5)"are"; tab(pos(0)+5)"evenly" tab(pos(0)+5)"spaced" ``` @@ -560,7 +560,7 @@ parameters. For example: -``` +```brightscript function cat(a, b) return a+b 'a, b could be numbers or strings end function @@ -593,7 +593,7 @@ in. For example: -``` +```brightscript sub main() obj = { add: add @@ -619,7 +619,7 @@ A function is anonymous if it does not have a name. Note that Anonymous Functions do not currently create closures. An Anonymous Function can be declared like this: -``` +```brightscript myfunc = function (a, b) return a+b end function @@ -629,7 +629,7 @@ print myfunc(1,2) They can be used with associative array literals like this: -``` +```brightscript q = { starring : function(o, e) str = e.GetBody() diff --git a/docs/REFERENCES/brightscript/language/runtime-functions.md b/docs/REFERENCES/brightscript/language/runtime-functions.md index eba02d48..3d529698 100644 --- a/docs/REFERENCES/brightscript/language/runtime-functions.md +++ b/docs/REFERENCES/brightscript/language/runtime-functions.md @@ -21,7 +21,7 @@ after *name*. For example: -``` +```brightscript app_mgr = CreateObject("roAppManager") section = CreateObject("roRegistrySection", "Data") ``` @@ -33,7 +33,7 @@ Component specification for a list of types. For example: -``` +```brightscript print type(5) 'returns a 2.1 compatible type print type("my string", 3) 'return a Roku OS 3.0 type ``` @@ -50,7 +50,7 @@ function. Box() will return an object version of an intrinsic type, or pass through an object if given one. -``` +```brightscript bo = box("string") bo = box(bo) ' no change to bo ``` @@ -72,7 +72,7 @@ If an array of files are passed instead of a single filename, then each file is For example: -``` +```brightscript sub Main() Run("pkg:/test.brs") BreakIfRunError(LINE_NUM) @@ -131,13 +131,13 @@ runtime error, but you don't want code execution to stop. Example: -``` +```brightscript print Eval("n=1/0") ``` Outputs: -``` +```brightscript 20 ``` @@ -160,14 +160,14 @@ Returns an error code result after the last script Run(). These two are normal: -``` +```brightscript &hFC==ERR_NORMAL_END &hE2==ERR_VALUE_RETURN ``` **Example: Assign variables to common runtime errors** -``` +```brightscript ERR_USE_OF_UNINIT_VAR = &hE9 ERR_DIV_ZERO = &h14 ERR_TM = &h18 diff --git a/docs/REFERENCES/brightscript/language/statement-summary.md b/docs/REFERENCES/brightscript/language/statement-summary.md index 0f2afd0d..e46ceabc 100644 --- a/docs/REFERENCES/brightscript/language/statement-summary.md +++ b/docs/REFERENCES/brightscript/language/statement-summary.md @@ -14,7 +14,7 @@ next: BrightScript supports the following familiar looking statement types: -``` +```brightscript If / Then / Else If / Else / End If For / To / End For / Step / Exit For For Each / In / End For / Exit For @@ -36,7 +36,7 @@ Each statement's syntax is documented precisely later in the manual. For example: -``` +```brightscript function Main() as Void dim cavemen[10] cavemen.push("fred") @@ -53,7 +53,7 @@ end function Each line may contain a single statement, or a colon ( : ) may be used to separate multiple statements on a single line. -``` +```brightscript myname = "fred" if myname="fred" then yourname = "barney" : ? yourname ``` diff --git a/docs/REFERENCES/scenegraph/animation-nodes/animation.md b/docs/REFERENCES/scenegraph/animation-nodes/animation.md index fa2e2413..90c664ab 100644 --- a/docs/REFERENCES/scenegraph/animation-nodes/animation.md +++ b/docs/REFERENCES/scenegraph/animation-nodes/animation.md @@ -24,7 +24,7 @@ The following example shows how to use some simple animations. It uses two Anima #### Animation BrightScript example -``` +```brightscript function init() scaleAnimation = m.top.FindNode("scaleAnimation") transAnimation = m.top.FindNode("transAnimation") diff --git a/docs/REFERENCES/scenegraph/component-functions/init.md b/docs/REFERENCES/scenegraph/component-functions/init.md index 8b7bb1f7..5f2e0844 100644 --- a/docs/REFERENCES/scenegraph/component-functions/init.md +++ b/docs/REFERENCES/scenegraph/component-functions/init.md @@ -18,7 +18,7 @@ If the \ element contains the definition of a function named init() tha #### Syntax -``` +```brightscript sub init() ... end sub diff --git a/docs/REFERENCES/scenegraph/component-functions/onkeyevent.md b/docs/REFERENCES/scenegraph/component-functions/onkeyevent.md index d79e1ccb..ed649a4c 100644 --- a/docs/REFERENCES/scenegraph/component-functions/onkeyevent.md +++ b/docs/REFERENCES/scenegraph/component-functions/onkeyevent.md @@ -18,7 +18,7 @@ The `onKeyEvent()` function receives remote control key events from the Roku OS, #### Syntax -``` +```brightscript function onKeyEvent(_key_ as String, _press_ as Boolean) as Boolean ... end function @@ -65,7 +65,7 @@ The following `onKeyEvent()` example handles supported remote control key presse **onKeyEvent() event handling example** -``` +```brightscript function onKeyEvent(key as String, press as Boolean) as Boolean handled = false if press then diff --git a/docs/REFERENCES/scenegraph/control-nodes/channelstore.md b/docs/REFERENCES/scenegraph/control-nodes/channelstore.md index 426cb3d9..37794831 100644 --- a/docs/REFERENCES/scenegraph/control-nodes/channelstore.md +++ b/docs/REFERENCES/scenegraph/control-nodes/channelstore.md @@ -96,7 +96,7 @@ Each of the commands starts a sequence of actions associated with the financial #### Sign-up example -``` +```brightscript store = CreateObject("roSGNode", "ChannelStore") ' Request several properties for sign-up @@ -112,7 +112,7 @@ store.command = "getUserData" #### Sign-in example -``` +```brightscript store = CreateObject("roSGNode", "ChannelStore") ' Set sign-in context for RFI screen @@ -180,7 +180,7 @@ To create an order, this field needs to be set to a ContentNode that has one chi To set the `order` field directly, first create a ContentNode, then create one child ContentNode with the `"code"` and `"qty"` fields set for each item to be purchased. Assuming `m.channelStore` is a ChannelStore node object, the following Brightscript code shows how to do this: -``` +```brightscript myOrder = CreateObject("roSGNode", "ContentNode") myFirstItem = myOrder.createChild("ContentNode") myFirstItem.addFields({ "code": "UPC2397", "qty": 1}) @@ -192,7 +192,7 @@ m.channelStore.order = myOrder The `order` field can be set indirectly as well, by setting the `deltaOrder` field to add or modify the desired quantity of an item. Assuming `m.channelStore` is a ChannelStore node object, the following results in the `order` field containing the same items as the previous example: -``` +```brightscript m.channelStore.deltaOrder = { "code": "UPC2397", "qty": 1} m.channelStore.deltaOrder = { "code": "UPC4321", "qty": 1} ``` @@ -798,7 +798,7 @@ If this command is successful, the [**purchases** field](#purchases) ContentNode Stores an OAuth token, custom token, or other custom data, which you can then retrieve with the [getChannelCred](#getchannelcred) command (the token is stored in the **channelCred.json.channel_data** field). This data is stored securely in the Roku cloud and can be retrieved by other devices linked to the same Roku account. As a result, users do not have to re-enter their account credentials when setting up new devices associated with the same Roku account. For more information, see [Automatic Account Link](/dev/docs/universal-authentication-protocol-for-single-sign-on). -``` +```brightscript function init(): m.store.ObserveField("storeChannelCredDataStatus", "onStoreChannelCredData") m.store.ObserveField("channelCred", "onGetChannelCred") @@ -921,7 +921,7 @@ Retrieves an oAuth token, custom token, or other authentication artifact (`chann Generates a signed JSON web token (JWT) in the Roku cloud and returns it to the app. This token can then be used by the publisher's web services to verify that a message originated from a genuine Roku device. The following example demonstrates how to generate the device attestation token: -``` +```brightscript sub handleData(event) data = event.getData() print data.status @@ -939,7 +939,7 @@ m.channelstore_node.command = "getDeviceAttestationToken" The following demonstrates a sample JWT that is returned to the app. Developers can use a [JWT debugger](https://jwt.io/#debugger-io) to decode this token. -``` +```text eyJ4NXUiOiJodHRwczovL2V4YW1wbGUucm9rdS5jb20vc2FtcGxlY2VydCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0.eyJuYmYiOjE2NTYzNzQyNzQsIngtcm9rdS1hdHRlc3RhdGlvbi1kYXRhIjp7Im5vbmNlIjoiNUUwNjkyRTBBMzg5RjRGNiIsImNoYW5uZWxJZCI6ImRldiIsImRldmVsb3BlcklkIjoiY2FhNzNmYmI1ZTc1YTQ2YTRiNjExNGRlNTFhNWFkYTdkNjE2ZTJlZCIsInRpbWVzdGFtcE1zIjoxNjU2Mzc3ODczOTkwfSwiaXNzIjoidXJuOnJva3U6Y2xvdWQtc2VydmljZXM6ZGV2aWNlLWF0dGVzdGF0aW9uIiwiZXhwIjoxNjU2NDY0Mjc0fQ.nywDvSUys27oeaQZ3yXwNBfOnXbO-TUDuekOPZYjSssfZhNhWwRXvPLbJKHcNMR5Z0vFOQLVDFeqEVGauIMxMEke5UFLuCRxhr3ayBJJPt_BPfrEFbAvYjFEGdKkxJqYUhuFE38R8lU2k7dhO0iFxDw1Qq7W4w8_7CjmDy4YFf7IfyhV7Vf2kGiOx5C94Niw5N2td3s21F3z77Rq_bofQ51DOKIwo_cDVuvPQnDyxG-CNEydZKCZZwGPYCKEHMPrIOOXJ-S9ZjArgaEpBUpMXWJibFxnkpVUVzbC22GEaqz_SjOJXFMQU7TaCKkDeCYVKylgKwCvbvHRDlgogf7kqg ``` @@ -952,7 +952,7 @@ To verify the JWT, developers must [download the Roku device attestation token c The decoded JWT contains the following fields: -``` +```brightscript "x-roku-attestation-data": { "nonce": "5E0692E0A389F4F6", "channelId": "dev", diff --git a/docs/REFERENCES/scenegraph/control-nodes/contentnode.md b/docs/REFERENCES/scenegraph/control-nodes/contentnode.md index 9f57a5d2..86823151 100644 --- a/docs/REFERENCES/scenegraph/control-nodes/contentnode.md +++ b/docs/REFERENCES/scenegraph/control-nodes/contentnode.md @@ -56,7 +56,7 @@ To create a ContentNode in BrightScript, you should generally: As follows: -``` +```brightscript ContentNode_object = createObject("RoSGNode","ContentNode") ContentNode_child_object = ContentNode_object.createChild("ContentNode") ContentNode_child_object.field_name = data @@ -67,13 +67,13 @@ ContentNode_child_object.field_name = data For nodes and components that require a ContentNode as the specification of their content field, you can define it as a child of the node or component in XML markup using the role attribute, or just assign the ContentNode object to the content field as follows: -``` +```brightscript NodeComponent.content = ContentNode_object ``` For other nodes and components that don't require a ContentNode, you can use getChild() or a similar function to locate the specific child ContentNode object that contains the data you want to assign to a particular node/component field: -``` +```brightscript ContentNode_child_object = ContentNode_object.getChild(child_number) NodeComponent.field_name = ContentNode_child_object.field_name ``` @@ -153,7 +153,7 @@ The following creates a component with a LabelList node populated with some spec All of the attributes listed in [Content Meta-Data](doc:content-metadata) are accessible as fields using dot (.) notation on a ContentNode object. For example, for a ContentNode object iteminfo, the Content Meta-Data Description attribute can be read or written as follows: -``` +```brightscript iteminfo.description ``` @@ -169,7 +169,7 @@ You can also access ContentNode attributes as fields using dot (.) notation if y Then for a listitemcontent ContentNode object iteminfo, you can read or write the componentname field in the same way as if it were a Content Meta-Data attribute: -``` +```brightscript iteminfo.componentname ``` diff --git a/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/dynamic-custom-keyboard.md b/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/dynamic-custom-keyboard.md index fe13103a..56c7e10c 100644 --- a/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/dynamic-custom-keyboard.md +++ b/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/dynamic-custom-keyboard.md @@ -24,7 +24,7 @@ The layout of the keyboard is customized based on a JSON-formatted Key Definitio The instance of the **DynamicKeyGrid** node is accessed via the **keyGrid** field of the **DynamicCustomKeyboard** node. The **keyGrid** field includes a **keyDefinitionUri** field, which must be set to a valid Key Definition File. Typically, this is done by creating an RSG component that extends the **DynamicCustomKeyboard** and then defining an **init()** function for that component as demonstrated in the following example: -``` +```brightscript sub init() m.top.keyGrid.keyDefinitionUri = "pkg:/data/coolKeyboardLayoutKDF.json" end sub @@ -48,7 +48,7 @@ It is recommended that developers create a component that extends the **DynamicC For most keys defined in the Key Definition File, the [default key selection handlers](#default-key-selection-handlers) will provide the desired behavior. If custom handling is needed, the component that extends the **DynamicCustomKeyboard** node class can implement an interface function. To do this, include a function within the component's \ element that has the following signature: -``` +```brightscript function keySelected(key as string) as boolean ``` @@ -79,7 +79,7 @@ The following example demonstrates a custom key handler: ``` 3. In the corresponding BrightScript file for the child **DynamicCustomKeyboard** component, the **keySelected()** function includes the following business logic: - ``` + ```brightscript function keySelected(key as string) as boolean if key = "ChangeCase" if m.top.keyGrid.mode = "UpperCase" ' m.top.keyGrid.mode would likely be initialized in the component's init() @@ -106,7 +106,7 @@ In most cases, the default key selection handlers can be used for modifying the ] ``` 2. The **keySelected()** function includes the following business logic: - ``` + ```brightscript function keySelected(key as string) as boolean if key = "DuplicateCharacter" currString = m.top.text diff --git a/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/key-definition-file.md b/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/key-definition-file.md index 662984ed..ecae3da0 100644 --- a/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/key-definition-file.md +++ b/docs/REFERENCES/scenegraph/dynamic-voice-keyboard-nodes/key-definition-file.md @@ -171,7 +171,7 @@ This example uses a Key Definition File to specify a simple numeric PIN pad. The roku815px - pin-pad-kdf -``` +```json { "keyboardWidthFHD": 495, "keyboardHeightFHD": 300, @@ -233,7 +233,7 @@ This example uses the Key Definition File for the Search "MiniKeyboard" used by roku815px - mini-keyboard-kdf -``` +```json { "keyboardWidthFHD": 576, "keyboardHeightFHD": 630, @@ -356,7 +356,7 @@ The examples below show the Keyboard in the "NameLower", "Zip" and "FullLower" m roku815px - key-grid-3-zip -``` +```json { "keyboardWidthFHD": 576, "keyboardHeightFHD": 432, @@ -757,7 +757,7 @@ The examples below show the keyboard in "ABC123Lower" mode as well as "AccentsUp roku815px - wifi-keyboard-2-symbols-kdf -``` +```json { "keyboardWidthFHD": 1368, "keyboardHeightFHD": 336, @@ -1549,7 +1549,7 @@ This example uses the same Key Definition File as the WiFi keyboard above, but w roku815px - email-keyboard-kdf -``` +```json { "keyboardWidthFHD": 1368, "keyboardHeightFHD": 336, @@ -2347,7 +2347,7 @@ This example starts with the same Key Definition File used for the WiFi keyboard roku815px - extended-action-keyboard-kdf -``` +```json { "keyboardWidthFHD": 1584, "keyboardHeightFHD": 336, diff --git a/docs/REFERENCES/scenegraph/label-nodes/multi-style-label.md b/docs/REFERENCES/scenegraph/label-nodes/multi-style-label.md index 6304a1bb..cf6ecaec 100644 --- a/docs/REFERENCES/scenegraph/label-nodes/multi-style-label.md +++ b/docs/REFERENCES/scenegraph/label-nodes/multi-style-label.md @@ -30,7 +30,7 @@ The MultiStyleLabel **drawingStyles** field contains one or more associative arr The MultiStyleLabel **text** field uses a simple markup style. Markup tags with the names of the styles defined in the **drawingStyles** field are used to delineate the boundaries of the label text to be rendered in that specific style. -``` +```brightscript m.MultiStyleLabel.drawingStyles = { "HandprintedRed": { diff --git a/docs/REFERENCES/scenegraph/list-and-grid-nodes/targetlist.md b/docs/REFERENCES/scenegraph/list-and-grid-nodes/targetlist.md index c01d4d8c..e5004d58 100644 --- a/docs/REFERENCES/scenegraph/list-and-grid-nodes/targetlist.md +++ b/docs/REFERENCES/scenegraph/list-and-grid-nodes/targetlist.md @@ -20,7 +20,7 @@ To set up a fixed focus list or grid, set the focusedTargetSet field to a Target **focusedTargetSet1** -``` +```brightscript focusedTargetSet1 = createObject("roSGNode", "TargetSet") m.tList1.focusedTargetSet = [ focusedTargetSet1 ] @@ -38,7 +38,7 @@ focusedTargetSet1.focusIndex = 1 **unfocusedTargetSet** -``` +```brightscript unfocusedTargetSet.targetRects = [ { x:-100, y:-64, height:134, width:240 }, { x:150, y:-64, height:134, width:240 }, @@ -61,7 +61,7 @@ When the focus moves to Item 2, the layout of the first row is defined by anothe **focusedTargetSet array** -``` +```brightscript focusedTargetSet1 = createObject("roSGNode", "TargetSet") focusedTargetSet2 = createObject("roSGNode", "TargetSet") focusedTargetSet3 = createObject("roSGNode", "TargetSet") @@ -71,7 +71,7 @@ m.tList1.focusedTargetSet = [ focusedTargetSet1, focusedTargetSet2, focusedTarge **Additional TargetSets for floating focus** -``` +```brightscript focusedTargetSet2.targetRects = [ { x:-178, y:-64, height:134, width:240 }, { x:72, y:-64, height:134, width:240 }, diff --git a/docs/REFERENCES/scenegraph/scene.md b/docs/REFERENCES/scenegraph/scene.md index 55d64b9c..f6fd402f 100644 --- a/docs/REFERENCES/scenegraph/scene.md +++ b/docs/REFERENCES/scenegraph/scene.md @@ -14,7 +14,7 @@ Extends [**Group**](doc:group) The **Scene** node class serves as the root of a SceneGraph node tree. Every **roSGScreen** object must have a **Scene** node, or a node that derives from the **Scene** node class as its root, including an XML markup component that extends the Scene node class or subclass. That node must be created using the **roSGScreen** createScene() function, with an argument that is a string of the name of the **Scene** node object created. For example: -``` +```brightscript screen = CreateObject("roSGScreen") scene = screen.CreateScene("Scene") ``` diff --git a/docs/REFERENCES/scenegraph/sliding-panels-nodes/gridpanel.md b/docs/REFERENCES/scenegraph/sliding-panels-nodes/gridpanel.md index ec2c7e1b..c47dbf31 100644 --- a/docs/REFERENCES/scenegraph/sliding-panels-nodes/gridpanel.md +++ b/docs/REFERENCES/scenegraph/sliding-panels-nodes/gridpanel.md @@ -104,7 +104,7 @@ For efficiency, sometimes the control logic for the GridPanel may create and hol > If you are creating the grid field (either a PosterGrid or MarkupGrid) associated with a GridPanel in script of a component that extends GridPanel, you also need to add the grid as a child of the GridPanel. For example, in a component that extends GridPanel, where m.top is that component, you would associate the grid field with a PosterGrid as follows: -``` +```brightscript grid = m.top.createChild("PosterGrid") m.top.grid = grid ``` diff --git a/docs/REFERENCES/scenegraph/sliding-panels-nodes/index.md b/docs/REFERENCES/scenegraph/sliding-panels-nodes/index.md index 9d8ba3a5..87661cd9 100644 --- a/docs/REFERENCES/scenegraph/sliding-panels-nodes/index.md +++ b/docs/REFERENCES/scenegraph/sliding-panels-nodes/index.md @@ -155,7 +155,7 @@ presses. **Panel Adding/Sliding Example** -``` +```brightscript sub init() m.top.backgroundURI = "pkg:/images/rsgetbg.jpg" m.top.overhang.showClock = false diff --git a/docs/REFERENCES/scenegraph/sliding-panels-nodes/listpanel.md b/docs/REFERENCES/scenegraph/sliding-panels-nodes/listpanel.md index f243c79c..89f64d16 100644 --- a/docs/REFERENCES/scenegraph/sliding-panels-nodes/listpanel.md +++ b/docs/REFERENCES/scenegraph/sliding-panels-nodes/listpanel.md @@ -113,7 +113,7 @@ If you set the list field to a MarkupList node, because the MarkupList is by nat > If you are creating the list field(either a LabelList or MarkupList) associated with a ListPanel in script of a component that extends ListPanel, you also need to add the list as a child of the ListPanel. For example, in a component that extends ListPanel, where m.top is that component, you would associate the list field with a LabelList as follows: -``` +```brightscript list = m.top.createChild("LabelList") m.top.list = list ``` diff --git a/docs/REFERENCES/scenegraph/sliding-panels-nodes/overhangpanelsetscene.md b/docs/REFERENCES/scenegraph/sliding-panels-nodes/overhangpanelsetscene.md index 9866fdfd..2cec2c56 100644 --- a/docs/REFERENCES/scenegraph/sliding-panels-nodes/overhangpanelsetscene.md +++ b/docs/REFERENCES/scenegraph/sliding-panels-nodes/overhangpanelsetscene.md @@ -16,7 +16,7 @@ Extends [**Scene**](doc:scene) The OverhangPanelSetScene node class provides a convenient way to create a Scene node that has set with default Overhang and PanelSet nodes. The layout of the Overhang and PanelSet use the default sizes for SDK2 apps. The node provides access to the PanelSet and Overhang via fields that contain the node objects. -``` +```brightscript scene = screen.CreateScene("OverhangPanelSetScene") ``` diff --git a/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/index.md b/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/index.md index 41426c50..b10bf77f 100644 --- a/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/index.md +++ b/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/index.md @@ -106,7 +106,7 @@ To create the confirmation dialog with a pre-built StandardDialog node and detec ##### BrightScript -``` +```brightscript sub showAccountDialog() ' set up the dialog m.accountDialog = createObject("roNode", "StandardMessageDialog") @@ -156,7 +156,7 @@ To create the confirmation dialog with a custom standard dialog and detect butto ##### BrightScript -``` +```brightscript sub showAccountDialog() ' set up the dialog m.accountDialog = createObject("roNode", "AccountDialog") @@ -211,7 +211,7 @@ For more information about how StandardDialog nodes used the RSGPalette colors, The following BrightScript code demonsrates how to create an **RSGPalette** node with green colors and assign it to the Scene's palette field. The resulting dialog is displayed below the code. -``` +```brightscript m.greenPalette = createObject("roSGNode", "RSGPalette") m.greenPalette.colors = {DialogBackgroundColor: "0x003000FF", DialogItemColor: "0x00EF00FF", diff --git a/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/std-dlg-multi-style-text-item.md b/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/std-dlg-multi-style-text-item.md index 0b7df2d6..bf158143 100644 --- a/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/std-dlg-multi-style-text-item.md +++ b/docs/REFERENCES/scenegraph/standard-dialog-framework-nodes/std-dlg-multi-style-text-item.md @@ -24,7 +24,7 @@ The **StdDlgMultiStyleTextItem** node enables developers to add a line of text w - The **text** field uses a simple markup style. Markup tags with the names of the styles defined in the **drawingStyles** field are used to delineate the boundaries of the label text to be rendered in that specific style. -``` +```brightscript msTextItem.drawingStyles = { "default": { "fontSize": {fhd:33,hd:22} diff --git a/docs/REFERENCES/scenegraph/typographic-nodes/font.md b/docs/REFERENCES/scenegraph/typographic-nodes/font.md index 16bccb55..e7edc467 100644 --- a/docs/REFERENCES/scenegraph/typographic-nodes/font.md +++ b/docs/REFERENCES/scenegraph/typographic-nodes/font.md @@ -58,7 +58,7 @@ Below is the list of all the possible system font values: The font can also be specified in BrightScript, for example: -``` +```brightscript label = CreateObject("roSGNode", "Label") font = CreateObject("roSGNode", "Font") font.uri = "pkg:/fonts/font.ttf" diff --git a/docs/REFERENCES/scenegraph/xml-elements/script.md b/docs/REFERENCES/scenegraph/xml-elements/script.md index c01b87d6..cc30869f 100644 --- a/docs/REFERENCES/scenegraph/xml-elements/script.md +++ b/docs/REFERENCES/scenegraph/xml-elements/script.md @@ -45,7 +45,7 @@ Here's an example of a BrightScript function that creates a component named Stop **BrightScript component creation** -``` +```brightscript function createStopwatch(parent as object) as object stopWatch = m.top.createChild("StopWatch") stopWatch.translation = [100, 200] diff --git a/docs/SPECIFICATIONS/media/content-protection.md b/docs/SPECIFICATIONS/media/content-protection.md index f31dea24..b9591ebf 100644 --- a/docs/SPECIFICATIONS/media/content-protection.md +++ b/docs/SPECIFICATIONS/media/content-protection.md @@ -28,7 +28,7 @@ next: **Setup ContentNode and set to Video node:** -``` +```brightscript contentNode = createObject("roSGNode", "contentNode") contentNode.streamFormat = "smooth" contentNode.url = "wwww.myvideo.com/content.ism" @@ -42,7 +42,7 @@ If your PlayReady implementation requires custom request data, `encodingType` and `encodingKey` should be formatted like the following: -``` +```brightscript contentNode = createObject("roSGNode", "contentNode") contentNode.streamFormat = "ism" contentNode.url = "wwww.myvideo.com/content.ism" @@ -81,14 +81,14 @@ As of [Roku OS 9.3](doc:release-notes#roku-os-93), support for Verimatrix DRM ha **Required Roku manifest entries:** -``` +```text requires_verimatrix_drm=1 requires_verimatrix_version=1.0 ``` **Configure DRM parameters in an roAssociativeArray:** -``` +```brightscript drmParams = createObject("roAssociativeArray") drmParams.name = "Verimatrix" drmParams.authDomain = "auth-value-from-streaming-provider" @@ -97,7 +97,7 @@ drmParams.serializationUrl = "hostname-url-from-streaming-provider" **Setup ContentNode and set to Video node:** -``` +```brightscript contentNode = createObject("roSGNode", "contentNode") contentNode.streamFormat = "hls" contentNode.url = "wwww.myvideo.com/content.m3u8" diff --git a/docs/SPECIFICATIONS/media/index.md b/docs/SPECIFICATIONS/media/index.md index 5f6422d5..9d1c3126 100644 --- a/docs/SPECIFICATIONS/media/index.md +++ b/docs/SPECIFICATIONS/media/index.md @@ -358,7 +358,7 @@ There are several conditions that must be checked to see if 4K UHD content can b - (Optional) Check if the device decrypts within a trusted execution environment (TEE). -``` +```brightscript function CanPlay4K() as Boolean dev_info = CreateObject("roDeviceInfo") hdmi_status = CreateObject("roHdmiStatus") @@ -399,7 +399,7 @@ end function HDR10 playback requires HDMI version 2.0a. HDCP version 2.2, and an HDR10 capable player and display. Apps can check if the Roku device and connected display support HDR10 with **GetDisplayProperties().hdr10** field of the [roDeviceInfo](doc:ifdeviceinfo) component. -``` +```brightscript function canPlayHDR() as Boolean dev_info = createObject("roDeviceInfo") return dev_info.getDisplayProperties().hdr10 diff --git a/docs/THE ROKU CHANNEL/video-on-demand/delivery/index.md b/docs/THE ROKU CHANNEL/video-on-demand/delivery/index.md index 8b98a361..312fa094 100644 --- a/docs/THE ROKU CHANNEL/video-on-demand/delivery/index.md +++ b/docs/THE ROKU CHANNEL/video-on-demand/delivery/index.md @@ -885,7 +885,7 @@ Roku is using Apache [xmlbeans](https://xmlbeans.apache.org/download/index.html) **Example response** -``` +```text XMLBEANS_LIB=./../lib ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console... /path/to/file/directory /MEC_SAMPLE_123456789.xml valid