Skip to content

Commit

Permalink
feat: generate documentation from markdown files (#378)
Browse files Browse the repository at this point in the history
* feat: generate documentation from markdown files

* chore: clean up documentation folder structure

* docs: add documentations for some endpoints

* chore: minor documentation style fixes

* chore(docs): fix some minor markdown issues

* add parentheses around arrow function arguments

* only import endpoint index files

* Revert "only import endpoint index files"

This reverts commit 8213fd5.

* only require js files as endpoints and no schemas

* regenerate mock data
  • Loading branch information
Kristján Oddsson committed Dec 14, 2017
1 parent 495f12a commit f3dc510
Show file tree
Hide file tree
Showing 28 changed files with 1,474 additions and 915 deletions.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
47 changes: 47 additions & 0 deletions docs/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<style>
body {
background-color: #fdf6e3;
font-family: 'Open Sans',Arial,tahoma,sans-serif;
color: #06568F;
line-height: 1.5;
font-size: 18px;
font-weight: 300;
max-width: 860px;
margin: auto;
}
a {
color: #268bd2;
}
ul {
list-style: none;
padding: 0;
}
li {
background-color: #268bd2;
color: #fdf6e3;
padding: 10px 20px;
border-radius: 2px;
}
li > a {
color: #fdf6e3;
}
h1, h2, h3 {
font-weight: 300;
margin: 0;
}
table {
width: 100%;
}
th {
text-align: left;
}
td:last-child,
th:last-child {
text-align: right;
}
hr {
border-top-style: dashed;
}
</style>

13 changes: 13 additions & 0 deletions endpoints/address/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Icelandic Addresses

Source [Iceland Post](https://postur.is)

- GET [/address](https://apis.is/address)

Lookup addresses in Iceland through the Icelandic Post API

| Parameters | Description | Example |
|--------------------|---------------|--------------------------------------------------------|
| Address (required) | Valid address | [Laugarvegur 1](https://apis.is/address/Laugarvegur 1) |

---
9 changes: 9 additions & 0 deletions endpoints/aur/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Auroracoin to ISK exchange

Source [ISX.is](https://isx.is)

- GET [/aur](https://apis.is/aur)

Current Auroracoin exchange rate and various statistics for the past day.

---
13 changes: 13 additions & 0 deletions endpoints/bus/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Icelandic Bus System

Source [bus.is](https://bus.is)

- GET [/bus/realtime](https://apis.is/bus/realtime)

Real-time location of busses. Results are only shown for active busses.

| Parameters | |
|-------------|---|
| BUSSES | Comma seperated list of numbers. Good to know: If not declared, the endpoint will return location of all available busses. |

---
13 changes: 13 additions & 0 deletions endpoints/car/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Cars in Iceland

Source: [The Road Traffic Directorate](http://www.samgongustofa.is/umferd/okutaeki/okutaekjaskra/uppfletting)

- GET [/car](https://apis.is/car)

Search the Icelandic vehicle registry.

| Parameters | Description | Example |
|--------------------|-----------------|-------------------------------------------|
| Number (required) | Registry number | [AA031](https://apis.is/car?number=AA031) |

---
17 changes: 17 additions & 0 deletions endpoints/company/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Icelandic companies

Source: [Directorate of Internal Revenue in Iceland](http://rsk.is/)

- GET [/company](https://apis.is/company)

Search the Icelandic company registry
**NB: At least one parameter is required.**

| Parameters | Description | Example |
|---------------|-----------------------------------------------|-------------------------------------------------|
| Name | Company name | [Blendin](https://apis.is/company?name=blendin) |
| Address | Company's address | |
| SocialNumber | Company's social security number / ID number | |
| VSKNR | Company's VAT-number (VSK in icelandic) || |

---
9 changes: 9 additions & 0 deletions endpoints/concerts/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Concerts in Iceland

Source: [midi.is](https://midi.is/)

- GET [/concerts](https://apis.is/concerts)

Get a list of all the concerts in Iceland sorted by date

---
14 changes: 14 additions & 0 deletions endpoints/currency/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Currency in relation to ISK

Source: [m5.is](http://m5.is/), [Arion banki](https://arionbanki.is/) and [Landsbankinn](https://landsbankinn.is/)

- GET [/currency/:source](https://apis.is/currency/:source)

Get currency data in relation to ISK

| Parameters | Description | Example |
|--------------------|---------------------|-----------------------|
| :source (required) | Which source to use | [m5](https://apis.is/currency/m5), [arion](https://apis.is/currency/arion) or [lb](https://apis.is/currency/lb) |


---
9 changes: 9 additions & 0 deletions endpoints/cyclecounter/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Bicyclecounter in Reykjavik

Source: [Bicycle Counter](http://bicyclecounter.dk/)

- GET [/cyclecounter](https://apis.is/cyclecounter)

Get current status of bicycle counters in Iceland, currently only one located by Suðurlandsbraut in Reykjavík.

---
9 changes: 9 additions & 0 deletions endpoints/earthquake/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Earthquakes in Iceland

Source: [Icelandic Meteorological Office](http://vedur.is)

- GET [/earthquake/is](https://apis.is/earthquake/is)

Get earthquake monitoring data for the last 48 hours.

---
14 changes: 14 additions & 0 deletions endpoints/flight/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# International flights in Iceland

Source: [Keflavik Airport](https://kefairport.is/)

- GET [/flight](https://apis.is/flight)

Get a list of all international flights departing and arriving at Keflavik Airport today.

| Parameters | Description | Example |
|---------------------|------------------------------------|----------------------------|
| Language (required) | The language to get the results in | 'en' or 'is' |
| Type (required) | The type of flights to fetch | 'departures' or 'arrivals' |

---
17 changes: 17 additions & 0 deletions endpoints/horses/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Icelandic horses

Source: [Worldfengur.com](http://www.worldfengur.com/freezone_horse.jsp?c=EN)

- GET [/horses](https://apis.is/horses)

Search the Icelandic horse database Worldfengur.
**NB: At least one of the following is required, id, name and origin or microchip.**

| Parameters | Description | Example |
|------------|------------------|-------------------------------------------------------|
| ID | Public ID | [IS1987187700](http://apis.is/horses?id=IS1987187700) |
| Name | Name of horse | |
| Origin | Place of origin | |
| Microchip | Microchip number | | |

---
9 changes: 9 additions & 0 deletions endpoints/hospital/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Status of Icelandic hospitals

Source: [The National University Hospital of Iceland](http://landspitali.is)

- GET [/hospital](https://apis.is/hospital)

Get the current status of the National University Hospital of Iceland.

---
9 changes: 9 additions & 0 deletions endpoints/lottery/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Icelandic lottery

Source: [The Icelandic Government Lottery](https://games.lotto.is/)

- GET [/lottery](https://apis.is/lottery)

Get the most recent numbers for the Icelandic lottery.

---
9 changes: 9 additions & 0 deletions endpoints/particulates/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Particulates in Reykjavik

Source: [Reykjavik City](http://reykjavik.is/)

- GET [/particulates](https://apis.is/particulates)

Get current status of particulates in Reykjavik City

---
9 changes: 9 additions & 0 deletions endpoints/petrol/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Petrol stations in Iceland

Source: [github.com/gasvaktin](https://github.com/gasvaktin/gasvaktin)

- GET [/petrol](https://apis.is/petrol)

Lookup locations and gas prices for petrol stations in Iceland.

---
13 changes: 13 additions & 0 deletions endpoints/rides/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Carpooling in Iceland

Source: [samferda.net](http://samferda.net)

- GET [/rides/samferda-drivers/](https://apis.is/rides/samferda-drivers/)

Get a list of drivers requesting passengers, sorted by departure date.

- GET [/rides/samferda-passengers/](https://apis.is/rides/samferda-passengers/)

Get a list of passengers requesting rides, sorted by preferred departure date

---
9 changes: 9 additions & 0 deletions endpoints/sarschool/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Landsbjörg SAR School course schedule

Source: [SAR School](http://skoli.landsbjorg.is/)

- GET [/sarschool](https://apis.is/sarschool)

Get a list of all courses scheduled by the Search and Rescue school for training of SAR Squad members.

---
13 changes: 13 additions & 0 deletions endpoints/ship/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Icelandic Ship Registry

Source: [The Icelandic Transport Authority](https://www.samgongustofa.is/siglingar/skrar-og-utgafa/skipaskra/uppfletting/)

- GET [/ship](https://apis.is/ship)

Search the Icelandic ship registry

| Parameters | Description | Example |
|-------------------|---------------------------------------------------------------|---------------|
| Search (required) | Ship name, regional code or the registy's registration number | [engey](https://apis.is/ship?search=engey), [RE-100](https://apis.is/ship?search=RE-100) |

---
13 changes: 13 additions & 0 deletions endpoints/sports/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Sport events in Iceland

Source: [KSÍ](http://ksi.is) and [HSÍ](http://hsi.is)

- GET [/sports/:sport](https://apis.is/sports/:sport)

Get events for Icelandic football and/or handball

| Parameters | Description | Example |
|-------------------|---------------------------|---------|
| :sport (required) | Which sport events to get | [football](https://apis.is/sports/football), [handball](https://apis.is/sports/handball) |

---
13 changes: 13 additions & 0 deletions endpoints/tv/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Icelandic television schedules

Source: [RÚV](http://ruv.is), [Stöð 2](http://stod2.is) and [SkjárEinn](http://skjarinn.is/einn)

- GET [/tv/:channel](https://apis.is/tv/:channel)

Get schedules for Icelandic tv stations.

| Parameters | Description | Example |
|------------|---------------------------------|------------------------------------------------------------------|
| :channel | Which channel's schedule to get | [ruv](https://apis.is/tv/ruv), [stod2](https://apis.is/tv/stod2) |

---
37 changes: 37 additions & 0 deletions endpoints/weather/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Icelandic Weather

Source: [Icelandic Meteorological Office](http://vedur.is)

- GET [/weather/:source/:lang](https://apis.is/weather/:source/:lang)

Get weather information for Iceland.
Under 'Descriptions' you will find a list that will help you understand the output of the following endpoints.

| Parameters | Description | Example |
|------------------|--------------------------------------|------------------------------------------------|
| :type (required) | Type of information to get | [forecasts](https://apis.is/weather/forecasts) |
| :lang | Language of output, defaults to 'is' | [en](https://apis.is/weather/forecasts/en) |

- GET [/weather/forecasts/:lang](https://apis.is/weather/forecasts/:lang)

| Parameters | Description | Example |
|---------------------|--------------------------------------|------------------------------------------------|
| :lang | Language of output, defaults to 'is' | [en](https://apis.is/weather/forecasts/en) |
| stations (required) | List of station numbers seperated by commas(,) or semicolons(;). See links below for more information. [Weather stations (icelandic)](http://www.vedur.is/vedur/stodvar) & [Weather stations (english)](http://en.vedur.is/weather/stations/) | |

- GET [/weather/observations/:lang](https://apis.is/weather/observations/:lang)

| Parameters | Description | Example |
|---------------------|--------------------------------------|------------------------------------------------|
| :lang | Language of output, defaults to 'is' | [en](https://apis.is/weather/forecasts/en) |
| stations (required) | List of station numbers seperated by commas(,) or semicolons(;). See links below for more information. [Weather stations (icelandic)](http://www.vedur.is/vedur/stodvar) & [Weather stations (english)](http://en.vedur.is/weather/stations/) | |
| time | 1h (default) = Fetch data from automatic weather stations that are updated on the hour. 3h = Only fetch mixed data from manned and automatic weather stations that is updated every 3 hours. | |
| anytime | 0 (default) = an error will be returned if current data is not available. 1 = last available numbers will be displayed, regardless of date. | |

- GET [/weather/texts](https://apis.is/weather/texts)

| Parameters | Description |
|------------------|--------------------------------------|
| types (required) | List of types seperated by commas(,) or semicolons(;). See 'Valid types' below for full list of valid type numbers and what they stand for. |

---
14 changes: 14 additions & 0 deletions make-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs')
const globby = require('globby')
const marked = require('marked')

globby(['./docs/*.md', './endpoints/**/*.md', '!node_modules/**']).then((paths) => {
let content = ''
paths.forEach((path) => {
content += fs.readFileSync(path, 'utf8')
})
const html = marked(content, { escapeMarkdown: false })
fs.writeFileSync('./docs/dist/index.html', html, 'utf8')
}).catch((error) => {
console.error(error)
})
Loading

0 comments on commit f3dc510

Please sign in to comment.