Skip to content

Commit

Permalink
📝 finished most of the important docs
Browse files Browse the repository at this point in the history
Co-Authored-By: Sammi Deftu <62822374+Deftu@users.noreply.github.com>
  • Loading branch information
asoji and Deftu committed Aug 10, 2024
1 parent dae4345 commit 4e6cbdd
Show file tree
Hide file tree
Showing 23 changed files with 254 additions and 10 deletions.
46 changes: 45 additions & 1 deletion Writerside/cfg/static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@
* {
scrollbar-width: auto;
scrollbar-color: var(--actual-primary-color) #ffffff;
scrollbar-gutter: stable;
}

/* Chrome, Edge, and Safari */
*::-webkit-scrollbar {
width: 0.5em;
scrollbar-gutter: stable;
}

*::-webkit-scrollbar-track {
Expand All @@ -156,6 +158,7 @@
border: 1px transparent;
}


/* starting page card */
.starting-page-card {
border-radius: 0.5em;
Expand All @@ -164,7 +167,22 @@

.starting-page-card:hover, .starting-page-title__card:hover {
border: 1px solid var(--wh-color-primary);
animation: cardpulse 2s infinite !important; /* WHY IS THIS NOT WORKING */
animation: cardpulse 2s infinite !important;
mask-image: none;
}

.see-also__card {
border-radius: 0.5em;
border: 1px solid var(--primary-color-25);
border-bottom-color: var(--primary-color-25) !important; /* YOU. YOU FUCKER. */
mask-border: unset;
mask-image: unset;
}

.see-also__card:hover {
border: 1px solid var(--wh-color-primary);
border-bottom-color: var(--wh-color-primary) !important; /* YOU. YOU FUCKER. */
animation: cardpulse 2s infinite !important;
mask-image: none;
}

Expand Down Expand Up @@ -349,6 +367,27 @@ i could do */
}
}

.prompt__wrapper--type-tip {
animation: tipadmonitionpulse 2s infinite;
}

@keyframes tipadmonitionpulse {
0% {
transform: scale(1);
box-shadow: 0 0 0 0 var(--wh-color-tip);
}

70% {
transform: scale(1);
box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
}

100% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
}

.article__figure .article__img {
border-radius: 0.5em;
}
Expand Down Expand Up @@ -400,4 +439,9 @@ i could do */
.navigation-links__next {
font-family: "Eudoxus Sans", sans-serif;
font-weight: bold;
}

.navigation-links__prev {
font-family: "Eudoxus Sans", sans-serif;
font-weight: bold;
}
8 changes: 4 additions & 4 deletions Writerside/docs.tree
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
<toc-element topic="Yiski5-Commands.md"/>
<toc-element topic="Yiski6-Commands.md"/>
</toc-element>
<toc-element topic="Runner.topic" toc-title="Runner"></toc-element>
<toc-element topic="Modules-Loader.topic" toc-title="Modules Loader">
</toc-element>
<toc-element topic="Modules.md">
<toc-element topic="Runner.md" toc-title="Runner"></toc-element>
<toc-element topic="Modules-Loader.md">
<toc-element topic="Modules-Metadata.md"/>
<toc-element topic="Modules.md"/>
</toc-element>

<toc-element toc-title="GitHub Repo" href="https://github.com/devOS-Sanity-Edition/Yiski"></toc-element>
</instance-profile>
1 change: 1 addition & 0 deletions Writerside/topics/About-Configs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# About Configs
<format style="italic">by asojidev</format>

## Why are these configs needed?

Expand Down
84 changes: 84 additions & 0 deletions Writerside/topics/Modules-Loader.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Module Loader
<format style="italic">by Deftu</format>

## Initial setup

For the module loader to know where and how to discover modules, you need to register [discoverers](#discovery), and then call the `ModuleLoader#discover` function. This function will give you a set of module metadata objects which contain all relevant information needed to set up a module and have it interact with our main runner.

## Entrypoints

The module loader uses an entrypoint system to allow modules to have their own logic run elsewhere (including inside other modules!). Using it is as simple as loading the module into the current classpath then passing a reference to their class into `ModuleLoader#loadEntrypoint`. Not only does this create an instance of the class given to it, but it allows the caller to pass their own constructor arguments to it. This **IS** validated at creation time to ensure that there are no future issues.

## Loading your own entrypoints

To create your own entrypoint instance, you'll need a reference to a class implements it. For example,

```kotlin
package com.example

import one.devos.yiski.module.loader.api.entrypoints.Entrypoint

interface MyEntrypoint : Entrypoint {

fun meow()

}

class MyEntrypointImpl : MyEntrypoint {

override fun meow() {
println("Meow")
}

}
```


```kotlin
package com.example

import one.devos.yiski.module.loader.impl.ModuleLoader

val moduleLoader: ModuleLoader = ...
val clz: Class<*> = Class.forName("com.example.MyEntrypointImpl")
val entrypoint = moduleLoader.loadEntrypoint(clz) as MyEntrypoint
```

## Obtaining another module's metadata

Each module has its own ID, which is unique to that module. This ID can be used to obtain other modules' metadata (and thus, their entrypoints). This can be achieved using `ModuleLoader#getMetadataFor`.

Alternatively, if you need the metadata of all currently loaded modules, `ModuleLoader#getModules` is exposed.

## Discovery

Modules are discovered via implementations of `ModuleDiscoverer`, which provides a set of paths (either physical or virtual) in which modules _will_ be stored. Potential duplicate modules will overwrite one another, the last found duplicate taking precedence.

> At least one discoverer is required for any modules to be discovered! Without a discoverer registered, no modules will be loaded.
{style="note"}

### Default discoverers

`ClasspathModuleDiscoverer`
: Discovers any modules currently loaded. It's best practice to always register this loader first to avoid unnecessary duplicates.

`JarModuleDiscoverer`
: Loads all modules within JAR files in it's given path. For example, if given the `modules` relative path, it would iterate through every `.jar` file inside that path in an attempt to identify a module. (f.ex, `/home/example/yiski/modules/module1.jar`, `/home/example/yiski/modules/module2.jar`, etc)

### Discovery pipeline

- First, all module discovers are called (and forcibly made distinct to avoid duplicates)
- Then, we begin iterating through each path returned by the module discoverers
- If the path is for a file,
- We load the file as a JAR file, then searching it's root for a `yiski.metadata.toml` ([see the module metadata](Modules-Metadata.md))
- If we find one, we read its contents into our metadata list and load the JAR file into our current classpath
- Otherwise, if the path points to a directory,
- We simply look for a `yiski.metadata.toml` inside the directory, and read its contents into our metadata list
- Finally, we read and validate all the sources in our metadata list, creating a list of all of our newly parsed `ModuleMetadata` objects
- These are then added to our loaded modules list and returned to the call of the `ModuleLoader#discover` function

<seealso style="cards">
<category ref="related-modules-data" >
<a href="Modules-Metadata.md" summary="Take a look at how the Modules Metadata is done and its relevancy."></a>
</category>
</seealso>
55 changes: 54 additions & 1 deletion Writerside/topics/Modules-Metadata.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Modules Metadata
<format style="italic">by asojidev</format>

> Work in Progress
> The Metadata is still a work in progress, this shows the current utilized draft of Yiski's Module Metadata.
{style="warning"}

Every module needs its own Metadata file, a file that contains information about what to load.
Expand All @@ -20,7 +21,59 @@ information about itself.
</tab>
</tabs>

> Assume all fields here are required unless specified otherwise.
{style="note"}

## Metadata

`version`
: Config version, **do not EVER** touch unless you know what you're doing.

## Runner

`mainClass`
: Main entrypoint for Runner to pick up and execute code on

## Module

`configClass`
: Config class to allow a module to be configurable through a file

### Packages

> Package paths are optional, but required if you're using anything related to Tables or Slash Commands
{style="note"}

> Do not point these to a file, point it to the package containing the classes/objects.
`databasePackage`
: Your module's package for where all the SQL/Exposed SQL Tables are stored

`slashCommandsPackage`
: Your module's package for where all the Slash Commands are stored

## Information

`id`
: The ID for your module

`name`
: The Name of your module

`description`
: What your module does/add

`version`
: Version of your module

`repo`
: Link to the repository where your module is

`license`
: The License your module uses

`authors`
: An array of names of people who have contributed to the module

<seealso>
<!--Provide links to related how-to guides, overviews, and tutorials.-->
Expand Down
20 changes: 20 additions & 0 deletions Writerside/topics/Modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Modules
<format style="italic">by Deftu</format>

Each module must provide its own implementation of `YiskiModuleEntrypoint` and `ConfigSetupEntrypoint`, and then provide the full path to both implementations in their respective fields of its `yiski.metadata.toml`.

## Creating your main entrypoint

Implementations of `YiskiModuleEntrypoint` **must** take a `DatabaseManager`, `Aviation`, `JDA` and `AbstractYiskiConfig` (in that order) in their constructor.

The `setup` function from the entrypoint can be used for listening to JDA/Aviation events, checking properties in the module's entrypoint, etc. It's good practice to perform any Discord-relating logic inside a listener for `ReadyEvent`.

## Creating your config setup entrypoint

No constructor arguments are passed down to `ConfigSetupEntrypoint`s, making their implementation very simple. Your module **must** provide some kind of implementation of `AbstractYiskiConfig`, that being the object which contains config data. The `read` function itself does not return anything, instead `ConfigSetupEntrypoint` opts for you to use that function to set the `config` property found inside of your implementation.

<seealso style="cards">
<category ref="related-modules-data" >
<a href="Modules-Metadata.md" summary="Take a look at how the Modules Metadata is done and its relevancy."></a>
</category>
</seealso>
1 change: 1 addition & 0 deletions Writerside/topics/Runner-Config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Runner
<format style="italic">by asojidev</format>

Download <resource src="config.toml"/> and put it in the same folder as your Runner.

Expand Down
27 changes: 27 additions & 0 deletions Writerside/topics/Runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Yiski's Main Runner
<format style="italic">by Deftu</format>

The bot's launch entrypoint, or main runner, is responsible for initially setting up JDA, database management, etc.
Of course, it is also responsible for managing each of the bot's modules using the module loading system.

## Initial startup

In order of its functionality:

- It will first discover and load any available modules,
- Then extract any necessary initial startup entrypoints (these being the `ConfigSetupEntrypoint` and the `YiskiModuleEntrypoint`).
- Available `ConfigSetupEntrypoint`s will then be read and validated to ensure that all config files are correct.
- Each module's database package will then have all of its tables registered with Exposed.
- Finally, we can now begin setting up JDA and Aviation. Inside which, all modules will have their slash commands registered.
- After we have a functioning instance of JDA, we can then inform each of our modules that it's time for setup. **At this stage, we are unaware of if JDA was able to log in. The setup function call is not done in alignment with JDA's `ReadyEvent`.**

## Consequent interference

After the main runner has done its purpose in allowing the modules to interface with its centralized instance of JDA, it will not be interfering with the functionality of the bot any further. The only events the main runner listens to inside of JDA are for logging out the bot's current online state and syncing commands in **test guilds**.

<seealso style="cards">
<category ref="modules">
<a href="Modules-Loader.md" summary="How the Module Loader works"></a>
<a href="Modules.md" summary="How Modules work"></a>
</category>
</seealso>
6 changes: 3 additions & 3 deletions Writerside/topics/Welcome.topic
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
<!-- Add several topics that are less important or are relevant only for advanced/experienced users. -->
<secondary>
<title>Want to create a Yiski module or contribute to Yiski's development?</title>
<a href="" summary="How does the Runner operate? and more.">Runner</a>
<a href="" summary="Everything you need to know about Modules.">Modules</a>
<a href="" summary="What does the Modules Loader... load?">Modules Loader</a>
<a href="Runner.md" summary="How does the Runner operate? and more.">Runner</a>
<a href="Modules.md" summary="Everything you need to know about Modules.">Modules</a>
<a href="Modules-Loader.md" summary="What does the Modules Loader... load?">Modules Loader</a>
<a href="https://github.com/devOS-Sanity-Edition/Yiski" type="open-source" summary="To the source code we go!">GitHub Repository</a>
</secondary>
</section-starting-page>
Expand Down
3 changes: 2 additions & 1 deletion Writerside/topics/Yiski-Bot-Setup.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Bot Setup
<format style="italic">by asojidev</format>

Want to run Yiski on your own? Well, it's a little bit involved, but here's how to set it up.

Expand All @@ -22,7 +23,7 @@ Here's what you must have installed before tackling self-hosting this bot.
<p>If you already know how to setup a Discord bot, go ahead and skip this. Just be sure to give it full Administrator privileges, and the Presence, Server Members, and Message Content intent.</p>
</tldr>

#### Discord
### Discord

<procedure title="Discord Setup" id="discord_setup">
<step>
Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# What is Yiski?
<format style="italic">by asojidev</format>

<img src="yiski_banner.png" alt="Yiski Logo" height="300"></img>

Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski1-Commands.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Yiski1
<format style="italic">by asojidev</format>

# Basic

Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski1-Config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Yiski1
<format style="italic">by asojidev</format>

Download <resource src="yiski1.config.toml"/> and put it in the same folder as your Runner.

Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski2-Commands.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Yiski2
<format style="italic">by asojidev</format>

Currently empty for now as work on Yiski2 has not started yet.
1 change: 1 addition & 0 deletions Writerside/topics/Yiski2-Config.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Yiski2
<format style="italic">by asojidev</format>

Currently empty for now as work on Yiski2 has not started yet.
1 change: 1 addition & 0 deletions Writerside/topics/Yiski3-Commands.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Yiski3
<format style="italic">by asojidev</format>

## Silly

Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski3-Config.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Yiski3
<format style="italic">by asojidev</format>

Download <resource src="yiski3.config.toml"/> and put it in the same folder as your Runner.

Expand Down
1 change: 1 addition & 0 deletions Writerside/topics/Yiski4-Commands.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Yiski4
<format style="italic">by asojidev</format>

Currently empty for now as work on Yiski4 has been indecisive.
Loading

0 comments on commit 4e6cbdd

Please sign in to comment.