Skip to content

Contributing_Advanced

Penaz edited this page Feb 23, 2024 · 4 revisions

Contributing: Getting Started

Here you will find in-depth instructions on contributing to the book.

Getting your tools together

In this guide, we will focus on the minimum amount of tools necessary to get you to contributing as fast as possible!

Here is what you need:

You don't actually need the tools to build the book if you just want to add some text.

Preparing your Git repository

First of all, you will need to "fork" the repository: that means making your own copy of it. This way you can add everything you want and have your own "working copy".

If you have a GitHub account, just go to the main repository and look for the "fork" button:

Forking the repo 1/2

GitHub will ask for confirmation and where to fork the repository (usually, by default, it will be your personal account):

Forking the repo 2/2

After confirming the fork, you will have a copy of the repository in your GitHub account.


Now we need to configure out own local copy using Gitnuro. So let's open it. You will find yourself in front of this window:

Cloning the repo 1/5

Now we click on the "Clone a repository" button. We will see that Gitnuro asks for an URL and a folder.

Cloning the repo 2/5

Let's go on GitHub, on the repository we just cloned (on the title it should show <your_Account>/2DGD_F0TH), click on the "Code" button and copy the URL shown in the HTTPS tab.

Cloning the repo 3/5

We fill the Gitnuro interface with the URL and the folder we want to save the repository in:

Cloning the repo 4/5

After that, we click on "Clone" and wait. When the cloning is completed, we will see a new folder, called 2DGD_F0TH and Gitnuro's interface will show the status of the repository. More on that later.

Cloning the repo 5/5

Your first contribution

This ebook is written in a flavour of what is called "Markdown": a way to write pure text and add more "meaning" to it, using symbols.

To learn more about markdown, I'll leave you to the amazing guide by im-luka: You can find it here

Differences with standard Markdown

In addition to what is in standard markdown, in this book you can write "boxes", which are used to highlight trivia, pitfalls, tips and notes.

Let's imagine you want to write a "tip" box. The text would look like this:

:::: tip ::::
This is a tip box, here you will find tips that are loosely related to the chapter at hand. These small tips will help you make a better game, or wiggle your way through something difficult.
:::::::::::::

It will show in the book like this:

Tip Box

There are 5 box types you can use:

  • tip
  • pitfall
  • trivia
  • note
  • wizardry

Another difference is how code listings are inserted in the book. It is a bit convoluted but it all boils down to the following text:

```{src="introduction/example" caption="Example code listing"}
```

This piece of code will automatically take the piece of code that is named "example" from the "introduction" subfolder under every folder in dynamic_listings and add "Example code listing" as a caption.


Another difference is math: this book uses LaTeX's math mode, so each formula is enclosed in one or two dollar symbols.

One dollar symbol per side will create an "inline" formula, while using two per side will put the formula on its own.

Here's an example of a math formula:

$$a \land b = c$$

This will show the following formula, in a line on its own, separated from the rest of the text:

Simple Formula

Writing your first contribution

To write your contributions, you will need a Markdown Editor. You can use Ghostwriter (which also has a nice integrated Markdown Cheatsheet!)

First thing is configuring: you just need to go on Settings -> Preview Options and select "Pandoc" as Markdown Flavour. Some of the customizations will now show properly (like images, due to how the book is currently structures, or code listings, because they're injected at build-time).

Configuring Ghostwriter

Now you can open one of the book files and start writing:

Writing in Ghostwriter 1/3

As you write more, the preview on the right side of the screen will update accordingly.

Writing in Ghostwriter 2/3

Now that we've written an entire section, we can save and get to the next step.

Writing in Ghostwriter 3/3

It is best to keep our edits small and commit them often, instead of giving huge contributions in one single commit: it makes checking them a lot easier.

Committing your contribution

Now we will open Gitnuro again, and do what is called a "commit": a way to write in stone (in the project history) our contribution, so it can be traced and saved.

Gitnuro will show something new: first thing is the "Uncommitted Changes" message on top of the graph, and second thing is the file we changed is now showing in the "Unstaged" area.

Committing our first contribution 1/5

Now we will add our edited file to the "staging area" by clicking on the "stage" button that appears when we hover on the file.

Committing our first contribution 2/5

Now the file will have moved to the "staging area". On the top right of the screen.

Committing our first contribution 3/5

The only thing left to do is writing a very short comment about what we did and click on the "commit" button.

Committing our first contribution 4/5

You can see that our new commit appears on the top of the graph. If we want to update our online version, we just need to press the "Push" button. It's possible that Gitnuro will request your GitHub credentials, that is normal.

Sending a pull request

Now that you have updated your GitHub copy, you can create a merge request towards the official repository, to have your contribution officially added to the book.

First thing, you need to go to your own copy of the book on GitHub and click on the "Pull Requests" tab. From there, click on "Pull Requests", from there click on the "New Pull Request" button.

Sending a pull request 1/3

From here you may need to click on the "Compare across forks" link and make sure that the repository on the left (the one receiving the pull request) is the original book repository (2DGD_F0TH/2DGD_F0TH), while the one on the right is your personal fork that we created at the beginning.

Sending a pull request 2/3

If everything is correct, you will see the page changing and showing the differences between your edited copy (on the right) and the current copy of the book (on the left). After that you can click on "Create Pull Request".

From here, just compile the small questionnaire (it will make it easier to understand what changes have been made and why) and then click on "Create pull request".

Sending a pull request 3/3

Congratulations, you have successfully contributed to the book!