DOCS: Add printRaw and tprintRaw docs (#663)

This commit is contained in:
Snarling 2023-07-07 18:23:26 -04:00 committed by GitHub
parent 3981f72149
commit 006fbd528f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 128 additions and 22 deletions

@ -84,7 +84,7 @@
| [Player](./bitburner.player.md) | |
| [ProcessInfo](./bitburner.processinfo.md) | A single process on a server. |
| [Product](./bitburner.product.md) | Product in a warehouse |
| [ReactElement](./bitburner.reactelement.md) | A stand-in for the real React.ReactElement, which API-extractor doesn't know about. Don't try to create one of these by hand; use React.createElement(). |
| [ReactElement](./bitburner.reactelement.md) | A stand-in for the real React.ReactElement. Use React.createElement to make these. See [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation. |
| [RecentScript](./bitburner.recentscript.md) | |
| [ReputationFormulas](./bitburner.reputationformulas.md) | Reputation formulas |
| [ResetInfo](./bitburner.resetinfo.md) | Various info about resets |
@ -125,6 +125,7 @@
| [FilenameOrPID](./bitburner.filenameorpid.md) | |
| [NSEnums](./bitburner.nsenums.md) | |
| [PortData](./bitburner.portdata.md) | |
| [ReactNode](./bitburner.reactnode.md) | <p>A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reactelement.md) is rendered dynamically with React. number and string are displayed directly. boolean, null, and undefined are ignored and not rendered. An array of ReactNodes will display all members of that array sequentially.</p><p>Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.</p> |
| [ScriptArg](./bitburner.scriptarg.md) | |
| [SleeveBladeburnerTask](./bitburner.sleevebladeburnertask.md) | |
| [SleeveClassTask](./bitburner.sleeveclasstask.md) | |

@ -137,6 +137,7 @@ export async function main(ns) {
| [peek(portNumber)](./bitburner.ns.peek.md) | Get a copy of the data from a port without popping it. |
| [print(args)](./bitburner.ns.print.md) | Prints one or more values or variables to the scripts logs. |
| [printf(format, args)](./bitburner.ns.printf.md) | Prints a formatted string to the scripts logs. |
| [printRaw(node)](./bitburner.ns.printraw.md) | Prints a ReactNode to the script logs. |
| [prompt(txt, options)](./bitburner.ns.prompt.md) | Prompt the player with an input modal. |
| [ps(host)](./bitburner.ns.ps.md) | List running scripts on a server. |
| [purchaseServer(hostname, ram)](./bitburner.ns.purchaseserver.md) | Purchase a server. |
@ -163,6 +164,7 @@ export async function main(ns) {
| [toast(msg, variant, duration)](./bitburner.ns.toast.md) | Queue a toast (bottom-right notification). |
| [tprint(args)](./bitburner.ns.tprint.md) | Prints one or more values or variables to the Terminal. |
| [tprintf(format, values)](./bitburner.ns.tprintf.md) | Prints a raw value or a variable to the Terminal. |
| [tprintRaw(node)](./bitburner.ns.tprintraw.md) | Prints a ReactNode to the terminal. |
| [tryWritePort(portNumber, data)](./bitburner.ns.trywriteport.md) | Attempt to write to a port. |
| [upgradePurchasedServer(hostname, ram)](./bitburner.ns.upgradepurchasedserver.md) | Upgrade a purchased server's RAM. |
| [vsprintf(format, args)](./bitburner.ns.vsprintf.md) | Format a string with an array of arguments. |

@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [printRaw](./bitburner.ns.printraw.md)
## NS.printRaw() method
Prints a ReactNode to the script logs.
**Signature:**
```typescript
printRaw(node: ReactNode): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| node | [ReactNode](./bitburner.reactnode.md) | The react node to be printed. |
**Returns:**
void
## Remarks
RAM cost: 0 GB
See [ReactNode](./bitburner.reactnode.md) type for the acceptable values.

@ -9,14 +9,14 @@ Set the title of the tail window of a script.
**Signature:**
```typescript
setTitle(title: string | ReactElement, pid?: number): void;
setTitle(title: string | ReactNode, pid?: number): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| title | string \| [ReactElement](./bitburner.reactelement.md) | |
| title | string \| [ReactNode](./bitburner.reactnode.md) | |
| pid | number | _(Optional)_ Optional. PID of the script having its tail closed. If omitted, the current script is used. |
**Returns:**
@ -35,5 +35,5 @@ If the pid is unspecified, it will modify the current scripts logs.
Otherwise, the pid argument can be used to change the logs from another script.
It is possible to pass a React Element instead of a string. Get these by calling React.createElement() with appropriate parameters. You should either know or be willing to learn about the React UI library if you go down this route, and there will likely be rough edges.
It is possible to pass any React Node instead of a string. See [ReactElement](./bitburner.reactelement.md) and [ReactNode](./bitburner.reactnode.md) types for additional info.

@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md) &gt; [tprintRaw](./bitburner.ns.tprintraw.md)
## NS.tprintRaw() method
Prints a ReactNode to the terminal.
**Signature:**
```typescript
tprintRaw(node: ReactNode): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| node | [ReactNode](./bitburner.reactnode.md) | The react node to be printed. |
**Returns:**
void
## Remarks
RAM cost: 0 GB
See [ReactNode](./bitburner.reactnode.md) type for the acceptable values.

@ -4,7 +4,7 @@
## ReactElement interface
A stand-in for the real React.ReactElement, which API-extractor doesn't know about. Don't try to create one of these by hand; use React.createElement().
A stand-in for the real React.ReactElement. Use React.createElement to make these. See [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.
**Signature:**

@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [ReactNode](./bitburner.reactnode.md)
## ReactNode type
A stand-in for the real React.ReactNode. A [ReactElement](./bitburner.reactelement.md) is rendered dynamically with React. number and string are displayed directly. boolean, null, and undefined are ignored and not rendered. An array of ReactNodes will display all members of that array sequentially.
Use React.createElement to make the ReactElement type, see [creating an element without jsx](https://react.dev/reference/react/createElement#creating-an-element-without-jsx) from the official React documentation.
**Signature:**
```typescript
type ReactNode = ReactElement | string | number | null | undefined | boolean | ReactNode[];
```
**References:** [ReactElement](./bitburner.reactelement.md)<!-- -->, [ReactNode](./bitburner.reactnode.md)

@ -1767,6 +1767,12 @@ export const ns: InternalAPI<NSFull> = {
const name = helpers.string(ctx, "name", _name);
return getRamCost(...name.split("."));
},
tprintRaw: () => (value) => {
Terminal.printRaw(wrapUserNode(value));
},
printRaw: (ctx) => (value) => {
ctx.workerScript.print(wrapUserNode(value));
},
flags: Flags,
...NetscriptExtra(),
};

@ -3,8 +3,7 @@ import { Exploit } from "../Exploits/Exploit";
import * as bcrypt from "bcryptjs";
import { Apr1Events as devMenu } from "../ui/Apr1";
import { InternalAPI } from "../Netscript/APIWrapper";
import { helpers, wrapUserNode } from "../Netscript/NetscriptHelpers";
import { Terminal } from "../Terminal";
import { helpers } from "../Netscript/NetscriptHelpers";
import { RamCostConstants } from "../Netscript/RamCostGenerator";
export interface INetscriptExtra {
@ -16,8 +15,6 @@ export interface INetscriptExtra {
bypass(doc: Document): void;
alterReality(): void;
rainbow(guess: string): void;
tprintRaw(value: React.ReactNode): void;
printRaw(value: React.ReactNode): void;
}
export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
@ -66,11 +63,5 @@ export function NetscriptExtra(): InternalAPI<INetscriptExtra> {
Player.giveExploit(Exploit.INeedARainbow);
return true;
},
tprintRaw: () => (value) => {
Terminal.printRaw(wrapUserNode(value));
},
printRaw: (ctx) => (value) => {
ctx.workerScript.print(wrapUserNode(value));
},
};
}

@ -183,8 +183,21 @@ interface TailProperties {
/**
* @public
* A stand-in for the real React.ReactElement, which API-extractor doesn't know about.
* Don't try to create one of these by hand; use React.createElement().
* A stand-in for the real React.ReactNode.
* A {@link ReactElement} is rendered dynamically with React.
* number and string are displayed directly.
* boolean, null, and undefined are ignored and not rendered.
* An array of ReactNodes will display all members of that array sequentially.
*
* Use React.createElement to make the ReactElement type, see {@link https://react.dev/reference/react/createElement#creating-an-element-without-jsx | creating an element without jsx} from the official React documentation.
*/
type ReactNode = ReactElement | string | number | null | undefined | boolean | ReactNode[];
/**
* @public
* A stand-in for the real React.ReactElement.
* Use React.createElement to make these.
* See {@link https://react.dev/reference/react/createElement#creating-an-element-without-jsx | creating an element without jsx} from the official React documentation.
*/
interface ReactElement {
type: string | ((props: any) => ReactElement | null) | (new (props: any) => object);
@ -4919,6 +4932,15 @@ export interface NS {
*/
print(...args: any[]): void;
/** Prints a ReactNode to the script logs.
* @remarks
* RAM cost: 0 GB
*
* See {@link ReactNode} type for the acceptable values.
*
* @param node - The react node to be printed. */
printRaw(node: ReactNode): void;
/**
* Prints a formatted string to the scripts logs.
* @remarks
@ -4957,6 +4979,15 @@ export interface NS {
*/
tprint(...args: any[]): void;
/** Prints a ReactNode to the terminal.
* @remarks
* RAM cost: 0 GB
*
* See {@link ReactNode} type for the acceptable values.
*
* @param node - The react node to be printed. */
tprintRaw(node: ReactNode): void;
/**
* Prints a raw value or a variable to the Terminal.
* @remarks
@ -5149,14 +5180,12 @@ export interface NS {
*
* Otherwise, the pid argument can be used to change the logs from another script.
*
* It is possible to pass a React Element instead of a string. Get these by calling
* React.createElement() with appropriate parameters. You should either know
* or be willing to learn about the React UI library if you go down this
* route, and there will likely be rough edges.
* It is possible to pass any React Node instead of a string.
* See {@link ReactElement} and {@link ReactNode} types for additional info.
*
* @param pid - Optional. PID of the script having its tail closed. If omitted, the current script is used.
*/
setTitle(title: string | ReactElement, pid?: number): void;
setTitle(title: string | ReactNode, pid?: number): void;
/**
* Get the list of servers connected to a server.