From 6d8084f40e3801957e9e9fcac681e01d51f90646 Mon Sep 17 00:00:00 2001
From: catloversg <152669316+catloversg@users.noreply.github.com>
Date: Mon, 21 Oct 2024 10:37:42 +0700
Subject: [PATCH] MISC: Improve tutorial, documentation and discoverability of
NS API documentation (#1697)
---
README.md | 5 +++--
src/ScriptEditor/ui/ScriptEditorRoot.tsx | 2 +-
src/ScriptEditor/ui/Toolbar.tsx | 7 ++-----
.../InteractiveTutorialRoot.tsx | 13 ++++++++----
src/ui/MD/a.tsx | 12 ++++++++++-
src/ui/React/NsApiDocumentationLink.tsx | 21 +++++++++++++++++++
6 files changed, 47 insertions(+), 13 deletions(-)
create mode 100644 src/ui/React/NsApiDocumentationLink.tsx
diff --git a/README.md b/README.md
index 3523a2d7b..9633020a0 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,10 @@ See the [frequently asked questions](./doc/FAQ.md) for more information . To dis
# Documentation
-The game's official documentation can be found in-game.
+There are 2 types of documentation:
-The [in-game documentation](./markdown/bitburner.md) is generated from the [TypeScript definitions](./src/ScriptEditor/NetscriptDefinitions.d.ts).
+- In-game documentation: It can be found in the Documentation tab. This is the best place to get up-to-date information. You can also read the web version at https://github.com/bitburner-official/bitburner-src/blob/stable/src/Documentation/doc/index.md.
+- NS API documentation: It's generated from the [TypeScript definitions](./src/ScriptEditor/NetscriptDefinitions.d.ts). You can read it at https://github.com/bitburner-official/bitburner-src/blob/stable/markdown/bitburner.md.
Anyone is welcome to contribute to the documentation by editing the [source
files](/src/Documentation/doc) and then making a pull request with your contributions.
diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx
index eb0b8962a..beb311d72 100644
--- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx
+++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx
@@ -87,7 +87,7 @@ function Root(props: IProps): React.ReactElement {
}
const cleanCode = currentScript.code.replace(/\s/g, "");
const ns1 = "while(true){hack('n00dles');}";
- const ns2 = `exportasyncfunctionmain(ns){while(true){awaitns.hack('n00dles');}}`;
+ const ns2 = `/**@param{NS}ns*/exportasyncfunctionmain(ns){while(true){awaitns.hack("n00dles");}}`;
if (!cleanCode.includes(ns1) && !cleanCode.includes(ns2)) {
dialogBoxCreate("Please copy and paste the code from the tutorial!");
return;
diff --git a/src/ScriptEditor/ui/Toolbar.tsx b/src/ScriptEditor/ui/Toolbar.tsx
index 9bf1a2583..61e971e00 100644
--- a/src/ScriptEditor/ui/Toolbar.tsx
+++ b/src/ScriptEditor/ui/Toolbar.tsx
@@ -3,7 +3,6 @@ import * as monaco from "monaco-editor";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
-import Link from "@mui/material/Link";
import Table from "@mui/material/Table";
import TableCell from "@mui/material/TableCell";
import TableRow from "@mui/material/TableRow";
@@ -22,7 +21,7 @@ import { useBoolean } from "../../ui/React/hooks";
import { Settings } from "../../Settings/Settings";
import { OptionsModal, OptionsModalProps } from "./OptionsModal";
import { useScriptEditorContext } from "./ScriptEditorContext";
-import { getNsApiDocumentationUrl } from "../../utils/StringHelperFunctions";
+import { NsApiDocumentationLink } from "../../ui/React/NsApiDocumentationLink";
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
@@ -71,9 +70,7 @@ export function Toolbar({ editor, onSave }: IProps) {
Terminal (Ctrl/Cmd + b)
-
- NS API documentation
-
+
{
}
@@ -352,6 +354,9 @@ export function InteractiveTutorialRoot(): React.ReactElement {
continuously hack the n00dles server.
+ To access , press the link at the bottom.
+
+
To save and close the script editor, press the button at the bottom.
>
diff --git a/src/ui/MD/a.tsx b/src/ui/MD/a.tsx
index 80720ba83..5ee0814a2 100644
--- a/src/ui/MD/a.tsx
+++ b/src/ui/MD/a.tsx
@@ -4,6 +4,7 @@ import { useNavigator } from "../React/Documentation";
import { CorruptableText } from "../React/CorruptableText";
import { Player } from "@player";
import { getNsApiDocumentationUrl } from "../../utils/StringHelperFunctions";
+import { Settings } from "../../Settings/Settings";
export const isSpoiler = (title: string): boolean => title.includes("advanced/") && Player.sourceFileLvl(1) === 0;
@@ -22,7 +23,16 @@ export const A = (props: React.PropsWithChildren<{ href?: string }>): React.Reac
href = getNsApiDocumentationUrl();
}
return (
-
+
{props.children}
);
diff --git a/src/ui/React/NsApiDocumentationLink.tsx b/src/ui/React/NsApiDocumentationLink.tsx
new file mode 100644
index 000000000..786516363
--- /dev/null
+++ b/src/ui/React/NsApiDocumentationLink.tsx
@@ -0,0 +1,21 @@
+import React from "react";
+import { Link } from "@mui/material";
+import { getNsApiDocumentationUrl } from "../../utils/StringHelperFunctions";
+import { Settings } from "../../Settings/Settings";
+
+export function NsApiDocumentationLink(): React.ReactElement {
+ return (
+
+ NS API documentation
+
+ );
+}