Skip to content

Commit 609592e

Browse files
committed
meta: refine contribution guide
The contributing guide was partly outdated, mentioning to run Hugo for building / previewing the site and was generally confusingly written, exhibiting a non-linear style. Update it such that it can now be read linearly, outlining the new preview / build process, explaining the markdown features we want contributors to use. We also now have a quick rundown of the superficial repository structure, hopefully enabling contributors to find relevant files faster when they're viewing the source tree. Also refine the commit message rambling to be clearer about the why of various requirements, such as the 50 (72) character header limit (GitHub breaks them at 72). Give hints as to when one should better split up their changes and when to use the commit message body. Explain what we use a sign-off for and reiterate that it is not required. As was recently the case, also mention what happens when there is a larger batch of pull requests open and why we don't merge them immediately one-by-one. Signed-off-by: Luca Zeuch <[email protected]>
1 parent 420fa23 commit 609592e

File tree

1 file changed

+149
-95
lines changed

1 file changed

+149
-95
lines changed

.github/CONTRIBUTING.md

Lines changed: 149 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,205 @@
11
# Contributing Guidelines
22

3-
## <a name="question"></a> Got a Question?
3+
## Got a Question?
44

5-
Please do not open issues for general support such as "how to do reaction roles" — use the
6-
[support server](https://discord.gg/4udtcA5) for that.
5+
We welcome suggestions for improving the documentation on our issue tracker—outdated information, missing items, typos,
6+
or clarity issues are all relevant.
77

8-
To keep this tracker clean, we will systematically close issues regarding general support and redirect to the
9-
aforementioned support server.
8+
General support queries and possible bugs in YAGPDB are **not** in scope and will be closed without comment; use the
9+
[support server] instead.
1010

11-
## <a name="bug"></a> Found a Bug?
11+
[support server]: https://discord.gg/4udtcA5
1212

13-
Do **not** use this tracker to file maybe-bugs in YAGPDB. We have a dedicated channel on the support server for that, to
14-
which you can post after it was confirmed to be one.
1513

16-
Should there be general issues with the documentation (grammatical structure, general flow, clarification needed), do
17-
feel free to open an issue clearly outlining what is wrong about it and consider suggesting how to fix it.
14+
## Submission Guide
1815

19-
## Submission Guidelines
16+
Thanks for contributing to the YAGPDB documentation! Please take a moment to review this document in order to make the
17+
contribution process easy and effective for everyone involved.
2018

2119
### Requirements
2220

23-
- An [editorconfig](https://editorconfig.org)-capable (text) editor.
24-
- The latest extended release of [Hugo](https://gohugo.io).
25-
- Optional: a webserver to serve a release build of the website.
21+
Small changes can be authored directly using the GitHub web interface, though we highly recommend an
22+
[EditorConfig]-capable editor like VSCode or Neovim for any extended work.
23+
24+
To preview your changes locally, you will also need [Node.js], [NPM], and the latest **extended** release of [Hugo]. NPM
25+
should come along with installing Node.js by default.
26+
27+
[Node.js]: https://nodejs.org/en
28+
[NPM]: https://www.npmjs.com/
29+
[Hugo]: https://gohugo.io/installation
30+
[EditorConfig]: https://editorconfig.org/
2631

2732
### Instructions
2833

29-
1. Search this repo's issues and pull requests tab for any open or closed PRs / issues that relate to your submission.
30-
You wouldn't want to duplicate existing efforts.
34+
The usual set of steps to contribute to anything hosted on GitHub applies: fork the repository, clone the fork,
35+
cut a new branch from `master`, make and commit your changes, and submit a pull request. We've outlined key parts of
36+
this process below.
37+
38+
> [!TIP]
39+
> Though you could work directly on the `master` branch, it is recommended to isolate your changes into a separate
40+
> branch. This way, you can work on multiple contributions simultaneously without them interfering with each other.
41+
> To create a new branch, simply run `git switch -c <branch-name> master` in the cloned repository.
42+
43+
#### Preparing Your Environment
3144

32-
2. [Fork](https://github.com/botlabs-gg/yagpdb-docs-v2/fork) and then clone your fork.
45+
In your local clone, install the required dependencies via NPM by running the following command:
3346

34-
3. In your cloned repository, make your changes on a new branch stemming from `master`:
47+
```shellsession
48+
$ npm install
49+
```
3550

36-
```shell
37-
git switch -c my-branch master
38-
```
51+
This will ensure that you can fully build the documentation site locally, including the custom syntax highlighting we
52+
use.
3953

40-
4. Launch the Hugo development environment via `hugo server`. It'll watch your worktree for changes and reload the page
41-
when changes are detected.
54+
#### Making Your Changes
4255

43-
5. Make your changes, ensuring that the page still builds in release mode via `hugo`. You may need to run `hugo mod
44-
vendor` prior to that.
56+
##### Markdown Features
4557

46-
6. Commit your changes using a descriptive commit message following our [commit message conventions](#commit). As a nice
47-
bonus, GitHub should automatically fill in the [pull request template](PULL_REQUEST_TEMPLATE.md) with your formatted
48-
message, saving you some work.
58+
The documentation is written in Markdown, with some additional shortcodes provided by the [Doks theme]; refer to its
59+
documentation for a complete list of features. If you are writing or editing custom command-related code, please use the
60+
`yag` language in fenced code blocks for accurate syntax highlighting:
4961

50-
7. Push your branch to GitHub:
62+
````markdown
63+
```yag
64+
{{/* your YAGPDB custom command code here */}}
65+
```
66+
````
5167

52-
```shell
53-
git push origin my-branch
54-
```
68+
For consistency within the raw Markdown, please **do not** use the four-space indentation for code blocks, even if you
69+
don't intend on highlighting them.
5570

56-
8. On GitHub, submit a pull request to `botlabs-gg:master`
71+
Use headers if possible to structure your content more clearly. Hugo will generate a table of contents based on those
72+
headers, displaying up to `h3` (`###`) headers on the right side of the page. Algolia indexes by section (which headers
73+
introduce), so it's beneficial to have a clear structure to improve search results.
5774

58-
Lastly, if you are unsure where to place a potential new file, do not hesitate to ask either on the support server or
59-
open an issue.
75+
Ensure each header is unique in its respective file—if necessary, you can give them a custom ID to make them unique:
6076

61-
## <a name="commit"></a> Commit Message Format
77+
```markdown
78+
### non-unique header{#my-unique-id}
79+
```
6280

63-
Formatting commit messages according to a specification makes it easier to parse and read commit history.
81+
This issue tends to especially arise on levels with a lower level of granularity, like `h4` (`####`) or `h5` (`#####`).
82+
It helps to have a linter or similar tools that tell you when a header becomes ambiguous.
6483

65-
Each commit message consists of a header, a body, and a footer:
84+
##### Repository Structure
6685

6786
```txt
68-
<header>
69-
<blank line>
70-
<body>
71-
<blank line>
72-
<footer
87+
content/
88+
├── docs/
89+
│ ├── core/
90+
│ ├── custom-commands/
91+
│ ├── fun/
92+
│ ├── moderation/
93+
│ │ └── advanced-automoderator/
94+
│ ├── notifications/
95+
│ ├── reference/
96+
│ │ └── templates/
97+
│ ├── tools-and-utilities/
98+
│ └── welcome/
99+
└── learn/
100+
├── beginner/
101+
├── intermediate/
102+
└── welcome/
73103
```
74104

75-
The `header` is *mandatory* and must conform to the [commit header](#commit-header) format.
105+
All page files are located in the `content/` directory, with the documentation being in the `docs/` subdirectory and the
106+
learning resources in `learn/`. From there on, we separate `docs/` into categories as seen on the control panel, with
107+
the actual pages representing whichever feature is in said category.
76108

77-
The `body` is *strongly recommended*. The [commit body](#commit-body) structure describes how it should be used.
109+
If you wish to include images, please store them alongside the file you're including the image in, similar to how it is
110+
already the case with the existing images and pages.
78111

79-
The `footer` is *optional*. The [commit footer](#commit-footer) format describes what the footer is used for.
112+
[Doks theme]: https://getdoks.org/docs/
80113

81-
### <a name="commit-header"></a> Commit Message Header
114+
#### Previewing Your Changes
82115

83-
```txt
84-
scope>: <short summary>
85-
| |
86-
| └─> Summary in imperative present tense. Not capitalized. No period at the end.
87-
|
88-
└─> Commit Scope: Where did this commit happen?
89-
e.g. core, customcommands, moderation, meta, repo, ...
90-
```
116+
In order to preview your changes locally, you will need to run a local instance of the documentation site. Assuming that
117+
you have Node.js (and NPM) and Hugo installed, you can do so by running the following command:
91118

92-
#### Scope
119+
```shellsession
120+
$ npm run dev
121+
```
93122

94-
The scope should be descriptive. If your commit contained multiple scopes, consider splitting them up appropriately and
95-
sending individual pull requests should they not be tightly knit together.
123+
This will run a local server on `http://localhost:1313` that will automatically update whenever you save a file, though
124+
without our custom syntax highlighting. If you prefer to view the site as it would appear on production, run the
125+
following commands instead:
96126

97-
There isn't a set list you have to pick from. Choose whatever seems most appropriate and most descriptive.
127+
```shellsession
128+
$ npm run build && npm run preview
129+
```
98130

99-
#### Summary
131+
This will build the site, execute the highlighting post-processor, and run a local server on `http://localhost:4173`.
100132

101-
Use the summary to provide a succint description of the change.
133+
#### Committing Your Changes
102134

103-
* Use the imperative, present tense: "change", not "changed" nor "changes". Think of it as if you're giving the codebase
104-
the instruction to *do this* in order to achieve the new desired state.
105-
* don't capitalise the first letter
106-
* no dot (.) at the end
107-
* in total no longer than 50 characters
135+
Once you are happy with your changes and ensured that the page builds without errors, you can commit your changes. We
136+
have a small set of rules for commit messages, which help both you and us keep track of changes more easily.
108137

109-
Some people use email to receive and send commits around, having long headers makes listing them not very nice. Any
110-
decent git-aware editor should tell you when you're exceeding these 50 characters.
138+
A commit message consists of a header, a body, and a footer:
111139

112-
### <a name="commit-body"></a> Commit Message Body
140+
```txt
141+
<header>
142+
<blank line>
143+
<body>
144+
<blank line>
145+
<footer>
146+
```
113147

114-
Just as in the summary, use the imperative, present tense: "fix", not "fixed", nor "fixes".
148+
The header is mandatory and should ideally be limited to about 50 characters. GitHub will automatically break the header
149+
line once it exceeds 72 characters, so consider that the hard limit. If your change is trivial enough, like a typo or
150+
fixing a broken link, the header is all you need. It should be written in the imperative mood and be descriptive of what
151+
precisely was changed.
115152

116-
Explain the motivation for the change in the commit message body. This part should explain *why* you are making that
117-
change and cleanly summarise what was changed for easier viewing in git logs.
153+
```diff
154+
- Update README.md
155+
+ readme: fix broken link to support server
156+
```
118157

119-
Lines should be broken at 72 characters, unless you are including a terminal log dump, then do not break the lines. Any
120-
decent git-capable editor should do this automatically for you.
158+
If you find yourself struggling to concisely summarize your changes in the header, consider splitting them up into
159+
multiple commits or perhaps even multiple PRs if appropriate.
121160

122-
### <a name="commit-footer"></a> Commit Message Footer
161+
For more sophisticated changes that require a bit more context (and summary), you can add a body. Simply insert a blank
162+
line after the header and write your body text. The body should be wrapped at 72 characters as well, but if you paste
163+
logs or other pre-formatted output, please do not wrap those lines. Like the header, the body should be written in the
164+
imperative mood, as if you were giving the codebase a command to apply the changes.
123165

124-
The footer can contain information about breaking changes (if any) and is also the place to reference GitHub issues and
125-
other pull requests that this commit closes, or is related to, as well as Co-Authors:
166+
The footer is optional and should be used to reference issues or pull requests that are related to the commit. You can
167+
also use it to close issues or pull requests by inserting `Closes #<issue-number>` or `Fixes #<issue-number>`. This is
168+
also the place where you can add a `Signed-off-by` line, certifying that you have the right to submit the code under
169+
[the license](../LICENSE) we publish this documentation under.
126170

127171
```txt
128-
BREAKING CHANGE: <breaking change summary>
129-
<blank line>
130-
<breaking change description + migrate instructions>
131-
<blank line>
132-
<blank line>
133-
Closes #<issue number>
134-
<blank line>
135-
<blank line>
136-
Co-authored-by: name <[email protected]>
172+
Signed-off-by: John Doe <[email protected]>
137173
```
138174

139-
We also recommend you sign-off your commits with `git commit -s`, thereby certifying the
140-
[Developer Certificate of Origin](https://developercertificate.org/) and that you read these guidelines. If you do so,
141-
include your realname and a proper email.
175+
Your sign-off should be with an identity that can be associated with you—for us, your GitHub username is sufficient, but
176+
please make sure that your email address is valid and reachable (so no `noreply`-addresses). Git will automatically
177+
append your sign-off to the commit message when you use the `-s` flag when committing, assuming you have properly
178+
configured your committer identity.
179+
180+
> [!NOTE]
181+
> *We* do **not** require you to sign off on your commits, but it is a good practice to do so. Some projects may
182+
> actually require it and attach a bigger legal meaning to it, so it's good to get into the habit of doing it.
183+
184+
### Submitting the Pull Request
185+
186+
Once you have committed your changes, push your branch to your fork on GitHub and open a pull request against the
187+
`master` branch of the main repository. If you prefer the CLI, GitHub provides a [CLI tool] that can help you with that.
188+
189+
[CLI tool]: https://cli.github.com/
142190

143-
#### Revert commits
191+
> [!TIP]
192+
> Using a header and body in your commit message will automatically fill in the pull request title and description on
193+
> GitHub, respectively, saving you some typing work you'd have to do anyway.
144194
145-
If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit.
146-
Obviously the header length limit of 50 characters does not apply to this.
195+
Once your pull request is opened, some automated checks will run on it, and it will be reviewed by one of the
196+
maintainers. Make sure to check back in a timely manner, you may already have received feedback!
197+
Once everything is in order and the changes are approved, your pull request will be merged into the main repository.
147198

148-
The content of the commit message body should contain:
199+
Fret not if your pull request was only approved but not merged immediately. If there's a larger batch of changes that
200+
need merging, we will merge them all at once as to not spam the GitHub servers with a bunch of deployments and
201+
Algolia Docsearch with a ton of re-crawls.
149202

150-
* information about the SHA of the commit being reverted in the following format: `This reverts commit <SHA>`,
151-
* a clear description of the reason for reverting the commit message.
203+
> [!NOTE]
204+
> If you prefer to use email to send your commits (for example because you don't have a GitHub account), please send
205+
> your patches to `[email protected]` using `git send-email`.

0 commit comments

Comments
 (0)