diff --git a/.gitignore b/.gitignore index f3a4a092..8c08e429 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ build/ .idea -.vscode \ No newline at end of file +.vscode/* +!.vscode/extensions.json +!.vscode/tasks.json +!.vscode/settings.json diff --git a/.ignore-files.txt b/.prettierignore similarity index 55% rename from .ignore-files.txt rename to .prettierignore index 0518c836..f5cf12eb 100644 --- a/.ignore-files.txt +++ b/.prettierignore @@ -1,2 +1,2 @@ docs/dependencies.md -docs/services.md +docs/services.md \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..eb90c787 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "davidanson.vscode-markdownlint", + "esbenp.prettier-vscode", + "jebbs.plantuml", + "valentjn.vscode-ltex", + "yzhang.markdown-all-in-one", + "jebbs.markdown-extended" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..80ebb39f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,27 @@ +{ + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "markdownExtended.disabledPlugins": "table-of-contents,footnote,abbr,deflist,sup,sub,checkbox,attrs,kbd,underline,multimd-table,container,mark", + "ltex.language": "en-GB", + "ltex.checkFrequency": "edit", + // This could cause more false positives + "ltex.additionalRules.enablePickyRules": true, + "ltex.hiddenFalsePositives": { + "en-GB": [ + // nodecg-io will always be written lowercease + "{'rule': 'UPPERCASE_SENTENCE_START', 'sentence': '^nodecg-io'}", + // Admonition markers are not recognised by the Markdown parser of LTeX + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^ATTENTION'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^CAUTION'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^DANGER'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^ERROR'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^EXAMPLE'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^HINT'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^IMPORTANT'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^NOTE'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^TIP'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^WARNING'}", + "{'rule': 'PUNCTUATION_PARAGRAPH_END', 'sentence': '^ADMONITION'}" + ] + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..602752f6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,51 @@ +{ + // See https://code.visualstudio.com/docs/editor/tasks + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "mkdocs serve locally", + "detail": "mkdocs serve", + "type": "shell", + "command": "mkdocs serve", + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "dependsOn": [ + "npm: format", + "npm: lint" + ] + }, + { + "type": "npm", + "script": "format", + "problemMatcher": [], + "label": "npm: format", + "detail":"prettier -w **.md", + "group": "test", + "presentation": { + "reveal": "never", + "panel": "shared", + "revealProblems": "onProblem" + }, + }, + { + "type": "npm", + "script": "lint", + "problemMatcher": [], + "label": "npm: lint", + "detail": "markdownlint -p .prettierignore .", + "group": "test", + "presentation": { + "reveal": "never", + "panel": "shared", + "revealProblems": "onProblem" + } + } + ] +} \ No newline at end of file diff --git a/docs/contribute/contribute.md b/docs/contribute/contribute.md index bca48316..171d1f5e 100644 --- a/docs/contribute/contribute.md +++ b/docs/contribute/contribute.md @@ -1,16 +1,23 @@ # How to contribute -There are many ways to contribute to nodecg-io: logging bugs, submitting pull requests, reporting issues, and creating suggestions. - -First you'll need an installation of nodecg-io. Please refer to the [installation guide](../getting_started/install.md) and create a development installation. -The CLI asks you whether you want to clone the documentation. It's highly recommended that you do that and update the documentation as you add new services or features. -To be able to create Pull Requests you should fork the corresponding repositories and add them as a remote (update URL for e.g., documentation repository): +There are many ways to contribute to nodecg-io: logging bugs, submitting pull +requests, reporting issues, and creating suggestions. You can also contribute to +this [documentation](docs_setup.md). + +First you'll need an installation of nodecg-io. Please refer to the +[installation guide](../getting_started/install.md) and create a development +installation. The CLI asks you whether you want to clone the documentation. It's +highly recommended that you do that and update the documentation as you add new +services or features. To be able to create Pull Requests you should fork the +corresponding repositories and add them as a remote (update URL for e.g., +documentation repository): ```shell git remote add fork https://github.com/[YOUR_USERNAME]/nodecg-io.git ``` -Then you can create a new branch, do your changes, create commits and publish the branch to your fork using the following command: +Then you can create a new branch, do your changes, create commits and publish +the branch to your fork using the following command: ```shell git push fork my-branch @@ -20,30 +27,36 @@ git push fork my-branch ### VS Code -In Visual Studio Code you can start the build task with -Ctrl+Shift+B (CMD+Shift+B on macOS). -The incremental builder will do an initial full build. -The watch builder will watch for file changes and compile those changes incrementally, giving you a fast, iterative coding experience. -It will even stay running in the background if you close VS Code. -You can resume it by starting the build task with -Ctrl+Shift+B (CMD+Shift+B) again. -You can kill the build task by pressing Ctrl+D in the task terminal (CMD+D) on macOS. -Errors and warnings will be shown in the status bar at the bottom left of the editor. You can view the error list using `View | Errors and Warnings` or pressing Ctrl+P and then ! (CMD+P and ! on macOS) +In Visual Studio Code you can start the build task with Ctrl + +Shift + B (CMD + Shift + +B on macOS). The incremental builder will do an initial full build. +The watch builder will watch for file changes and compile those changes +incrementally, giving you a fast, iterative coding experience. It will even stay +running in the background if you close VS Code. You can resume it by starting +the build task with Ctrl + Shift + B +(CMD + Shift + B) again. +You can kill the build task by pressing Ctrl + D in the +task terminal (CMD + D) on macOS. +Errors and warnings will be shown in the status bar at the bottom left of the +editor. You can view the error list using `View | Errors and Warnings` or +pressing Ctrl + P and then ! (or +CMD + P and ! on macOS). ### Terminal You can also use you terminal to build nodecg-io: -``` +```shell cd path/to/nodecg-io npm run build ``` -To do a full rebuild instead of just an incremental build you can use `npm run rebuild`. +To do a full rebuild instead of just an incremental build you can use +`npm run rebuild`. The watch builder can be activated here too: -``` +```shell cd path/to/nodecg-io npm run watch ``` @@ -54,19 +67,26 @@ To test the changes you simply need to start/restart NodeCG. ## Adding dependencies to packages -This project uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces/) to manage our monorepo, and most importantly link all our packages together. -Because of linking you should not use `npm install xyz --save` to add dependencies because npm can't get the development version of internal packages like `nodecg-io-core`. Doing so will result in an error and break the link. -Instead, you should edit the `package.json` directly using a text editor and the run `npm install` in the repository root. +This project uses +[npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces/) to manage +our monorepo, and most importantly link all our packages together. Because of +linking you should not use `npm install xyz --save` to add dependencies because +npm can't get the development version of internal packages like +`nodecg-io-core`. Doing so will result in an error and break the link. Instead, +you should edit the `package.json` directly using a text editor and the run +`npm install` in the repository root. ## Open a Pull Request -Once you have implemented your feature or fixed a bug push it to your fork and start a Pull Request. +Once you have implemented your feature or fixed a bug push it to your fork and +start a Pull Request. ## Merge Upstream Changes -Occasionally you will want to merge changes in the upstream repository (the official code repo) with your fork. +Occasionally you will want to merge changes in the upstream repository (the +official code repo) with your fork. -``` +```shell cd path/to/nodecg-io git checkout master git pull https://github.com/codeoverflow-org/nodecg-io master @@ -74,16 +94,31 @@ git pull https://github.com/codeoverflow-org/nodecg-io master Manage any merge conflicts, commit them, and then push them to your fork. -You may also occasionally need to merge upstream master in a pull request. To do that make the above to update your local master, and then merge your local master into your PR branch. +You may also occasionally need to merge upstream master in a pull request. To do +that make the above to update your local master, and then merge your local +master into your PR branch. ### Where to Contribute -After cloning and building the repo, check out the [issues list](https://github.com/codeoverflow-org/nodecg-io/issues). Issues labelled [`help wanted`](https://github.com/codeoverflow-org/nodecg-io/labels/help%20wanted) are good issues to submit a PR for. Issues labelled [`good first issue`](https://github.com/codeoverflow-org/nodecg-io/labels/good%20first%20issue) are great candidates to pick up if you are in the code for the first time. If you are contributing significant changes, please discuss with the assignee of the issue first before starting to work on the issue. +After cloning and building the repo, check out the +[issues list](https://github.com/codeoverflow-org/nodecg-io/issues). Issues +labelled +[help wanted](https://github.com/codeoverflow-org/nodecg-io/labels/help%20wanted) +are good issues to submit a PR for. Issues labelled +[good first issue](https://github.com/codeoverflow-org/nodecg-io/labels/good%20first%20issue) +are great candidates to pick up if you are in the code for the first time. If +you are contributing significant changes, please discuss with the assignee of +the issue first before starting to work on the issue. You may also contribute to +this [documentation](docs_setup.md). ## Suggestions -We're also interested in your feedback. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly. +We're also interested in your feedback. You can submit a suggestion or feature +request through the issue tracker. To make this process more effective, we're +asking that these include more information to help define them more clearly. ## Discussion Etiquette -In order to keep the conversation clear and transparent, please limit discussion to English and keep things on topic with the issue. Be considerate to others and try to be courteous and professional at all times. +In order to keep the conversation clear and transparent, please limit discussion +to English and keep things on topic with the issue. Be considerate to others and +try to be courteous and professional at all times. diff --git a/docs/contribute/create_sample.md b/docs/contribute/create_sample.md index 696ebf31..6f2e7c1c 100644 --- a/docs/contribute/create_sample.md +++ b/docs/contribute/create_sample.md @@ -1,75 +1,85 @@ # Create a sample bundle -A sample should have the same name as the service, but it may include a short description in the name after the service name as well. -E.g. `twitch-chat` or `obs-scenelist`. +A sample should have the same name as the service, but it may include a short +description in the name after the service name as well. E.g. `twitch-chat` or +`obs-scenelist`. -Create a folder in `samples` named after the sample and add a `package.json` and a `tsconfig.json`: +Create a folder in `samples` named after the sample and add a `package.json` and +a `tsconfig.json`: -`package.json` +=== "package.json" -```json -{ - "name": "", - "private": true, - "version": "0.2.0", - "nodecg": { - "compatibleRange": "^1.1.1", - "bundleDependencies": { - "nodecg-io-": "^0.2.0" + ```json + { + "name": "", + "private": true, + "version": "0.2.0", + "nodecg": { + "compatibleRange": "^1.1.1", + "bundleDependencies": { + "nodecg-io-": "^0.2.0" + } + }, + "scripts": { + "build": "tsc -b", + "watch": "tsc -b -w", + "clean": "tsc -b --clean" + }, + "license": "MIT", + "dependencies": { + "nodecg-io-": "^0.2.0", + "nodecg-io-core": "^0.2.0", + "@types/node": "^15.0.2", + "nodecg-types": "^1.8.2", + "typescript": "^4.2.4" } - }, - "scripts": { - "build": "tsc -b", - "watch": "tsc -b -w", - "clean": "tsc -b --clean" - }, - "license": "MIT", - "dependencies": { - "nodecg-io-": "^0.2.0", - "nodecg-io-core": "^0.2.0", - "@types/node": "^15.0.2", - "nodecg-types": "^1.8.2", - "typescript": "^4.2.4" } -} -``` + ``` -`tsconfig.json` +=== "tsconfig.json" -```json -{ - "extends": "../../tsconfig.common.json", - "references": [ - { - "path": "../../nodecg-io-core" - }, - { - "path": "../../services/nodecg-io-" - } - ] -} -``` + ```json + { + "extends": "../../tsconfig.common.json", + "references": [ + { + "path": "../../nodecg-io-core" + }, + { + "path": "../../services/nodecg-io-" + } + ] + } + ``` + +Now you can create a file called `extension/index.ts`. Here's a template. Make +sure you replace all the comments with your own code. -Now you can create a file called `extension/index.ts`. Here's a template. Make sure you replace all the comments with your own code. +=== "index.ts" -```typescript -import { NodeCG } from "nodecg-types/types/server"; -import { requireService } from "nodecg-io-core"; -import { TheServicesExportedClient } from "nodecg-io-"; + ```typescript + import { NodeCG } from "nodecg-types/types/server"; + import { requireService } from "nodecg-io-core"; + import { TheServicesExportedClient } from "nodecg-io-"; -module.exports = function (nodecg: NodeCG) { - nodecg.log.info("Sample bundle for started"); + module.exports = function (nodecg: NodeCG) { + nodecg.log.info("Sample bundle for started"); - const service = requireService(nodecg, ""); - service?.onAvailable((client) => { - nodecg.log.info(" client has been updated."); + const service = requireService( + nodecg, + "" + ); + service?.onAvailable((client) => { + nodecg.log.info(" client has been updated."); - // TODO do something with the client to demonstrate the functionality. - }); + // TODO do something with the client to demonstrate the functionality. + }); - service?.onUnavailable(() => nodecg.log.info(" client has been unset.")); -}; -``` + service?.onUnavailable(() => + nodecg.log.info(" client has been unset.") + ); + }; + ``` ## Next steps diff --git a/docs/contribute/create_service.md b/docs/contribute/create_service.md index 5b629642..25c2f9e4 100644 --- a/docs/contribute/create_service.md +++ b/docs/contribute/create_service.md @@ -1,27 +1,32 @@ # Create a service integration -This guide helps you to create a service integration such as _twitch-chat_ or _discord_ +This guide helps you to create a service integration such as _twitch-chat_ or +_discord_ ## Find a JavaScript library -Go to [npmjs.com](https://www.npmjs.com/) and look whether there's already a package that wraps around the API of your service. If there's no such package, you need to create one yourself. This process is not described here. You may read the +Go to [npmjs.com](https://www.npmjs.com/) and look whether there's already a +package that wraps around the API of your service. If there's no such package, +you need to create one yourself. This is not described here. You may read the [“Contributing packages to the registry” from the npm Docs](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry). -## Create a service +## Create the service files -To create the service you can either use a premade Python 3 script in `.scripts/create-service.py`, or create the files manually. +To create the service you can either use a premade Python 3 script in +`.scripts/create-service.py`, or create the files manually. -## Using the script (recommended) +### Using the script (recommended) What this script does: - It creates all required files for a new nodecg-io service -- It copies version and dependency information (e.g., for typescript) from `noodecg-io-template` +- It copies version and dependency information (e.g., for typescript) from + `noodecg-io-template` -It'll also create a sample and the files for the docs -Requirements: +It'll also create a sample and the files for the docs Requirements: -- python3 in your PATH +- `python3` in your `$PATH` (see + [install page](https://wiki.python.org/moin/BeginnersGuide/Download)) - executed from root of nodecg-io repo The script waits for your input for each of those fields: @@ -35,148 +40,188 @@ Author url: Sample name: ``` -Now the script will rebuild your environment. +!!! INFO -## Create the files manually + Now the script will rebuild your environment. -From here you will have to replace: +### Create the files manually -- `YourServiceName` to your service's name in [PascalCase](https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md#class). -- `yourServiceName` to your service's name in [carmelCase](https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md#variable-and-function). -- `your-service-name` to your service's name with only lowercase and hyphens (`-`) for example: ws-server. +!!! NOTE -Now you need to create a package. You should call it `nodecg-io-your-service-name`. + From here you will have to replace: -First create a directory with that name in `/services/` and put file called `package.json` into it. + - `YourServiceName` to your service's name in [PascalCase](https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md#class). + - `yourServiceName` to your service's name in [carmelCase](https://github.com/basarat/typescript-book/blob/master/docs/styleguide/styleguide.md#variable-and-function). + - `your-service-name` to your service's name with only lowercase and + hyphens (`-`) for example: `ws-server`. + +Now you need to create a package. You should call it +`nodecg-io-your-service-name`. + +First create a directory with that name in `/services/` and put file called +`package.json` into it. Put the following into it: -```json -{ - "name": "nodecg-io-", - "version": "0.2.0", - "description": "", - "homepage": "https://nodecg.io/RELEASE/samples/", - "author": { - "name": "", - "url": "" - }, - "repository": { - "type": "git", - "url": "https://github.com/codeoverflow-org/nodecg-io.git", - "directory": "services/nodecg-io-" - }, - "files": ["**/*.js", "**/*.js.map", "**/*.d.ts", "*.json"], - "main": "extension", - "scripts": {}, - "keywords": ["nodecg-io", "nodecg-bundle"], - "nodecg": { - "compatibleRange": "^1.1.1", - "bundleDependencies": { - "nodecg-io-core": "^0.2.0" +=== "package.json" + + ```json + { + "name": "nodecg-io-", + "version": "0.2.0", + "description": "", + "homepage": "https://nodecg.io/RELEASE/samples/", + "author": { + "name": "", + "url": "" + }, + "repository": { + "type": "git", + "url": "https://github.com/codeoverflow-org/nodecg-io.git", + "directory": "services/nodecg-io-" + }, + "files": ["**/*.js", "**/*.js.map", "**/*.d.ts", "*.json"], + "main": "extension", + "scripts": {}, + "keywords": ["nodecg-io", "nodecg-bundle"], + "nodecg": { + "compatibleRange": "^1.1.1", + "bundleDependencies": { + "nodecg-io-core": "^0.2.0" + } + }, + "license": "MIT", + "devDependencies": { + "@types/node": "^15.0.2", + "nodecg-types": "^1.8.2", + "typescript": "^4.2.4" + }, + "dependencies": { + "nodecg-io-core": "^0.2.0", + "": "" } - }, - "license": "MIT", - "devDependencies": { - "@types/node": "^15.0.2", - "nodecg-types": "^1.8.2", - "typescript": "^4.2.4" - }, - "dependencies": { - "nodecg-io-core": "^0.2.0", - "": "" } -} -``` + ``` -Next you need to put a file called `tsconfig.json` next to your `package.json`. The `tsconfig.json` should look like this: +Next you need to put a file called `tsconfig.json` next to your `package.json`. +The `tsconfig.json` should look like this: -```json -{ - "extends": "../../tsconfig.common.json", - "references": [ - { - "path": "../../nodecg-io-core" - } - ] -} -``` +=== "tsconfig.json" + + ```json + { + "extends": "../../tsconfig.common.json", + "references": [ + { + "path": "../../nodecg-io-core" + } + ] + } + ``` Now run `npm install` in the repository root. ## Create a configuration schema -Next create a file called `your-service-name-schame.json`. This is a JSON schema file that indicates how the configuration for your service should be structured. If you need help here take a look at [this](https://json-schema.org/understanding-json-schema/) online resource and the schema-files of the other service implementations. +Next create a file called `your-service-name-schame.json`. This is a JSON schema +file that indicates how the configuration for your service should be structured. +If you need help here take a look at +[this](https://json-schema.org/understanding-json-schema/) online resource and +the schema-files of the other service implementations. ## Create the service -Create a file called `index.ts` in a folder called `extension` inside your service's directory. You can then paste the following code and fill in your code instead of the comments. - -```typescript -// TODO: Rename all occurrences of "YourServiceName" in PascalCase -// TODO: Rename all occurrences of "yourServiceName" in carmelCase -// TODO: Rename all occurrences of "your-service-name" with only lowercase and hyphens ( - ) - -import { NodeCG } from "nodecg-types/types/server"; -import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core"; -// TODO: Replace the "fake" service class with that found on npm etc. -import { ServiceClass } from "./"; - -interface YourServiceNameServiceConfig { - // TODO Fill in the values from your json schema here. The json - // schema will load into an instance of this. -} - -// ServiceClient ensures that you will provide a `getNativeClient` function that should give -// access to the underlying client from the library that you are using. -// TODO: if you want to provide simplifications for the service then make this -// type-alias a separate class in a separate file and directly implement those simplifications -// there. -// TODO: Replace the `ServiceClass` with the class of the package from step 1 -export type YourServiceNameServiceClient = ServiceClient; - -module.exports = (nodecg: NodeCG) => { - new YourServiceNameService(nodecg, "your-service-name", __dirname, "../your-service-name-schema.json").register(); -}; - -class YourServiceNameService extends ServiceBundle { - async validateConfig(config: YourServiceNameServiceConfig): Promise> { - // TODO You can validate your config here. If this gets called, the schema is correct. - // You should for example check whether oauth keys are valid and servers are online here - // If everything is good return 'emptySuccess()' - // If an error occurs return 'error()' - } +Create a file called `index.ts` in a folder called `extension` inside your +service's directory. You can then paste the following code and fill in your code +instead of the comments. + +=== "index.ts" + + ```typescript + // TODO: Rename all occurrences of "YourServiceName" in PascalCase + // TODO: Rename all occurrences of "yourServiceName" in carmelCase + // TODO: Rename all occurrences of "your-service-name" with only lowercase and hyphens ( - ) + + import { NodeCG } from "nodecg-types/types/server"; + import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core"; + // TODO: Replace the "fake" service class with that found on npm etc. + import { ServiceClass } from "./"; - async createClient(config: YourServiceNameServiceConfig): Promise> { - // TODO Here you should return a ServiceClient that is exposed to bundles. - // Or create a instance of your class if you have any simplifications and return that. - // If everything is good return 'success(client)' - // If an error occurs return 'error()' + interface YourServiceNameServiceConfig { + // TODO Fill in the values from your json schema here. The json + // schema will load into an instance of this. } - stopClient(client: YourServiceNameServiceClient): void { - // Here you should make sure you disconnect everything here (if possible). + // ServiceClient ensures that you will provide a `getNativeClient` function that should give + // access to the underlying client from the library that you are using. + // TODO: if you want to provide simplifications for the service then make this + // type-alias a separate class in a separate file and directly implement those simplifications + // there. + // TODO: Replace the `ServiceClass` with the class of the package from step 1 + export type YourServiceNameServiceClient = ServiceClient; + + module.exports = (nodecg: NodeCG) => { + new YourServiceNameService( + nodecg, + "your-service-name", + __dirname, + "../your-service-name-schema.json" + ).register(); + }; + + class YourServiceNameService extends ServiceBundle< + YourServiceNameServiceConfig, + YourServiceNameServiceClient + > { + async validateConfig( + config: YourServiceNameServiceConfig + ): Promise> { + // TODO You can validate your config here. If this gets called, the schema is correct. + // You should for example check whether oauth keys are valid and servers are online here + // If everything is good return 'emptySuccess()' + // If an error occurs return 'error()' + } + + async createClient( + config: YourServiceNameServiceConfig + ): Promise> { + // TODO Here you should return a ServiceClient that is exposed to bundles. + // Or create a instance of your class if you have any simplifications and return that. + // If everything is good return 'success(client)' + // If an error occurs return 'error()' + } + + stopClient(client: YourServiceNameServiceClient): void { + // Here you should make sure you disconnect everything here (if possible). + } } -} -``` + ``` + +!!! NOTE -Now run `npm run build` in the repository root, start NodeCG and test your service out. + Now run `npm run build` in the repository root, start NodeCG and test your service out. ## Next steps You could [create a sample bundle](create_sample.md) for your brand-new service. -If you don't do so, make sure you add a placeholder file called `.md` in `docs/samples` in your fork of the documentation. +If you don't do so, make sure you add a placeholder file called +`.md` in `docs/samples` in your fork of the documentation. The file should look like this: -```markdown - +=== "the-service-name.md" -## Using the sample bundle + ```markdown + -No sample bundle for service ``. -[You can help us and create one!](https://github.com/codeoverflow-org/nodecg-io/blob/master/docs/docs/contribute.md) -``` + ## Using the sample bundle + + No sample bundle for service ``. + [You can help us and create one!](https://github.com/codeoverflow-org/nodecg-io/blob/master/docs/docs/contribute.md) + ``` + +!!! ATTENTION -Do not remove the marker in the first line until there is a sample bundle, and it is documented there. Don't forget to add this file to `mkdocs.yml`. + Do not remove the marker in the first line until there is a sample bundle, + and it is documented there. Don't forget to add this file to `mkdocs.yml`. diff --git a/docs/contribute/docs_markdown.md b/docs/contribute/docs_markdown.md new file mode 100644 index 00000000..90bffd0b --- /dev/null +++ b/docs/contribute/docs_markdown.md @@ -0,0 +1,175 @@ +Our special mix of Markdown plugins: + +## [`plantuml-markdown`](https://github.com/mikitex70/plantuml-markdown) + +!!! EXAMPLE "Plant UML diagram" + + === "Markdown" + + ````markdown + ```plantuml format="svg" alt="My super diagram placeholder" width="400px" height="400px" + title Authentication Sequence + Alice -> Bob: calls + Alice <-- Bob: responds + ``` + ```` + + === "Output" + + ```plantuml format="svg" alt="My super diagram placeholder" width="400px" height="400px" + title Authentication Sequence + Alice -> Bob: calls + Alice <-- Bob: responds + ``` + +## [`codehilite`](https://python-markdown.github.io/extensions/code_hilite/) + +Syntax highlighting in fenced code blocks. + +!!! EXAMPLE "Syntax highlighting" + + === "Markdown" + + ````markdown + ```typescript + import { NodeCG } from "nodecg-types/types/server"; + module.exports = (nodecg: NodeCG) => { + new YourServiceNameService(nodecg, "your-service-name", __dirname, "../your-service-name-schema.json").register(); + }; + ``` + ```` + + === "Output" + + ```typescript + import { NodeCG } from "nodecg-types/types/server"; + module.exports = (nodecg: NodeCG) => { + new YourServiceNameService(nodecg, "your-service-name", __dirname, "../your-service-name-schema.json").register(); + }; + ``` + +## [`pymdownx.inlinehilite`](https://facelessuser.github.io/pymdown-extensions/extensions/inlinehilite/) + +!!! EXAMPLE "Inline Highlighted Code Example" + + === "Markdown" + + ```markdown + `` Here is some code: `#!py3 import pymdownx; pymdownx__version__`. + + The mock shebang will be treated like text here: ` #!js vartest = 0; `. `` + ``` + + === "Output" + + Here is some code: `#!py3 import pymdownx; pymdownx.__version__` + + The mock shebang will be treated like text here: ` #!js var test = 0; `. + +## [`pymdownx.superfences`](https://facelessuser.github.io/pymdown-extensions/extensions/superfences/) + +1. Allowing the nesting of fences under blockquotes, lists, or other block + elements. +2. Ability to specify custom fences to provide features like flowcharts, + sequence diagrams, or other custom blocks. +3. Allow disabling of indented code blocks in favour of only using the fenced + variant (off by default). +4. Experimental feature that preserves tabs within a code block instead of + converting them to spaces which is Python Markdown's default behaviour. + +## [`pymdownx.tabbed`](https://facelessuser.github.io/pymdown-extensions/extensions/tabbed/) + +!!! EXAMPLE "Example Tabs" + + === "Markdown" + + ```markdown + === "Tab 1" + + Markdown **content**. + + Multiple paragraphs. + + === "Tab 2" + + More Markdown **content**. + + - list item a + - list item b + ``` + + === "Output" + + === "Tab 1" + + Markdown **content**. + + Multiple paragraphs. + + === "Tab 2" + + More Markdown **content**. + + - list item a + - list item b + +## [`pymdownx.tasklist`](https://facelessuser.github.io/pymdown-extensions/extensions/tasklist/) + +GFM style task lists + +!!! EXAMPLE "Task lists" + + === "Markdown" + + ```markdown + - [X] item 1 + * [X] item A + * [ ] item B + more text + + [x] item a + + [ ] item b + + [x] item c + * [X] item C + - [ ] item 2 + - [ ] item 3 + ``` + + === "Output" + + - [X] item 1 + * [X] item A + * [ ] item B + more text + + [x] item a + + [ ] item b + + [x] item c + * [X] item C + - [ ] item 2 + - [ ] item 3 + +## [`admonition`](https://python-markdown.github.io/extensions/admonition/) + +> Possible types are: +> NOTE, SUMMARY, ABSTRACT, TLDR, INFO, TODO, TIP, HINT, SUCCESS, CHECK, DONE, +> QUESTION, HELP, FAQ, WARNING, ATTENTION, CAUTION, FAILURE, FAIL, MISSING, +> DANGER, ERROR, BUG, EXAMPLE, SNIPPET, QUOTE, CITE + +!!! EXAMPLE "Inline Highlighted Code Example" + + === "Markdown" + + ```markdown + !!! HINT "optional explicit title within double quotes" + + Any number of other indented markdown elements. + + This is the second paragraph. + ``` + + === "Output" + + !!! HINT "optional explicit title within double quotes" + + Any number of other indented markdown elements. + + This is the second paragraph. diff --git a/docs/contribute/docs_sample.md b/docs/contribute/docs_sample.md new file mode 100644 index 00000000..1130b6d2 --- /dev/null +++ b/docs/contribute/docs_sample.md @@ -0,0 +1,43 @@ +# Add your sample to the docs + +To document a sample bundle take a look at the name of the service the sample +bundle is for. If it's for example `nodecg-io-example` the documentation should +go into `docs/samples/example.md` in the doc's repository. There you should +include a step-by-step manual how to configure the service and get the bundle +running. + +!!! ATTENTION + + Don't forget to add the newly created Markdown file to `mkdocs.yml`. + +!!! NOTE + + When you create your documentation pull request, please include the ID of + your PR in the main repository in the description, so the documentation + will not be merged before the actual code. + +You should make this very detailed, so everyone gets it to work because a +super-good implementation is worth nothing if there's nobody who can use it. +Take a look at the [twitch sample bundle](../samples/twitch-chat.md). + +!!! NOTE + + We also have the getting started section and especally the + ["Try an included sample"](::/../../getting_started/try_example_bundle.md)-Guide, + so you can offload some of the documentation to stuff aready written there. + +## Guidelines + +> […] The sample docs should […] be centered around the service and not the +> sample […]. Writing what the sample does with the service and how it is named +> should be enough. +> Actually the +> [ChatOverflow docs](https://github.com/codeoverflow-org/chatoverflow-gh-pages) +> are a good example […]. +> Have a guide how to use the dashboard and then an entry for each service that +> describes what config it needs and where you can get tokens. Instead of a code +> snipped I would then explain what the sample does and link to it. +> +> ~ (daniel0611 27.02.2021 on +> [GitHub](https://github.com/codeoverflow-org/nodecg-io/issues/37#issuecomment-787054359)) +> _shortened by the author_ diff --git a/docs/contribute/docs_setup.md b/docs/contribute/docs_setup.md new file mode 100644 index 00000000..cb9f389a --- /dev/null +++ b/docs/contribute/docs_setup.md @@ -0,0 +1,80 @@ +nodecg-io has a steadily growing and improving documentation. We are using +[Markdown](https://en.wikipedia.org/wiki/Markdown) to describe the content and +[mkdocs](https://www.mkdocs.org/) for the deployment to the webpage +(). If you want to get to know the standard Markdown syntax, +take a look at this [guide](https://www.markdownguide.org/). We also use many +plugins, so you may take a look at a curated list of +[examples](docs_markdown.md) of the extended syntax. + +## Clone this repo + +If you installed the development version nodecg-io with the CLI, you may have +already cloned the `nodecg-io-docs` repository into the `docs` folder inside +nodecg-io directory. Then you will have to fork the official repo and add your +fork as a remote: + +```shell +git remote add (https://github.com//nodecg-io-docs.git) +``` + +Else clone your fork into a desired directory with: + +```shell +git clone https://github.com//nodecg-io-docs.git +``` + +## Repository structure + +```plain +|-- .github ................ CI workflows +|-- .vscode ................ VS Code specific configs +|-- docs ................... All files included in the documentation +| |-- assets ................ other files used (images) +| |-- contribute ............ Section on development and documentation +| |-- getting_started ....... Section on first use +| |-- samples ............... documentation for the sample bundles +| |-- dependencies.md ....... One huge UML diagram (auto generated) +| |-- index.md .............. Home screen of the documentation +| `-- services.md ........... Availabel Services (auto generated) +|-- .markdownlint.json ..... markdownlint config file +|-- .prettierrc.json ....... prettier (formatter) config file +`-- mkdocs.yml ............. mkdocs config file +``` + +## Install dependencies to use the preview + +You will need a Python 3 installed. You will also need to install `mkdocs` with +pip: + +```shell +pip install -r requirements.txt +``` + +Now you can serve the local version with: + +```shell +mkdocs serve +``` + +Now you can access it in your browser under . + +## Using VS Code + +### Extensions + +For the folks out there who are using VS Code to edit these documents you can +use the recommended extensions of this workspace by using the `@recommended ` +filter in the extensions panel. Those extensions will format (`Prettier`) and +lint (`markdownlint`) the markdown files, and live check many typos and grammar +(`LTeX`). Also, the built-in preview will parse more of our used syntax. + +### Tasks + +!!! NOTE + + You will need prettier and markdownlint installed in your path. + +You may also benefit from the preconfigured serve task. It can be accessed with +Ctrl + Shift + B (CMD + +Shift + B on macOS). This will format and lint the files +and then serve them to you. diff --git a/docs/contribute/sample_documentation.md b/docs/contribute/sample_documentation.md deleted file mode 100644 index 3f245963..00000000 --- a/docs/contribute/sample_documentation.md +++ /dev/null @@ -1,7 +0,0 @@ -# Add your sample to the docs - -To document a sample bundle take a look at the name of the service the sample bundle is for. If it's for example `nodecg-io-example` the documentation must go into `docs/samples/example.md` in the doc's repository. There you should include a step-by-step manual how to configure the service and get the bundle running. - -Don't forget to add the newly created Markdown file to `mkdocs.yml`. When you create your documentation pull request, please include the ID of your PR in the main repository in the description, so the documentation will not be merged before the actual code. - -You should make this very detailed, so everyone gets it to work because a super-good implementation is worth nothing if there's nobody who can use it. Take a look at the [twitch sample bundle](../samples/twitch-chat.md). diff --git a/docs/getting_started/configuration.md b/docs/getting_started/configuration.md index 56441a36..a13746c1 100644 --- a/docs/getting_started/configuration.md +++ b/docs/getting_started/configuration.md @@ -1,32 +1,48 @@ # Configuration -Since version `0.2.0` nodecg-io has a configuration feature to save some settings without needing to code something or log in. The configuration file for -this feature is at `cfg/nodecg-io-core.json` inside your nodecg installation. This file does not exist by default, you need to create it yourself. +Since version `0.2.0` nodecg-io has a configuration feature to save some +settings without needing to code something or log in. The configuration file for +this feature is at `cfg/nodecg-io-core.json` inside your NodeCG installation. +This file does not exist by default, you need to create it yourself. -The currently only thing you can configure is automatic login, but there may be more configurable options in the future. +The currently only thing you can configure is automatic login, but there may be +more configurable options in the future. ## Automatic login -Automatic login will automatically load nodecg-io when nodecg starts using the provided password. +Automatic login will automatically load nodecg-io when NodeCG starts using the +provided password. -Therefore, nodecg-io will be able to decrypt your configuration for your service instances and provide your bundles with service clients without you logging in to nodecg-io using the dashboard. -This is especially useful if you are running nodecg with nodecg-io on a server which may reboot from time to time to ensure that your bundles are always working without you needing to manually log in after each restart. +Therefore, nodecg-io will be able to decrypt your configuration for your service +instances and provide your bundles with service clients without you logging in +to nodecg-io using the dashboard. This is especially useful if you are running +NodeCG with nodecg-io on a server which may reboot from time to time to ensure +that your bundles are always working without you needing to manually log in +after each restart. -**Security warning:** Having both the encrypted configuration and your used password saved on disk defeats nodecg-io's data-at-rest encryption. -Any program that can read disk contents can access your credentials of any service instance. We discourage using this and if you really want to use it you should be extra cautious about which bundles you install. +!!! WARNING Security warning + + Having both the encrypted configuration and your used password saved on disk + defeats nodecg-io's data-at-rest encryption. + + Any program that can read disk contents can access your credentials of any + service instance. We discourage using this and if you really want to use it + you should be extra cautious about which bundles you install. Options of automatic login: - `enabled` (boolean) - Automatic login will be only enabled if this `enabled` option is set to `true`. - This option can be used to temporarily disable automatic login without needing to delete the whole automatic login configuration - and allows for easy re-enabling without needing to enter the password in the config again. + Automatic login will be only enabled if this `enabled` option is `true`. + This option can be used to temporarily disable automatic login without + needing to delete the whole automatic login configuration and allows for + easy re-enabling without needing to enter the password in the config again. - `password` (string) - This is the password that will be used to log in. It should be the password you use to log in to nodecg-io. - If this password is wrong an error will be logged after startup. + This is the password that will be used to log in. It should be the password + you use to log in to nodecg-io. If this password is wrong an error will be + logged after startup. Example config: diff --git a/docs/getting_started/create_new_bundle.md b/docs/getting_started/create_new_bundle.md index 212cd15c..4c5371b6 100644 --- a/docs/getting_started/create_new_bundle.md +++ b/docs/getting_started/create_new_bundle.md @@ -1,44 +1,67 @@ # Create your first bundle -To actually use nodecg-io you need to create a bundle. Here's a step-by-step guide to create one. +To actually use nodecg-io you need to create a bundle. Here's a step-by-step +guide to create one. -Think of what services your bundle needs. Take a look at the [service list](../services.md) if to see what services are available. If you need a service that is not yet available consider [creating it](../contribute/create_service.md). +Think of what services your bundle needs. Take a look at the +[service list](../services.md) if to see what services are available. If you +need a service that is not yet available consider +[creating it](../contribute/create_service.md). ## Create your bundle using the nodecg-io CLI -Automatically generating a bundle that uses nodecg-io requires that you have the nodecg-io CLI installed. A guide on how to do this is inside the [installation guide](./install.md). Also note that this currently only works when you have installed a release version, not development versions. +Automatically generating a bundle that uses nodecg-io requires that you have the +nodecg-io CLI installed. A guide on how to do this is inside the +[installation guide](./install.md). -To start run this command while being inside your nodecg installation: +!!! NOTE + + Also note that this currently only works when you have installed a release + version, not development versions. + +To start run this command while being inside your NodeCG installation: ```shell nodecg-io generate ``` -This will ask you a couple details about your bundle like name, description and used services. -Most questions have a reasonable default that you can choose if you don't care or are not sure about the asked thing. +This will ask you a couple details about your bundle like name, description and +used services. Most questions have a reasonable default that you can choose if +you don't care or are not sure about the asked thing. -After finishing the prompt the CLI will generate your bundle, install dependencies and, if you have chosen TypeScript, compile the generated code. +After finishing the prompt the CLI will generate your bundle, install +dependencies and, if you have chosen TypeScript, compile the generated code. ## Test it -Start NodeCG and make sure that the bundle gets loaded successfully, and it is displayed in the nodecg-io dashboard with all service dependencies. +Start NodeCG and make sure that the bundle gets loaded successfully, and it is +displayed in the nodecg-io dashboard with all service dependencies. ## Modify it -After that you should edit the `extension/index.ts` or `extension/index.js` depending on your chosen language to do something useful. -You can start by updating the `onAvailable` callbacks. +After that you should edit the `extension/index.ts` or `extension/index.js` +depending on your chosen language to do something useful. You can start by +updating the `onAvailable` callbacks. -_Note:_ If you need to access another service inside the callback of a `onAvailable` call you can use `otherService.getClient()` to get the client or `undefined` if it is not set. +_Note:_ If you need to access another service inside the callback of a +`onAvailable` call you can use `otherService.getClient()` to get the client or +`undefined` if it is not set. ## Further steps A couple of steps you may want to do after generating a bundle: -- Create a git repository for you bundle (a `.gitignore` is automatically generated for you) and push it to a git platform of your choice -- Add an [open source licence](https://choosealicense.com), don't forget it to also add it to the `package.json` file -- Add code formatters and linting tools like [prettier](https://prettier.io/) and [ESLint](https://eslint.org/) +- Create a git repository for you bundle (a `.gitignore` is automatically + generated for you) and push it to a git platform of your choice +- Add an [open source licence](https://choosealicense.com), don't forget it to + also add it to the `package.json` file +- Add code formatters and linting tools like [prettier](https://prettier.io/) + and [ESLint](https://eslint.org/) - Add a README that explains what your bundle does and how it can be used ## Share it! -If you share your work others might find it useful and get happy with it. We made nodecg-io for you, and the nodecg people made nodecg for you. Many people spent much time for you to create cool content that easy and if you shared your work others could create good content more easily as well. +If you share your work others might find it useful and get happy with it. We +made nodecg-io for you, and the NodeCG people made NodeCG for you. Many people +spent much time for you to create cool content that easy and if you shared your +work others could create good content more easily as well. diff --git a/docs/getting_started/existing_bundle.md b/docs/getting_started/existing_bundle.md index 93a6c31d..cfbac2cf 100644 --- a/docs/getting_started/existing_bundle.md +++ b/docs/getting_started/existing_bundle.md @@ -1,16 +1,20 @@ # Migrating your existing bundle to nodecg-io -This guide explains to you how to migrate an existing nodecg bundle that already meets your requirements to use nodecg-io. -nodecg-io manages service configuration and authentication, so your bundle doesn't have to bother with it. +This guide explains to you how to migrate an existing NodeCG bundle that already +meets your requirements to use nodecg-io. nodecg-io manages service +configuration and authentication, so your bundle doesn't have to bother with it. -If you are lucky and used the same library as we do for the service you want to migrate, nodecg-io is a drop-in replacement just doing authentication and configuration. -If you have used another library, you'll have to do a little more work to migrate to the library that our service uses. -In that case make sure that the migration is worth the effort. -You can use nodecg-io for one service and use your own library of choice for other services if you like to. +If you are lucky and used the same library as we do for the service you want to +migrate, nodecg-io is a drop-in replacement just doing authentication and +configuration. If you have used another library, you'll have to do a little more +work to migrate to the library that our service uses. In that case make sure +that the migration is worth the effort. You can use nodecg-io for one service +and use your own library of choice for other services if you like to. ## Install `nodecg-io-core` -The first thing you need to do is to install `nodecg-io-core`. You can do this simply using this npm command: +The first thing you need to do is to install `nodecg-io-core`. You can do this +simply using this npm command: ```shell npm install nodecg-io-core @@ -18,7 +22,8 @@ npm install nodecg-io-core ## Import `requireService` -Now that you have `nodecg-io-core` installed in your bundle you can import the `requireService` function that it exposes: +Now that you have `nodecg-io-core` installed in your bundle you can import the +`requireService` function that it exposes: === "TypeScript/ES Modules" @@ -34,28 +39,34 @@ Now that you have `nodecg-io-core` installed in your bundle you can import the ` ## Import Service type (TypeScript only) -If you're using TypeScript, you'll also need to install the package of the service that you want to use. -You need it to be able to import its type for type safety. +If you're using TypeScript, you'll also need to install the package of the +service that you want to use. You need it to be able to import its type for type +safety. -This example uses `twitch-chat` as an example, but you can just replace it with the name of the service you need. +This example uses `twitch-chat` as an example, but you can just replace it with +the name of the service you need. -=== "TypeScript" +```shell +npm install nodecg-io-twitch-chat +``` - ```shell - npm install nodecg-io-twitch-chat - ``` +=== "TypeScript" ```typescript import { TwitchChatServiceClient } from "nodecg-io-twitch-chat"; ``` -Note: You can get the name of the type by using autocomplete in your editor or by looking it up in the service sample. +!!! NOTE + + You can get the name of the type by using autocomplete in your editor or by + looking it up in the service sample. ## Require the service -Now you can finally tell nodecg-io that you want to get access to a service using the `requireService` function. -You'll have to pass your nodecg instance which is used to identify your bundle and the name of the service you want. -In case of TypeScript you'll also need to provide the type of the service. +Now you can finally tell nodecg-io that you want to get access to a service +using the `requireService` function. You'll have to pass your NodeCG instance +which is used to identify your bundle and the name of the service you want. In +case of TypeScript you'll also need to provide the type of the service. === "TypeScript" @@ -73,38 +84,51 @@ In case of TypeScript you'll also need to provide the type of the service. ### Using `onAvailable` and `onUnavailable` handlers -You can set up handlers that are executed when the user assigns a service instance to your bundle, removes the assignment or when the service client got updated in some way. +You can set up handlers that are executed when the user assigns a service +instance to your bundle, removes the assignment or when the service client got +updated in some way. -Handlers added with `onAvailable` will get called if there was a change and you got a client: +Handlers added with `onAvailable` will get called if there was a change, and you +got a client: -```typescript -// This is the variable with the return value of requireService(). -// You may want to change the variable name for the service you are using. -twitchChat.onAvailable((client) => { - nodecg.log.info("Client was set"); - // You can use the passed client in here to e.g. setup handlers on the client -}); -``` +=== "TypeScript" -`onAvailable` is especially useful to add event handlers to clients. -E.g., if you want to react to donations or chat messages you can add event handlers for these here. + ```typescript + // This is the variable with the return value of requireService(). + // You may want to change the variable name for the service you are using. + twitchChat.onAvailable((client) => { + nodecg.log.info("Client was set"); + // You can use the passed client in here to e.g. setup handlers on the client + }); + ``` -Handlers added with `onUnavailable` will get called if your bundle was not assigned a service instance or if there was an error in service client creation: +`onAvailable` is especially useful to add event handlers to clients. E.g., if +you want to react to donations or chat messages you can add event handlers for +these here. -```typescript -twitchChat.onUnavailable(() => { - nodecg.log.info("Client was unset"); -}); -``` +Handlers added with `onUnavailable` will get called if the user unassigned your +bundle from service instance or if there was an error in service client +creation: + +=== "TypeScript" + + ```typescript + twitchChat.onUnavailable(() => { + nodecg.log.info("Client was unset"); + }); + ``` ### Using `getClient` Instead of callbacks you can also get access to the client directly: -```typescript -const twitchChatClient = twitchChat.getClient(); -``` +=== "TypeScript" + + ```typescript + const twitchChatClient = twitchChat.getClient(); + ``` -`getClient` will return the client if your bundle has an assigned service instance that has produced a service client without error -and will return `undefined` otherwise. -This is useful for when you want to use the client due to some external event or from `onAvailable` handlers of other services. +`getClient` will return the client if your bundle has an assigned service +instance that has produced a service client without error and will return +`undefined` otherwise. This is useful for when you want to use the client due to +some external event or from `onAvailable` handlers of other services. diff --git a/docs/getting_started/install.md b/docs/getting_started/install.md index 372640fc..290e4614 100644 --- a/docs/getting_started/install.md +++ b/docs/getting_started/install.md @@ -26,37 +26,37 @@ that this list might not be up-to-date. Here's how to install the native build tools on the most popular operating systems, if you need them: -#### Windows +=== "Windows" -For Windows, you'll need the Visual Studio Build Tools, if you have Visual -Studio installed you should already have them. If you don't have Visual Studio -just install the Visual Studio Build Tools by running the following command as -an **Administrator**: + For Windows, you'll need the Visual Studio Build Tools, if you have Visual + Studio installed you should already have them. If you don't have Visual Studio + just install the Visual Studio Build Tools by running the following command as + an **Administrator**: -```shell -npm install -g windows-build-tools -``` + ```shell + npm install -g windows-build-tools + ``` -#### Linux +=== "Linux" -For Linux, you'll need a C++ compiler and some other packages. On Ubuntu/Debian -based operating systems run the following command: + For Linux, you'll need a C++ compiler and some other packages. On Ubuntu/Debian + based operating systems run the following command: -```shell -sudo apt install build-essential libusb-1.0-0-dev libasound2-dev libudev-dev -``` + ```shell + sudo apt install build-essential libusb-1.0-0-dev libasound2-dev libudev-dev + ``` -For other Linux distros you'll need the corresponding packages, just search on -the internet how the packages are named for your specific distro. + For other Linux distros you'll need the corresponding packages, just search on + the internet for the packages on your specific distro. -#### macOS +=== "macOS" -For macOS, you'll need the Xcode command line tools. To install them run the -following command: + For macOS, you'll need the Xcode command line tools. To install them run the + following command: -```shell -xcode-select --install -``` + ```shell + xcode-select --install + ``` ## Install the nodecg-io CLI @@ -66,16 +66,21 @@ Install the nodecg-io CLI using the following command: npm install -g nodecg-io-cli ``` -_Note:_ If you are running on Linux, you may need to use `sudo` if your npm -installation uses a non-writeable path (default on Ubuntu apt packages, usually -does not apply to packages installed using [nvm](https://github.com/nvm-sh/nvm)) +!!! NOTE + + If you are running on Linux, you may need to use `sudo` if your npm + installation uses a non-writeable path (default on Ubuntu apt packages, usually + does not apply to packages installed using + [nvm](https://github.com/nvm-sh/nvm)) ## Install nodecg-io using the nodecg-io CLI -> nodecg-io will always be installed into a `nodecg-io/` directory inside your -> NodeCG installation so that your bundles and all bundles from nodecg-io are -> separated. The CLI will add this path to the loaded bundles in your NodeCG -> configuration automatically, you don't need to worry about it. +!!! INFO + + nodecg-io will always be installed into a `nodecg-io/` directory inside your + NodeCG installation so that your bundles and all bundles from nodecg-io are + separated. The CLI will add this path to the loaded bundles in your NodeCG + configuration automatically, you don't need to worry about it. With the nodecg-io CLI installed you can run this command inside a NodeCG installation to install nodecg-io: @@ -87,12 +92,12 @@ Installing nodecg-io... You will get a prompt which asks you which version you want to install: -
user@computer:~/nodecg$ nodecg-io install
+
user@computer:~/nodecg$ nodecg-io install
 Installing nodecg-io...
 Detected nodecg installation at /home/user/nodecg.
 ? Which version do you want to install? (Use arrow keys) 
   development 
-❯ 0.1
+❯ 0.1
There are two possible installation types: @@ -110,63 +115,54 @@ There are two possible installation types: For starters, we recommend using the development version, so you may try our premade examples. -### Production install - -
- Click to see more! - -Because you selected a production install you may select the services to be -included in this next step: - -
user@computer:~/nodecg$ nodecg-io install
-Installing nodecg-io...
-Detected nodecg installation at /home/user/nodecg.
-? Which version do you want to install? 0.1
-? Which services do you want to use? (Press <space> to select, <a> to toggle all,
-<i> to invert selection, and <enter> to proceed)
-❯◯ ahk
- ◯ android
- ◯ curseforge
- ◯ discord
- ◯ intellij
- ◯ irc
- ◯ midi-input
-(Move up and down to reveal more choices)
- -If you want to every change your nodecg-io installation to add/remove a service -or change the version, you can always re-run `nodecg-io install`. If a nodecg-io -installation is found, its options will be preselected in the prompt. Re-running -`nodecg-io install` will also update all packages to the latest patch version. - -
- -### Development install - -
- Click to see more! - -Because you selected a production install you may select to use the samples and -documentation to be included in these next steps: - -
user@computer:~/nodecg$ nodecg-io install
-Installing nodecg-io...
-Detected nodecg installation at /home/user/nodecg.
-? Which version do you want to install? development
-? Would you like to use the provided samples? (y/N) 
- -
user@computer:~/nodecg$ nodecg-io install
-Installing nodecg-io...
-Detected nodecg installation at /home/user/nodecg.
-? Which version do you want to install? development
-? Would you like to use the provided samples? No
-? Would you like to clone the documentation? (y/N) 
- -If you want to every change your nodecg-io installation to add/remove a service -or change the version, you can always re-run `nodecg-io install`. If a nodecg-io -installation is found, its options will be preselected in the prompt. Re-running -`nodecg-io install` will also pull the repository and rebuild it. - -
+=== "Production install" + + Because you selected a production install you may select the services to be + included in this next step: + +
user@computer:~/nodecg$ nodecg-io install
+    Installing nodecg-io...
+    Detected nodecg installation at /home/user/nodecg.
+    ? Which version do you want to install? 0.1
+    ? Which services do you want to use? (Press <space> to select, <a> to toggle all,
+    <i> to invert selection, and <enter> to proceed)
+    ❯◯ ahk
+     ◯ android
+     ◯ curseforge
+     ◯ discord
+     ◯ intellij
+     ◯ irc
+     ◯ midi-input
+    (Move up and down to reveal more choices)
+ + If you want to every change your nodecg-io installation to add/remove a service + or change the version, you can always re-run `nodecg-io install`. If it finds a + nodecg-io installation, its options will be preselected in the prompt. + Re-running `nodecg-io install` will also update all packages to the latest patch + version. + +=== "Development install" + + Because you selected a production install you may select to use the samples and + documentation to be included in these next steps: + +
user@computer:~/nodecg$ nodecg-io install
+    Installing nodecg-io...
+    Detected nodecg installation at /home/user/nodecg.
+    ? Which version do you want to install? development
+    ? Would you like to use the provided samples? (y/N) 
+ +
user@computer:~/nodecg$ nodecg-io install
+    Installing nodecg-io...
+    Detected nodecg installation at /home/user/nodecg.
+    ? Which version do you want to install? development
+    ? Would you like to use the provided samples? No
+    ? Would you like to clone the documentation? (y/N) 
+ + If you want to every change your nodecg-io installation to add/remove a service + or change the version, you can always re-run `nodecg-io install`. If it finds a + nodecg-io installation, its options will be preselected in the prompt. + Re-running `nodecg-io install` will also pull the repository and rebuild it. ### Continue reading diff --git a/docs/getting_started/try_example_bundle.md b/docs/getting_started/try_example_bundle.md index d57abe3a..61f2163a 100644 --- a/docs/getting_started/try_example_bundle.md +++ b/docs/getting_started/try_example_bundle.md @@ -3,9 +3,11 @@ Trying one of the premade example bundles is a good way to get to know the framework and especially the selected service. -> In case you installed the **production** branch of nodecg-io, you are out of -> luck. Because the build process will cause problems if you just take one of -> the samples and rebuild elsewhere. +!!! ATTENTION + + In case you installed the **production** branch of nodecg-io, you are out of + luck. Because the build process will cause problems if you just take one of the + samples and rebuild elsewhere. If you installed **dev** branch via the `nodecg-io-cli` and did not select the “use the samples”-option run `nodecg-io install` and select it. @@ -28,7 +30,7 @@ the `Run and Debug` Explorer View: You may also launch NodeCG using your terminal with: -
user@computer:~/nodecg$ npm run start
+
user@computer:~/nodecg$ npm run start
 
 > nodecg@1.8.1 start
 > node index.js
@@ -38,7 +40,7 @@ info: [nodecg-io-core] Minzig!
 
 // A whole host of logging output
 
-info: [nodecg/lib/server] NodeCG running on http://localhost:9090
+info: [nodecg/lib/server] NodeCG running on http://localhost:9090
Now you can open the NodeCG dashboard (by default) under . @@ -69,7 +71,7 @@ to arrange yourself with this one. So, to get started: ### In pink: NodeCG Tabs Here you will find every NodeCG-bundle that has a dashboard. Here you may select -the [`nodecg-io-debug`](../samples/debug.md)-dashboard, if it is installed. +the [nodecg-io-debug](../samples/debug.md)-dashboard, if it is installed. ### In yellow: Monaco editor @@ -112,9 +114,12 @@ This section has three dropdowns: ### In red: Unset all Button This button will set the service instance for every bundle/service combination -to none, effectively removing the access to every service from all bundles. -**Caution**: This can not be undone, and you will have to set up all the bundles -again. _The service instances will be unaffected._ +to none, effectively removing the access to every service from all bundles. + +!!! DANGER + + This can not be undone, and you will have to set up all the bundles + again. __The service instances will be unaffected.__ ## Step 4: Configure the sample diff --git a/docs/index.md b/docs/index.md index 0733d280..595f520b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,13 +16,20 @@ ## About nodecg-io -nodecg-io is the successor of [ChatOverflow](https://github.com/codeoverflow-org/chatoverflow). The aim of this bundle is to simplify the code and expand the number of integrated services. The main goal is to increase the number of supported APIs to save you development time. +nodecg-io is the successor of +[ChatOverflow](https://github.com/codeoverflow-org/chatoverflow). The aim of +this bundle is to simplify the code and expand the number of integrated +services. The main goal is to increase the number of supported APIs to save you +development time. ## How to use nodecg-io -If you want to use nodecg-io, you should note that it is only a framework for your bundle. -So you need at least a basic knowledge of the programming language JavaScript or any other language that compiles to JavaScript like TypeScript. -If that's no problem you can head over to the [installation guide](./getting_started/install.md) and take a look at the [available nodecg-io services](./services.md). +If you want to use nodecg-io, you should note that it is only a framework for +your bundle. So you need at least a basic knowledge of the programming language +JavaScript or any other language that compiles to JavaScript like TypeScript. If +that's no problem you can head over to the +[installation guide](./getting_started/install.md) and take a look at the +[available nodecg-io services](./services.md). ## Implemented Services and Interfaces @@ -68,4 +75,7 @@ If that's no problem you can head over to the [installation guide](./getting_sta ## How to contribute -If you want to contribute to this bundle you can implement one of those services or fix an [issue](https://github.com/codeoverflow-org/nodecg-io/issues). Before contributing head over to the [“How to contribute”](./contribute/contribute.md)-Guide. +If you want to contribute to this bundle you can implement one of those services +or fix an [issue](https://github.com/codeoverflow-org/nodecg-io/issues). Before +contributing head over to the +[“How to contribute”](./contribute/contribute.md)-Guide. diff --git a/docs/samples/artnet.md b/docs/samples/artnet.md index 21d50d84..82686f3b 100644 --- a/docs/samples/artnet.md +++ b/docs/samples/artnet.md @@ -4,7 +4,7 @@ The Art-Net example bundle in `samples/artnet-console` demonstrates the ability send data via Art-Net to e.g., open lighting architecture or professional lighting equipment. Here is a guide to how to get it working. The underlying service is using -[`jeffreykog/node-artnet-protocol`](https://github.com/jeffreykog/node-artnet-protocol) +[jeffreykog/node-artnet-protocol](https://github.com/jeffreykog/node-artnet-protocol) as its library. ### Prerequisites @@ -21,8 +21,8 @@ will also tell you how to log in and how to use the GUI. ### Configure the Art-Net sample bundle -1. In NodeCG, create a new Art-Net service instance. -2. Enter the host to witch the service should broadcast: +1. In NodeCG, create a new Art-Net service instance. +2. Enter the host to witch the service should broadcast: **Host** @@ -36,12 +36,14 @@ will also tell you how to log in and how to use the GUI. After entering it, click save. - You may overwrite this broadcast address in code with - `client.bind("host address");`. + !!! INFO -3. Set the sample's (`artnet-console`) dependency to be the newly created - service instance (of type `artnet`). -4. Check the NodeCG logs. You should see data logged. + You may overwrite this broadcast address in code with + `#!ts client.bind("host address");`. + +3. Set the sample's (`artnet-console`) dependency to be the newly created + service instance (of type `artnet`). +4. Check the NodeCG logs. You should see data logged. ### Explanations @@ -64,12 +66,7 @@ declare class ArtDmx { physical: number; universe: number; data: number[]; - constructor( - sequence: number, - physical: number, - universe: number, - data: number[] - ); + constructor(sequence: number, physical: number, universe: number, data: number[]); isSequenceEnabled(): boolean; static decode(data: Buffer): ArtDmx; toString(): string; @@ -90,12 +87,14 @@ setInterval(() => { }, 800); ``` -_Note_: Since neither this library nor nodecg-io does not yet contain an -abstraction, so the data is sent to the timings set by the specification, you -should respect this part of specification in **your implementation**. +!!! NOTE + + Since neither this library nor nodecg-io does not yet contain an + abstraction, so the data is sent to the timings set by the specification, you + should respect this part of specification in **your implementation**. -> However, an input that is active but not changing, will re-transmit the last -> valid ArtDmx packet at approximately 4-second intervals. (_Note_. In order to -> converge the needs of Art- Net and sACN it is recommended that Art-Net devices -> actually use a re-transmit time of 800mS to 1000mS). -> — [Art-Net 4 Specification p. 48](https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf) + > However, an input that is active but not changing, will re-transmit the last + > valid ArtDmx packet at approximately 4-second intervals. (_Note_. In order to + > converge the needs of Art- Net and sACN it is recommended that Art-Net devices + > actually use a re-transmit time of 800mS to 1000mS). + > — [Art-Net 4 Specification p. 48](https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf) diff --git a/docs/samples/discord-rpc.md b/docs/samples/discord-rpc.md index 29540fe5..2927e799 100644 --- a/docs/samples/discord-rpc.md +++ b/docs/samples/discord-rpc.md @@ -16,8 +16,10 @@ will also tell you how to log in and how to use the GUI. - A discord application with permissions `indentify` and `rpc` -_Note:_ If you don't have an application yet, you can create one -[here](https://discord.com/developers/applications) +!!! Note + + If you don't have an application yet, you can create one + [here](https://discord.com/developers/applications) ### Configure the Discord RPC sample bundle diff --git a/docs/samples/discord.md b/docs/samples/discord.md index 008fe712..bb4ce309 100644 --- a/docs/samples/discord.md +++ b/docs/samples/discord.md @@ -16,9 +16,11 @@ will also tell you how to log in and how to use the GUI. - A Discord Bot token -_Note:_ If you don't have such a token yet, you can follow -[this](https://discordjs.guide/preparations/setting-up-a-bot-application.html) -guide. +!!! Note + + If you don't have such a token yet, you can follow + [this](https://discordjs.guide/preparations/setting-up-a-bot-application.html) + guide. ### Configure the Discord sample bundle diff --git a/docs/samples/github.md b/docs/samples/github.md index 0c1a5f48..d37c4313 100644 --- a/docs/samples/github.md +++ b/docs/samples/github.md @@ -15,9 +15,11 @@ will also tell you how to log in and how to use the GUI. - A GitHub token -_Note:_ If you don't have a token yet, you can create one -[here](https://github.com/settings/tokens/new). The token requires at least the -`repo` scope. +!!! Note + + If you don't have a token yet, you can create one + [here](https://github.com/settings/tokens/new). The token requires at least the + `repo` scope. ### Configure the GitHub sample bundle diff --git a/docs/samples/gsheets.md b/docs/samples/gsheets.md index 2205fe0c..bcaae06e 100644 --- a/docs/samples/gsheets.md +++ b/docs/samples/gsheets.md @@ -16,17 +16,20 @@ will also tell you how to log in and how to use the GUI. - Google cloud API OAuth access (client ID, client Secret) - Grant `Google Sheets API v4` access at the project's dashboard. - Shortcut URL: - > + `https://console.developers.google.com/apis/library/sheets.googleapis.com?project=`. -_Note:_ If you don't have such a key yet, you can generate them like -[this](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred). -As the redirect URI add -. +!!! NOTE + + If you don't have such a key yet, you can generate them like + [this](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred). + As redirect URI add: + + ### Configure the gsheets sample bundle -1. In NodeCG, create a new googleapis service instance. -2. Enter the credentials for googleapis: +1. In NodeCG, create a new googleapis service instance. +2. Enter the credentials for googleapis: ```json { @@ -38,12 +41,14 @@ As the redirect URI add After entering it, click save. - _Note:_ You can add multiple scopes if the googleapis instance is used for - multiple bundles. + !!! Note + + You can add multiple scopes if the googleapis instance is used for + multiple bundles. -3. Set the sample's (`gsheets`) dependency to be the newly created service - instance (of type `googleapis`). -4. Check the NodeCG logs: +3. Set the sample's (`gsheets`) dependency to be the newly created service + instance (of type `googleapis`). +4. Check the NodeCG logs: You should see an error or a success message that is hardcoded in `samples/gsheets/extension/index.ts`. diff --git a/docs/samples/intellij.md b/docs/samples/intellij.md index c93325ea..6671c7d9 100644 --- a/docs/samples/intellij.md +++ b/docs/samples/intellij.md @@ -30,7 +30,7 @@ will also tell you how to log in and how to use the GUI. 1. In NodeCG, create a new IntelliJ service instance. 2. Enter the host and port of your IDE's HTTP server: - ``` + ```json { "address": "127.0.0.1:19524" } diff --git a/docs/samples/midi-input.md b/docs/samples/midi-input.md index b86d4239..a8eaeab8 100644 --- a/docs/samples/midi-input.md +++ b/docs/samples/midi-input.md @@ -17,9 +17,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the midi-input sample bundle -1. In NodeCG, create a new midi-input service instance. +1. In NodeCG, create a new midi-input service instance. -2. Enter your device information: +2. Enter your device information: ```json { @@ -27,20 +27,24 @@ will also tell you how to log in and how to use the GUI. } ``` - After entering it, click save. - **Note:** A script is provided to list all inputs and outputs. It can be run - from the sample directory `samples/midi-input` using the command - `npm run list`. The devices should be listed with their device names and - some other stuff. - Under Linux this looks for example like this: + After entering it, click save. - ``` - nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 - ``` + !!! NOTE + + A script is provided to list all inputs and outputs. It can be run + from the sample directory `samples/midi-input` using the command + `npm run list`. The devices should be listed with their device names + and some other stuff. + + Under Linux this looks for example like this: + + ```plain + nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 + ``` -3. Set the sample's (`midi-input`) dependency to be the newly created service - instance (of type `midi-input`). -4. Check the NodeCG logs: +3. Set the sample's (`midi-input`) dependency to be the newly created service + instance (of type `midi-input`). +4. Check the NodeCG logs: You should see an error or a success message and all midi messages that are sent by the device that is configured. diff --git a/docs/samples/midi-io.md b/docs/samples/midi-io.md index 8bdf9924..83f079e2 100644 --- a/docs/samples/midi-io.md +++ b/docs/samples/midi-io.md @@ -17,9 +17,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the midi-io sample bundle -1. In NodeCG, create a new midi-input service instance. +1. In NodeCG, create a new midi-input service instance. -2. Enter your device information: +2. Enter your device information: ```json { @@ -27,23 +27,27 @@ will also tell you how to log in and how to use the GUI. } ``` - After entering it, click save. - **Note:** A script is provided to list all inputs and outputs. It can be run - from the sample directory `samples/midi-io` using the command - `npm run list`. The devices should be listed with their device names and - some other stuff. - Under Linux this looks for example like this: + After entering it, click save. - ``` - nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 - ``` + !!! NOTE + + A script is provided to list all inputs and outputs. It can be run + from the sample directory `samples/midi-input` using the command + `npm run list`. The devices should be listed with their device names + and some other stuff. + + Under Linux this looks for example like this: + + ```plain + nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 + ``` -3. Create a new midi-output service instance using the left upper menu. +3. Create a new midi-output service instance using the left upper menu. -4. Set the sample's (`midi-io`) dependencies to be the newly created service - instances (of type `midi-input` & `midi-output`). +4. Set the sample's (`midi-io`) dependencies to be the newly created service + instances (of type `midi-input` & `midi-output`). -5. Check the NodeCG logs: +5. Check the NodeCG logs: You should see an error or a success message and midi messages that are received and echoed back to the device that is configured. The messages are diff --git a/docs/samples/midi-output.md b/docs/samples/midi-output.md index 788c4c77..031ff664 100644 --- a/docs/samples/midi-output.md +++ b/docs/samples/midi-output.md @@ -17,9 +17,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the midi-output sample bundle -1. In NodeCG, create a new midi-output service instance. +1. In NodeCG, create a new midi-output service instance. -2. Enter your device information: +2. Enter your device information: ```json { @@ -27,21 +27,25 @@ will also tell you how to log in and how to use the GUI. } ``` - After entering it, click save. - **Note:** A script is provided to list all inputs and outputs. It can be run - from the sample directory `samples/midi-output` using the command - `npm run list`. The devices should be listed with their device names and - some other stuff. - Under Linux this looks for example like this: + After entering it, click save. - ``` - nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 - ``` + !!! NOTE + + A script is provided to list all inputs and outputs. It can be run + from the sample directory `samples/midi-input` using the command + `npm run list`. The devices should be listed with their device names + and some other stuff. + + Under Linux this looks for example like this: + + ```plain + nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0 + ``` -3. Set the sample's (`midi-output`) dependency to be the newly created service - instance (of type `midi-output`). +3. Set the sample's (`midi-output`) dependency to be the newly created service + instance (of type `midi-output`). -4. Check the NodeCG logs: +4. Check the NodeCG logs: You should see an error or a success message and random midi messages should be sent to the device that is configured. The messages are only `Noteon` diff --git a/docs/samples/nanoleaf.md b/docs/samples/nanoleaf.md index 3ee86236..c10bf8be 100644 --- a/docs/samples/nanoleaf.md +++ b/docs/samples/nanoleaf.md @@ -18,9 +18,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the nanoleaf sample bundle -1. In NodeCG, create a new nanoleaf service instance. +1. In NodeCG, create a new nanoleaf service instance. -2. Enter the IP address of your nanoleaf controller: +2. Enter the IP address of your nanoleaf controller: ```json { @@ -28,13 +28,15 @@ will also tell you how to log in and how to use the GUI. } ``` - Before clicking save put your nanoleaf controller into pairing mode by - holding the on-off button for 5-7 seconds till the LED starts flashing. + !!! ATTENTION - After entering your config and entering pairing mode, click save. + Before clicking save put your nanoleaf controller into pairing mode by + holding the on-off button for 5-7 seconds till the LED starts flashing. -3. Set the sample's (`nanoleaf`) dependency to be the newly created service - instance (of type `nanoleaf`). + After entering your config and entering pairing mode, click save. -4. If everything worked, your nanoleafs should now shine orange. - If not you should check the NodeCG logs for any errors. +3. Set the sample's (`nanoleaf`) dependency to be the newly created service + instance (of type `nanoleaf`). + +4. If everything worked, your nanoleafs should now shine orange. + If not you should check the NodeCG logs for any errors. diff --git a/docs/samples/obs.md b/docs/samples/obs.md index 32a7347d..2f82c9db 100644 --- a/docs/samples/obs.md +++ b/docs/samples/obs.md @@ -16,15 +16,17 @@ will also tell you how to log in and how to use the GUI. - OBS with obs-websocket installed -_Note:_ OBS is available [here](https://obsproject.com/de/download) and -obs-websocket with install instructions is available -[here](https://github.com/Palakis/obs-websocket/releases). +!!! NOTE + + OBS is available [here](https://obsproject.com/de/download) and + obs-websocket with install instructions is available + [here](https://github.com/Palakis/obs-websocket/releases). ### Configure the OBS sample bundle -1. In NodeCG, create a new obs service instance. +1. In NodeCG, create a new obs service instance. -2. Enter the configuration for obs: +2. Enter the configuration for obs: ```json { @@ -34,15 +36,17 @@ obs-websocket with install instructions is available } ``` - If you don't want to use a password, you can just remove the password - property from the config. + !!! INFO + + If you don't want to use a password, you can just remove the password + property from the config. After entering it, click save. -3. Set the sample's (`obs-scenelist`) dependency to be the newly created service - instance (of type `obs`). +3. Set the sample's (`obs-scenelist`) dependency to be the newly created + service instance (of type `obs`). -4. Check the NodeCG logs: +4. Check the NodeCG logs: You should see an error or a success message and the names of all you scenes that you have set in OBS. diff --git a/docs/samples/philipshue.md b/docs/samples/philipshue.md index 482a4e9d..b24b17db 100644 --- a/docs/samples/philipshue.md +++ b/docs/samples/philipshue.md @@ -18,9 +18,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the Philips Hue sample bundle -1. In NodeCG, create a new Philips Hue service instance. +1. In NodeCG, create a new Philips Hue service instance. -2. Enter configuration for hue. +2. Enter configuration for hue. If you want the bridge to be automatically discovered just set `discover` to true like this: @@ -44,14 +44,16 @@ will also tell you how to log in and how to use the GUI. After entering it, press the big link button on your bridge and then click save. - After the first time you connect to your bridge it will create a user and an - API key which will be saved so that you only need to press the link button - when you connect it for the first time. + !!! INFO -3. Set the sample's (`philipshue-lights`) dependency to be the newly created - service instance (of type `philipshue`). + After the first time you connect to your bridge it will create a user and an + API key which will be saved so that you only need to press the link button + when you connect it for the first time. -4. Check the NodeCG logs: +3. Set the sample's (`philipshue-lights`) dependency to be the newly created + service instance (of type `philipshue`). + +4. Check the NodeCG logs: You should see an error or a success message and the number of lights that the bridge knows of. diff --git a/docs/samples/rcon.md b/docs/samples/rcon.md index 7946c06f..c3862594 100644 --- a/docs/samples/rcon.md +++ b/docs/samples/rcon.md @@ -1,6 +1,6 @@ ## Using the RCON sample bundle -The rcon sample bundle in `samples/rcon-minecraft` shows how to send a command +The RCON sample bundle in `samples/rcon-minecraft` shows how to send a command to a Minecraft server. ### Prerequisites @@ -15,11 +15,11 @@ will also tell you how to log in and how to use the GUI. - A working [Minecraft](https://minecraft.net) server. -### Configure the rcon sample bundle +### Configure the RCON sample bundle -1. In NodeCG, create a new rcon service instance. +1. In NodeCG, create a new RCON service instance. -2. Enter the host, port, and password of the rcon connection. This can be found +2. Enter the host, port, and password of the RCON connection. This can be found in the `server.properties` file (`rcon.port`, `rcon.password`): ```json diff --git a/docs/samples/reddit.md b/docs/samples/reddit.md index 08609f7c..8380e957 100644 --- a/docs/samples/reddit.md +++ b/docs/samples/reddit.md @@ -15,8 +15,10 @@ will also tell you how to log in and how to use the GUI. - A Reddit Application (Should be of type script for own purpose) -_Note:_ If you don't have such an application yet, you can get one -[here](https://www.reddit.com/prefs/apps). +!!! NOTE + + If you don't have such an application yet, you can get one + [here](https://www.reddit.com/prefs/apps). ### Configure the Reddit sample bundle diff --git a/docs/samples/serial.md b/docs/samples/serial.md index 67965d3f..d5039807 100644 --- a/docs/samples/serial.md +++ b/docs/samples/serial.md @@ -19,9 +19,9 @@ will also tell you how to log in and how to use the GUI. ### Configure the serial sample bundle -1. In NodeCG, create a new serial service instance. +1. In NodeCG, create a new serial service instance. -2. Enter the information of your device: +2. Enter the information of your device: ```json { @@ -41,15 +41,17 @@ will also tell you how to log in and how to use the GUI. After entering it, click save. - _Note:_ If you want to list all connected devices you can open a terminal in - `nodecg-io-serial` and run `npm run list`. _Note:_ If you are using multiple - devices you might want to use the `pnpId`, since ports can change between - reboots! + !!! NOTE -3. Set the sample's (`serial`) dependency to be the newly created service - instance (of type `serial`). + If you want to list all connected devices you can open a terminal in + `nodecg-io-serial` and run `npm run list`. _Note:_ If you are using multiple + devices you might want to use the `pnpId`, since ports can change between + reboots! -4. Check the NodeCG logs: +3. Set the sample's (`serial`) dependency to be the newly created service + instance (of type `serial`). + +4. Check the NodeCG logs: You should see an error or a success message and nodecg-io will send ping to the microcontroller every 10 seconds. The Arduino device will respond with diff --git a/docs/samples/shlink.md b/docs/samples/shlink.md index 6adf7def..f31d9739 100644 --- a/docs/samples/shlink.md +++ b/docs/samples/shlink.md @@ -19,8 +19,8 @@ will also tell you how to log in and how to use the GUI. ### Configure the Shlink sample bundle -1. In NodeCG, create a new Shlink service instance. -2. Enter the configuration for Shlink: +1. In NodeCG, create a new Shlink service instance. +2. Enter the configuration for Shlink: ```json { @@ -31,14 +31,16 @@ will also tell you how to log in and how to use the GUI. After entering it, click save. -3. Set the sample's (`shlink-list-short-urls`) dependency to be the newly - created service instance (of type `shlink`). +3. Set the sample's (`shlink-list-short-urls`) dependency to be the newly + created service instance (of type `shlink`). -4. Check the NodeCG logs: +4. Check the NodeCG logs: You should see an error or a success message and the amount of configured short URLs on the Shlink server. - _Note:_ When listing short URLs — like this sample does — be aware that the - amount of short URLs might be limited by the - [API key role](https://shlink.io/documentation/api-docs/api-key-roles/). + !!! NOTE + + When listing short URLs — like this sample does — be aware that the + amount of short URLs might be limited by the + [API key role](https://shlink.io/documentation/api-docs/api-key-roles/). diff --git a/docs/samples/slack.md b/docs/samples/slack.md index 6574de51..ede10d84 100644 --- a/docs/samples/slack.md +++ b/docs/samples/slack.md @@ -16,8 +16,10 @@ will also tell you how to log in and how to use the GUI. - a Slack Bot token -_Note:_ If you don't have such a token yet, you can create your own app with -token on [this](https://app.slack.com/apps-manage/) page. +!!! NOTE + + If you don't have such a token yet, you can create your own app with + token on [this](https://app.slack.com/apps-manage/) page. ### Configure the Slack sample bundle diff --git a/docs/samples/spotify.md b/docs/samples/spotify.md index 04ae1d8c..fb26b8d1 100644 --- a/docs/samples/spotify.md +++ b/docs/samples/spotify.md @@ -17,15 +17,17 @@ will also tell you how to log in and how to use the GUI. - A Spotify account and a registered Spotify application and the associated client id/client secret. -_Note:_ If you don't have a registered application, yet you can follow -[this guide](https://developer.spotify.com/documentation/general/guides/app-settings/#register-your-app). -As a redirect URL use . +!!! NOTE + + If you don't have a registered application, yet you can follow + [this guide](https://developer.spotify.com/documentation/general/guides/app-settings/#register-your-app). + As a redirect URL use . ### Configure the Spotify sample bundle -1. In NodeCG, create a new Spotify service instance. +1. In NodeCG, create a new Spotify service instance. -2. Enter your client ID and secret for Spotify: +2. Enter your client ID and secret for Spotify: ```json { @@ -37,15 +39,17 @@ As a redirect URL use . After entering it, click save. - _Note:_ This sample requires the `user-read-playback-state` scope, but you - can require other scopes if you want to use functions that require them. A - list of all scopes can be found - [here](https://developer.spotify.com/documentation/general/guides/scopes/). + !!! NOTE + + This sample requires the `user-read-playback-state` scope, but you + can require other scopes if you want to use functions that require them. A + list of all scopes can be found + [here](https://developer.spotify.com/documentation/general/guides/scopes/). -3. Set the sample's (`spotify-current-song`) dependency to be the newly created - service instance (of type `spotify`). +3. Set the sample's (`spotify-current-song`) dependency to be the newly created + service instance (of type `spotify`). -4. Check the NodeCG logs: +4. Check the NodeCG logs: You should see an error or a success message and the current playing song with names and artists. diff --git a/docs/samples/sql.md b/docs/samples/sql.md index be69b54b..6c5b5642 100644 --- a/docs/samples/sql.md +++ b/docs/samples/sql.md @@ -15,9 +15,11 @@ will also tell you how to log in and how to use the GUI. - A database supported by [knex](https://knexjs.org/#Installation) -_Note:_ If you don't have a database yet and just want to test things you can -use sqlite3 and don't need to set up a database server. You can always move to a -different database type later. +!!! NOTE + + If you don't have a database yet and just want to test things you can + use sqlite3 and don't need to set up a database server. You can always move + to a different database type later. ### Configure the SQL sample bundle diff --git a/docs/samples/streamdeck.md b/docs/samples/streamdeck.md index 92643d25..ab93a5ad 100644 --- a/docs/samples/streamdeck.md +++ b/docs/samples/streamdeck.md @@ -20,11 +20,11 @@ Follow the instructions listed under Manual Installation [here](https://github.com/timothycrosley/streamdeck-ui/blob/master/README.md). Everything after the `sudo udevadm` command can be omitted. -### Configure the Streamdeck Rainbow bundle +### Configure the StreamDeck Rainbow bundle -1. In NodeCG, create a new StreamDeck service instance. +1. In NodeCG, create a new StreamDeck service instance. -2. Enter the configuration: +2. Enter the configuration: ```json { @@ -32,10 +32,12 @@ Everything after the `sudo udevadm` command can be omitted. } ``` - `default` tells the bundle to automatically find a StreamDeck. If you use - multiple StreamDecks, you need to put in an ID here. + !!! INFO -3. Set the sample's (`streamdeck-rainbow`) dependency to be the newly created - service instance (of type `streamdeck`). + `default` tells the bundle to automatically find a StreamDeck. If you use + multiple StreamDecks, you need to put in an ID here. -4. Watch your streamdeck. +3. Set the sample's (`streamdeck-rainbow`) dependency to be the newly created + service instance (of type `streamdeck`). + +4. Watch your streamdeck. diff --git a/docs/samples/tiane.md b/docs/samples/tiane.md index 96ed6233..141b6852 100644 --- a/docs/samples/tiane.md +++ b/docs/samples/tiane.md @@ -18,9 +18,11 @@ will also tell you how to log in and how to use the GUI. room client required) - a Discord Bot token -_Note:_ If you don't Discord Bot token yet, you can follow -[this](https://discordjs.guide/preparations/setting-up-a-bot-application.html) -guide. +!!! NOTE + + If you don't Discord Bot token yet, you can follow + [this](https://discordjs.guide/preparations/setting-up-a-bot-application.html) + guide. ### Configure the TIANE sample bundle diff --git a/docs/samples/twitch-addons.md b/docs/samples/twitch-addons.md index cc120db7..2c67dafe 100644 --- a/docs/samples/twitch-addons.md +++ b/docs/samples/twitch-addons.md @@ -16,10 +16,12 @@ will also tell you how to log in and how to use the GUI. - A Twitch oAuth-Key -_Note:_ If you don't have such a key yet, you can generate it on -. Just log into your Twitch account and copy the -token. You can also use any other token. There are no special scope requirements -as the token is only used to convert channel names to IDs. +!!! NOTE + + If you don't have such a key yet, you can generate it on + . Just log into your Twitch account and copy + the token. You can also use any other token. There are no special scope + requirements as the token is only used to convert channel names to IDs. ### Configure the Twitch-Addons sample bundle diff --git a/docs/samples/twitch-api.md b/docs/samples/twitch-api.md index 3ef62209..14f6df81 100644 --- a/docs/samples/twitch-api.md +++ b/docs/samples/twitch-api.md @@ -16,10 +16,12 @@ will also tell you how to log in and how to use the GUI. - A Twitch oAuth-Key -_Note:_ If you don't have such a key yet, you can generate it on -, select custom scope token and select the -scopes you need. For this sample you don't need any additional scopes, so you -can leave everything off. +!!! NOTE + + If you don't have such a key yet, you can generate it on + , select custom scope token and select + the scopes you need. For this sample you don't need any additional scopes, + so you can leave everything off. ### Configure the Twitch API sample bundle diff --git a/docs/samples/twitch-chat.md b/docs/samples/twitch-chat.md index b4e6b706..ed52080d 100644 --- a/docs/samples/twitch-chat.md +++ b/docs/samples/twitch-chat.md @@ -16,9 +16,11 @@ will also tell you how to log in and how to use the GUI. - a Twitch oAuth-Key -_Note:_ If you don't have such a key yet, you can generate it on -. Just log into your Twitch account and copy the -token. +!!! NOTE + + If you don't have such a key yet, you can generate it on + . Just log into your Twitch account and copy + the token. ### Configure the Twitch sample bundle diff --git a/docs/samples/twitch-pubsub.md b/docs/samples/twitch-pubsub.md index 974143ef..372ec0b0 100644 --- a/docs/samples/twitch-pubsub.md +++ b/docs/samples/twitch-pubsub.md @@ -15,9 +15,11 @@ will also tell you how to log in and how to use the GUI. - A Twitch oAuth-Key -_Note:_ If you don't have such a key yet, you can generate it on -, select custom scope token and select these -scopes: `channel_subscriptions`, `bits:read` and `channel:read:redemptions` +!!! NOTE + + If you don't have such a key yet, you can generate it on + , select custom scope token and select these + scopes: `channel_subscriptions`, `bits:read` and `channel:read:redemptions` ### Configure the Twitch PubSub sample bundle diff --git a/docs/samples/twitter.md b/docs/samples/twitter.md index 159b9c1c..b8f86e3f 100644 --- a/docs/samples/twitter.md +++ b/docs/samples/twitter.md @@ -20,9 +20,11 @@ will also tell you how to log in and how to use the GUI. - The _Access token_ here **oauthToken** - The _Access token secret_ here **oauthTokenSecret** -_Note:_ You will need a Twitter developer account -() to get the necessary keys -and tokens. +!!! NOTE + + You will need a Twitter developer account + () to get the necessary keys + and tokens. ### Configure the sample bundle diff --git a/docs/samples/xdotool.md b/docs/samples/xdotool.md index 2c53afb9..b5c9d652 100644 --- a/docs/samples/xdotool.md +++ b/docs/samples/xdotool.md @@ -5,6 +5,10 @@ the xdotool service to execute [xdotool commands](http://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html) by minimizing the currently active window. +!!! ATTENTION + + Only works on Linux + ### Prerequisites You will need a working `nodecg-io` installation. If you have non yet take a @@ -13,7 +17,7 @@ install this bundle, so take a look at the [“Try an included sample”](../getting_started/try_example_bundle.md)-Guide. It will also tell you how to log in and how to use the GUI. -- Xdotool installed (Only works on Linux) +- Xdotool installed ### Configure the Xdotool sample bundle diff --git a/docs/samples/youtube.md b/docs/samples/youtube.md index 4af41a98..29b472f8 100644 --- a/docs/samples/youtube.md +++ b/docs/samples/youtube.md @@ -16,17 +16,21 @@ will also tell you how to log in and how to use the GUI. - Google cloud API OAuth access (client ID, client Secret) - Grant `YouTube Data API v3` access at the project's dashboard. - Shortcut URL: - > + `https://console.developers.google.com/apis/library/youtube.googleapis.com?project=`. -_Note:_ If you don't have such a key yet, you can generate them like -[this](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred). -As redirect URI add . +!!! NOTE + + If you don't have such a key yet, you can generate them like + [this](https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred). + As redirect URI add: + + ### Configure the YouTube sample bundle -1. In NodeCG, create a new googleapis service instance. +1. In NodeCG, create a new googleapis service instance. -2. Enter your YouTube OAuth credentials: +2. Enter your YouTube OAuth credentials: ```json { @@ -38,13 +42,15 @@ As redirect URI add . After entering it, click save. - _Note:_ You can add multiple scopes if the googleapis instance is used for - multiple bundles. + !!! NOTE + + You can add multiple scopes if the googleapis instance is used for + multiple bundles. -3. Set the sample's (`youtube-playlist`) dependency to be the newly created - service instance (of type `googleapis`). +3. Set the sample's (`youtube-playlist`) dependency to be the newly created + service instance (of type `googleapis`). -4. Check the NodeCG logs: +4. Check the NodeCG logs: You should see an error or a success message that is hardcoded in `samples/youtube-playlist/extension/index.ts`. diff --git a/docs/stylesheets/colors.css b/docs/stylesheets/colors.css index 0b32848b..6f34a4b9 100644 --- a/docs/stylesheets/colors.css +++ b/docs/stylesheets/colors.css @@ -19,3 +19,7 @@ .md-typeset .task-list-control [type="checkbox"]:checked + .task-list-indicator::before { background: var(--md-primary-fg-color) !important; } + +.md-typeset pre > code { + white-space: pre-wrap; +} diff --git a/mkdocs.yml b/mkdocs.yml index 4c30b4d0..e3e2a279 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -33,6 +33,7 @@ markdown_extensions: - pymdownx.tabbed - pymdownx.tasklist: custom_checkbox: true + - admonition nav: - Home: index.md @@ -46,7 +47,10 @@ nav: - Basics: contribute/contribute.md - Create a Service: contribute/create_service.md - Create a sample bundle: contribute/create_sample.md - - Document a sample: contribute/sample_documentation.md + - Documentation: + - Setup: contribute/docs_setup.md + - Markdown: contribute/docs_markdown.md + - Document a sample: contribute/docs_sample.md - Contributors: contribute/contributors.md - Services: - Available services: services.md diff --git a/package.json b/package.json index e8cebc29..7a5e7943 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "compatibleRange": "^1.1.1" }, "scripts": { - "lint": "markdownlint -p ./.ignore-files.txt .", - "format": "prettier -w --ignore-path ./.ignore-files.txt **.md" + "lint": "markdownlint -p .prettierignore .", + "format": "prettier -w **.md" } }