improve docs readability 📝

This commit is contained in:
Jannis R 2019-12-12 18:42:44 +01:00
parent ef7bd42d15
commit 0165320808
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
4 changed files with 9 additions and 6 deletions

View file

@ -334,7 +334,7 @@ departure of first (later) journey 2017-12-17T19:19:00+01:00
If you pass `polylines: true`, each journey leg will have a `polyline` field. Refer to [the section in the `trip()` docs](trip.md#polyline-option) for details. If you pass `polylines: true`, each journey leg will have a `polyline` field. Refer to [the section in the `trip()` docs](trip.md#polyline-option) for details.
If you pass `scheduledDays: true`, each journey will have a `scheduledDays` field looking like this: If you pass `scheduledDays: true`, each journey will have a `scheduledDays` object looking like this:
```js ```js
{ {

View file

@ -47,6 +47,7 @@ The response may look like this:
latitude: 52.521508, latitude: 52.521508,
longitude: 13.411267 longitude: 13.411267
}, },
line: { line: {
type: 'line', type: 'line',
id: 's9', id: 's9',
@ -68,6 +69,7 @@ The response may look like this:
}, },
direction: 'S Flughafen Berlin-Schönefeld', direction: 'S Flughafen Berlin-Schönefeld',
trip: 31463, trip: 31463,
nextStopovers: [ { nextStopovers: [ {
stop: { stop: {
type: 'stop', type: 'stop',

View file

@ -55,6 +55,7 @@ The response looked like this:
```js ```js
{ {
id: '1|31431|28|86|17122017', id: '1|31431|28|86|17122017',
origin: { origin: {
type: 'station', type: 'station',
id: '900000260005', id: '900000260005',

View file

@ -1,14 +1,14 @@
# Writing a profile # Writing a profile
**Per HAFAS endpoint, `hafas-client` has an endpoint-specific customisation called *profile***, which may for example do the following: **Per HAFAS endpoint, `hafas-client` has an endpoint-specific customisation called *profile*.** A profile may, for example, do the following:
- handle the additional requirements of the endpoint (e.g. authentication), - handle the additional requirements of the endpoint (e.g. authentication),
- extract additional information from the data provided by the endpoint, - extract additional information from the data provided by the endpoint,
- guard against triggering bugs of certain endpoints (e.g. time limits). - guard against triggering bugs of certain endpoints (e.g. time limits).
This guide is about writing such a profile. If you just want to use an already supported endpoint, refer to the [API documentation](readme.md) instead. This guide is about writing such a profile. If you just want to use an already supported endpoint, refer to the [main readme](../readme.md) instead.
*Note*: **If you get stuck, ask for help by [creating an issue](https://github.com/public-transport/hafas-client/issues/new)!** We want to help people expand the scope of this library. *Note*: **If you get stuck, ask for help by [creating an issue](https://github.com/public-transport/hafas-client/issues/new)**; We're happy to help you expand the scope of this library!
## 0. How do the profiles work? ## 0. How do the profiles work?
@ -21,7 +21,7 @@ A profile may consist of three things:
- **flags indicating which features are supported by the endpoint** e.g. `trip` - **flags indicating which features are supported by the endpoint** e.g. `trip`
- **methods overriding the [default profile](../lib/default-profile.js)** - **methods overriding the [default profile](../lib/default-profile.js)**
As an example, let's say we have an [Austrian](https://en.wikipedia.org/wiki/Austria) endpoint: Let's use a fictional endpoint for [Austria](https://en.wikipedia.org/wiki/Austria) as an example:
```js ```js
const myProfile = { const myProfile = {
@ -31,7 +31,7 @@ const myProfile = {
} }
``` ```
Assuming their HAFAS endpoint returns all lines names prefixed with `foo `, We can strip them like this: Assuming their HAFAS endpoint returns all line names prefixed with `foo `, we can adapt our profile to clean them:
```js ```js
// get the default line parser // get the default line parser