Skip to content

How To Contribute?

ClementSparrow edited this page Apr 13, 2023 · 2 revisions

This is a page to explain the process of contributing to Pattern:Script, practically. If you're here to contribute, thanks a lot! You may also be interested in reading the page What To Contribute?

What do I need to contribute?

You only need:

  • a GitHub account and git client,
  • a code editor (I use Sublime Text 3 on mac),
  • a way to run a web server on your machine (see below),
  • all the standard web browsers to test your code :-)

How do I setup an environment to contribute?

Don't fall in PuzzleScript's trap

PuzzleScript has multiple scripts helping setting up an environment to run a local version of PuzzleScript for development purpose. These scripts are all deprecated for Pattern:Script (they are still in the repository in case someone needs them in a fork, but don't use them). So, ignore all the files in the repository's main directory except src, which is where the code can be found. Also ignore src/runserver.

Setup a local web server

This is something you can do in many ways and it's beyond the point of this page to explain how to do it. The simplest way to do it, and how I do it personally, is to have Python3 installed, open a terminal, get in the src directory, and execute python3 -m http.server. You may have to tell your system that python should accept incoming connections, or something like that. Then you can use any browser to test your edited version of Pattern:Script by using an url like http://localhost:8000/. The HTTPS protocol is not supported and it can cause issues (such as denied CORS requests), but it is not (yet) a problem for me. Please tell me if you encounter other issues so that I can update this page.

What code standard should I follow?

I purposefully use a different standard than increpare. It helps me keep track of what parts of the code are native PuzzleScript and which ones I have modified. I also find it way more convenient, of course. You don't have to follow the same standard than me but then, if you submit a PR, I will change the formatting before accepting it. My standard is:

  • Use tabulations to indent code, not spaces. Because that's what it is made for.
  • Use Allman's style for placing braces, because it helps code refactoring.
  • Don't use semicolons at the end of lines, that's totally useless and has always be optional, an antiquated design from old languages. Because javascript itself is not very well designed, it can cause some issues in certain cases. To avoid them, always place semicolons at the beginning of lines that start with a [ or (.
  • Use explicit names for variables and functions. We have autocompleting editors.

How do I send my contributions?

Use GitHub's system of Pull requests (PR). It basically sends your commits as a fork and we can both continue making changes on it before I accept it and merge it with the base Pattern:Script.