Skip to content

Commit

Permalink
[Docs] Fix inline code blocks and misc tweaks. (#2878)
Browse files Browse the repository at this point in the history
* Fix code blocks and list items having overlap if they contain code blocks.

* Fixes for interaction framework intro guide.

* Add NuGet icon to top navbar.

* tweak action triggers

* Fix mobile navbar links.

* Add relatively ugly hack to improve toc filter functionality.

---------

Co-authored-by: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com>
  • Loading branch information
AnalogFeelings and Misha-133 authored Mar 15, 2024
1 parent 4efe3be commit 3331614
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- '*'
paths:
- 'docs/**'
branches:
- 'dev'
workflow_dispatch:
pull_request:
paths:
Expand Down
16 changes: 14 additions & 2 deletions docs/_template/material/public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,20 @@ code {
}

/* MAKES PARAMETERS MORE SPACIOUS */
dl.parameters > dt > code {
padding: 3px;
:not(pre) > code {
padding: 3px;
}

/* MAKES LIST ITEMS BE SLIGHTLY MORE SEPARATED */
/* THIS AVOIDS CODE BLOCK OVERLAP */
ul:not(.navbar-nav) > li:not(:last-child) {
margin-bottom: 4px;
}

/* MAKES NAVBAR LINKS LOOK BETTER IN MOBILE */
.navbar-expand-md .navbar-nav .nav-link {
padding-right: var(--bs-navbar-nav-link-padding-x);
padding-left: var(--bs-navbar-nav-link-padding-x);
}

/* MAKES INHERITANCE LIST READABLE */
Expand Down
61 changes: 58 additions & 3 deletions docs/_template/material/public/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,69 @@
export default {
iconLinks: [
export default
{
iconLinks:
[
{
icon: 'github',
href: 'https://github.com/discord-net/Discord.Net',
title: 'GitHub'
},
{
icon: 'box-seam-fill',
href: 'https://www.nuget.org/packages/Discord.Net/',
title: 'NuGet'
},
{
icon: 'discord',
href: 'https://discord.gg/dnet',
title: 'Discord'
}
]
],
start: () =>
{
// Ugly hack to improve toc filter.
let target = document.getElementById("toc");
let config = { attributes: false, childList: true, subtree: true };
let observer = new MutationObserver((list) =>
{
for(const mutation of list)
{
if(mutation.type === "childList" && mutation.target == target)
{
let filter = target.getElementsByClassName("form-control")[0];

let filterValue = localStorage.getItem("tocFilter");
let scrollValue = localStorage.getItem("tocScroll");

if(filterValue && filterValue !== "")
{
filter.value = filterValue;

let inputEvent = new Event("input");
filter.dispatchEvent(inputEvent);
}

// Add event to store scroll pos.
let tocDiv = target.getElementsByClassName("flex-fill")[0];

tocDiv.addEventListener("scroll", (event) =>
{
if (event.target.scrollTop >= 0)
{
localStorage.setItem("tocScroll", event.target.scrollTop);
}
});

if(scrollValue && scrollValue >= 0)
{
tocDiv.scroll(0, scrollValue);
}

observer.disconnect();
break;
}
}
});

observer.observe(target, config);
}
}
14 changes: 9 additions & 5 deletions docs/guides/int_framework/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ A new module instance is created before a command execution starts then it will

Every module class must:

- be public
- inherit [InteractionModuleBase]
- Be public
- Inherit from [InteractionModuleBase]

Optionally you can override the included :

Expand Down Expand Up @@ -61,7 +61,7 @@ Valid **Interaction Commands** must comply with the following requirements:
|[Autocomplete Command](#autocomplete-commands)| `Task`/`Task<RuntimeResult>` | - | - | `[AutocompleteCommand]`|

> [!NOTE]
> a `TypeConverter` that is capable of parsing type in question must be registered to the [InteractionService] instance.
> A `TypeConverter` that is capable of parsing type in question must be registered to the [InteractionService] instance.
> You should avoid using long running code in your command module.
> Depending on your setup, long running code may block the Gateway thread of your bot, interrupting its connection to Discord.
Expand Down Expand Up @@ -94,13 +94,17 @@ By default, your methods can feature the following parameter types:
- `sbyte`, `byte`
- `int16`, `int32`, `int64`
- `uint16`, `uint32`, `uint64`
- `enum` (Values are registered as multiple choice options and are enforced by Discord. Use the `[Hide]` attribute on enum values to prevent them from getting registered.)
- `enum`
- `DateTime`
- `TimeSpan`

> [!NOTE]
> Enum values are registered as multiple choice options and are enforced by Discord. Use the `[Hide]` attribute on enum values to prevent them from getting registered.
---

**You can use more specialized implementations of [IChannel] to restrict the allowed channel types for a channel type option.*
**You can use more specialized implementations of [IChannel] to restrict the allowed channel types for a channel type option.**

| interface | Channel Type |
|---------------------|-------------------------------|
| `IStageChannel` | Stage Channels |
Expand Down

0 comments on commit 3331614

Please sign in to comment.