-
Notifications
You must be signed in to change notification settings - Fork 3
Docfx #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Docfx #48
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3dc2361
Move csproj into subfolder
flibber-hk 3c0cf89
Re-commit
flibber-hk 084726f
Init docs
flibber-hk c2c64b9
Add styling
flibber-hk 315cf20
Add some articles
flibber-hk 5bbb32d
Filter plugin class
flibber-hk 85587be
Easy PR comment
flibber-hk 9f7a4d8
Add shield icon
flibber-hk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Docs | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| actions: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| concurrency: | ||
| group: pages | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.output.page_url }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: 10.x | ||
|
|
||
| - name: Build | ||
| run: dotnet build -c Release | ||
|
|
||
| - name: DocFX build | ||
| working-directory: docs | ||
| run: dnx docfx --yes | ||
| continue-on-error: false | ||
|
|
||
| - name: Upload assets | ||
| uses: actions/upload-pages-artifact@v4 | ||
| with: | ||
| path: docs/_site | ||
|
|
||
| - name: Deploy | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [submodule "docs/silksong-modding-style-docfx"] | ||
| path = docs/silksong-modding-style-docfx | ||
| url = https://github.com/silksong-modding/silksong-modding-style-docfx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| <Solution> | ||
| <Project Path="Silksong.DataManager.csproj" /> | ||
| <Project Path="src/Silksong.DataManager.csproj" /> | ||
| </Solution> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /**/DROP/ | ||
| /**/TEMP/ | ||
| /**/packages/ | ||
| /**/bin/ | ||
| /**/obj/ | ||
| _site | ||
| /api/*.yml | ||
| /api/.manifest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Data Types | ||
|
|
||
| DataManager supports global data, which is an alternative to BepInEx configuration, and per-save data | ||
| which is effectively a modded extension to save data. | ||
|
|
||
| All data types are handled by generic interfaces, such as `IGlobalDataMod<T>` where T is the type of data you want to | ||
| store. DataManager will automatically serialize your data as JSON at appropriate times. DataManager uses the | ||
| Newtonsoft.Json library for serialization and the serialization behavior can be altered by using Newtonsoft.Json | ||
| attributes in advanced use cases. | ||
|
|
||
| In the case that a mod needs to add its own data manually instead of or in addition to these interfaces, the paths | ||
| used by DataManager can all be found in the `DataPaths` class. | ||
|
|
||
| ## Global data | ||
|
|
||
| Global data is available for cases where data is needed across multiple saves, or outside of saves such as in the menu. | ||
| DataManager offers 2 types of global data which mod developers can choose between based on their use case. | ||
|
|
||
| ### `IProfileDataMod` | ||
|
|
||
| `IProfileDataMod<T>` is ideal for mods that want a more powerful alternative to BepInEx configuration. Data is stored | ||
| in the same location as BepInEx configuration files, which means that is scoped to your profile in the mod loader. It | ||
| is loaded when the game opens and saved when the game closes; you can access it in your plugin's `Start` method. | ||
|
|
||
| ### `IGlobalDataMod` | ||
|
|
||
| `IGlobalDataMod<T>` is an alternative to `IProfileDataMod<T>` which is saved in the save data directory, in | ||
| `<save directory>/Modded/Global/<plugin ID>.json.dat`. There are 2 benefits of this location: | ||
| 1. It will be synced across devices by Steam Cloud | ||
| 2. It will be available across multiple profiles | ||
|
|
||
| Therefore, if either of these use cases are relevant to your mod, you should use `IGlobalDataMod<T>`. Similar to | ||
| `IProfileDataMod<T>`, this data is loaded when the game opens and saved when the game closes; you can access it in | ||
| your plugin's `Start` method. | ||
|
|
||
| ## Save-specific data | ||
|
|
||
| Save-specific data is a way for your mod to add its own data to a save file. DataManager supports both mutable | ||
| and immutable data. | ||
|
|
||
| ### `IOnceSaveDataMod` | ||
|
|
||
| `IOnceSaveDataMod<T>` provides immutable data which is set at the beginning of the file and never updated again. | ||
| It is stored in `<save directory>/Modded/userN/OncePerSave/<mod ID>.json.dat`. Data is saved when a game starts, | ||
| specifically at the end of `GameManager.StartNewGame` and loaded when loading into a file. Immutable data results | ||
| in fewer disk operations which makes the game more performant, so developers are encouraged to use it when possible. | ||
|
|
||
| ### `ISaveDataMod` | ||
|
|
||
| `ISaveDataMod<T>` is used for all mutable save data. It is stored in | ||
| `<save directory>/Modded/userN/SaveData/<mod ID>.json.dat`. Data is saved when the game is saved and loaded when | ||
| loading into a file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| uid: ExamplesArticle | ||
| --- | ||
|
|
||
| # Examples | ||
|
|
||
| The following is the standard pattern for mods implementing ISaveDataMod. | ||
|
|
||
| ```csharp | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Silksong.DataManager; | ||
| using BepInEx; | ||
|
|
||
| // The Save Data class can be any serializable type | ||
| public class SaveData | ||
| { | ||
| public long TheSavedIntValue { get; set; } | ||
| } | ||
|
|
||
| [BepInAutoPlugin(id: "io.github.username.my-mod")] | ||
| [BepInDependency(Silksong.DataManager.DataManagerPlugin.Id)] | ||
| public partial class MyPlugin : BaseUnityPlugin, ISaveDataMod<SaveData> | ||
| { | ||
| private SaveData _saveData = new SaveData(); | ||
|
|
||
| [AllowNull] | ||
|
flibber-hk marked this conversation as resolved.
|
||
| public SaveData SaveData | ||
| { | ||
| get => _saveData; | ||
| set => _saveData = value ?? new SaveData(); | ||
| } | ||
|
|
||
| // rest of mod class | ||
| } | ||
| ``` | ||
|
|
||
| You can freely access members of the SaveData object; when the user enters an existing save file, | ||
| DataManager will set this to the value from the last time they used that save file, | ||
| and when the user returns to menu, it will be replaced with a new object. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Lifecycle | ||
|
|
||
| In this article, we give the times at which DataManager operations run. | ||
|
BadMagic100 marked this conversation as resolved.
|
||
|
|
||
| ## Global data | ||
|
|
||
| * DataManager loads Global and Profile data during the Plugin.Start method. | ||
| It is likely that this will run before your plugin's Start method, but this is | ||
| not guaranteed by Unity. | ||
| If you need data this early, you may want to wait a frame before accessing the data, | ||
| although this should not be necessary for most pluggins. | ||
| * DataManager writes Global and Profile data to disk when the user quits the game. | ||
| Note - this will not happen if the game crashed. | ||
|
|
||
| ## Save data | ||
|
|
||
| * When the user creates a new save file, DataManager will not do anything to SaveData mods. | ||
| It is your responsibility to construct an instance of your save data class, although this will be done | ||
| automatically if you use the example code (see <xref:ExamplesArticle>). | ||
| * When the user enters an existing save file, DataManager will set the SaveData | ||
| property to the save data from the previous time they entered the file. If there | ||
| was no save data then (e.g. if the user installed your mod after they created the save), | ||
| then DataManager will not do anything at this moment. | ||
| * Whenever the game saves, DataManager will get the SaveData property and write it to disk. | ||
| This will happen regardless of if your save data was loaded when the user entered the file. | ||
| * When the user quits to menu, DataManager will set the SaveData property to null | ||
| (after the save data gets saved to disk). | ||
| If you are using the code in the example, this will be intercepted | ||
| and a new SaveData object will be constructed (for if they enter a new file). | ||
| * When the user deletes a save file, all data managed by DataManager for that save file | ||
| will be deleted too. | ||
|
|
||
| ## OnceSaveData | ||
|
|
||
| * When the user creates a new save file, the OnceSaveData will be retrieved and written to disk. | ||
| * Whenever the SaveData is loaded for a file (or set to null), the OnceSaveData will be as well. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| - name: Getting Started | ||
| - href: ../index.md | ||
| - href: datatypes.md | ||
| - href: examples.md | ||
| - href: lifecycle.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/dotnet/docfx/main/schemas/docfx.schema.json", | ||
| "metadata": [ | ||
| { | ||
| "src": [ | ||
| { | ||
| "src": "../src", | ||
| "files": [ | ||
| "**/*.csproj" | ||
| ] | ||
| } | ||
| ], | ||
| "dest": "api", | ||
| "filter": "filterconfig.yml" | ||
| } | ||
| ], | ||
| "build": { | ||
| "content": [ | ||
| { | ||
| "files": [ | ||
| "**/*.{md,yml}" | ||
| ], | ||
| "exclude": [ | ||
| "_site/**" | ||
| ] | ||
| } | ||
| ], | ||
| "resource": [ | ||
| { | ||
| "files": [ | ||
| "images/**" | ||
| ] | ||
| } | ||
| ], | ||
| "output": "_site", | ||
| "template": [ | ||
| "default", | ||
| "modern", | ||
| "silksong-modding-style-docfx" | ||
| ], | ||
| "globalMetadata": { | ||
| "_appName": "DataManager", | ||
| "_appTitle": "DataManager", | ||
| "_enableSearch": true, | ||
| "pdf": false | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ### YamlMime:ManagedReference | ||
| apiRules: | ||
| - exclude: | ||
| uidRegex: 'Silksong\.DataManager\.DataManagerPlugin' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.