Skip to content

Commit

Permalink
minor edits to CONTRIBUTING.md fix ccxt#1006
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Dec 30, 2017
1 parent 11952a3 commit 51a6143
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ These PHP base classes and files are not transpiled:

Below are key notes on how to keep the JS code transpileable.

If you see `[TypeError] Cannot read property '1' of null` transpilation errors when you `npm run build`:
If you see a `[TypeError] Cannot read property '1' of null` exception or any other transpilation error when you `npm run build`, check if your code satisifes the following rules:

- don't put empty lines inside your methods
- always use Python-style indentation, it is preserved as is for all languages
Expand All @@ -185,7 +185,7 @@ If you see `[TypeError] Cannot read property '1' of null` transpilation errors w
- avoid mixed comment styles, use double-slash `//` in JS for line comments
- avoid multi-line comments

If the transpiling process runs, but generates incorrect PHP/Python:
If the transpiling process finishes successfully, but generates incorrect Python/PHP syntax, check for the following:

- every opening bracket like `(` or `{` should have a space before it!
- do not use language-specific code syntax sugar, even if you really want to
Expand Down Expand Up @@ -242,7 +242,13 @@ The basic JSON-skeleton for a new exchange integration is as follows:
}
```

In the code for each exchange, you'll notice that the functions that make API requests aren't explicitly defined. This is because the ``api`` definition in the exchange description JSON is used to create magic functions inside the exchange subclass that take ``request`` dictionaries and return the API response. In the example above, the ``endpoint/example`` results in the injection of a ``this.publicGetEndpointExample`` function. Similarly, the ``orderbook/{pair}/full`` results in a ``this.publicGetOrderbookPairFull`` function, that takes a named ``pair`` parameter.
#### Implicit API Methods

In the code for each exchange, you'll notice that the functions that make API requests aren't explicitly defined. This is because the `api` definition in the exchange description JSON is used to create *magic functions* (aka *partial functions* or *closures*) inside the exchange subclass. That implicit injection is done by the `defineRestApi/define_rest_api` base exchange method.

Each partial function takes a dictionary of `params` and returns the API response. In the example JSON above, the `'endpoint/example'` results in the injection of a `this.publicGetEndpointExample` function. Similarly, the `'orderbook/{pair}/full'` results in a `this.publicGetOrderbookPairFull` function, that takes a ``pair`` parameter.

Upon instantiation the base exchange class takes each URL from its list of endpoints, splits it into words, and then makes up a callable function name from those words by using a partial construct. That process is the same in JS and PHP as well. It is also briefly described here: https://github.com/ccxt-dev/ccxt/wiki/Manual#api-method-naming-conventions.

```UNDER CONSTRUCTION```

Expand Down

0 comments on commit 51a6143

Please sign in to comment.