Skip to content

Commit

Permalink
docs: added the api docs page and linked in throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
khawarizmus committed Oct 4, 2023
1 parent df9106d commit 0074fea
Show file tree
Hide file tree
Showing 8 changed files with 635 additions and 83 deletions.
666 changes: 614 additions & 52 deletions docs/api.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/guide/calculating-the-qibla.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ console.log(qiblaDirection) // 292.6457605278075

### Optional Coordinates

You can also pass in an optional [`CoordinatesObject`]() to the `getQiblaDirection` method. This is useful if you want to calculate the Qibla direction for a different location than the one you used to initialize the calculator.
You can also pass in an optional [`CoordinatesObject`](../api.md#coordinatesobject) to the `getQiblaDirection` method. This is useful if you want to calculate the Qibla direction for a different location than the one you used to initialize the calculator.

```ts
const alAqsaCoordinates = {
Expand All @@ -37,7 +37,7 @@ console.log(qiblaDirection) // 157.29924281528764

## Using the `calculateQiblaDirection` Function Helper

The `calculateQiblaDirection` function helper is a standalone function that can be used to calculate the Qibla direction. It accepts a [`CoordinatesObject`]() as its only argument.
The `calculateQiblaDirection` function helper is a standalone function that can be used to calculate the Qibla direction. It accepts a [`CoordinatesObject`](../api.md#coordinatesobject) as its only argument.

```ts
import { calculateQiblaDirection } from 'prayer-call'
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/one-time-calculator.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For configuration details, refer to the [Config](../config/config.md) section.

### `getAllPrayerTimes`

Returns an array of [`TimeObject`]() with prayer names and their corresponding time as a Javascript `Date` object.
Returns an array of [`TimeObject`](../api.md#timeobject) with prayer names and their corresponding time as a Javascript `Date` object.

::: info
The array includes the sunrise time object.
Expand Down Expand Up @@ -78,7 +78,7 @@ calculator.getAllPrayerTimes() // check the output tab

### `getPrayerTime`

Returns the time for a specific prayer based on the initialized date. Accepts a prayer parameter of type `PrayerNamesType`. Use the [`PrayerNames`]() enum for available prayer names.
Returns the time for a specific prayer based on the initialized date. Accepts a prayer parameter of type [`PrayerNamesType`](../api.md#prayernamestype). Use the [`PrayerNames`](../api.md#prayernames) enum for available prayer names.

```ts
import { Methods, PrayerNames, StaticCalculator } from 'prayer-call'
Expand All @@ -98,7 +98,7 @@ calculator.getPrayerTime(PrayerNames.FAJR)

### `getMiddleOfTheNightTime` and `getLastThirdOfTheNightTime`

Returns a [`TimeObject`]() representing the time of the middle and the last third of the night respectively based on the moon. Useful for Qiyam calculations.
Returns a [`TimeObject`](../api.md#timeeventobject) representing the time of the middle and the last third of the night respectively based on the moon. Useful for Qiyam calculations.

```ts
import { Methods, StaticCalculator } from 'prayer-call'
Expand All @@ -123,7 +123,7 @@ calculator.getLastThirdOfTheNightTime()

Returns a `number` representing the Qibla direction in degrees from North.

By default this method will use the initialization coordinates but can optional accept a `CoordinatesObject`.
By default this method will use the initialization coordinates but can optional accept a [`CoordinatesObject`](../api.md#coordinatesobject).

```ts
import { Methods, StaticCalculator } from 'prayer-call'
Expand Down Expand Up @@ -177,7 +177,7 @@ calculator.getCalculationOptions()

### `setCalculationOptions`

Allows you to update the calculator's configuration without creating a new instance. Accepts a `newConfig` param of type `Partial<CalculationsConfig>`.
Allows you to update the calculator's configuration without creating a new instance. Accepts a `newConfig` param of type [`Partial<CalculationsConfig>`](../api.md#calculationsconfig).

For configuration details, refer to the [Config](../config/config.md) section.

Expand Down
22 changes: 11 additions & 11 deletions docs/guide/reactive-calculator.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For configuration details, refer to the [Config](../config/config.md) section.

### `getCurrentPrayerTime`

Returns a [`TimeObject`]() with the name and Adhan time of the current prayer. If the invocation time is past Isha, the returned value would be `{ name: "none", time: null }`.
Returns a [`TimeObject`](../api.md#timeobject) with the name and Adhan time of the current prayer. If the invocation time is past Isha, the returned value would be `{ name: "none", time: null }`.

```ts
import { Methods, ReactiveCalculator } from 'prayer-call'
Expand All @@ -38,7 +38,7 @@ reactiveCalculator.getCurrentPrayerTime()

### `getNextPrayerTime`

Returns a [`TimeObject`]() with the name and Adhan time of the next prayer. If the current prayer `"isha"`, the returned value would be `{ name: "none", time: null }`.
Returns a [`TimeObject`](../api.md#timeobject) with the name and Adhan time of the next prayer. If the current prayer `"isha"`, the returned value would be `{ name: "none", time: null }`.

```ts
import { Methods, ReactiveCalculator } from 'prayer-call'
Expand All @@ -56,7 +56,7 @@ reactiveCalculator.getNextPrayerTime()

### `getAllPrayerTimes`

Returns an array of [`TimeObject`]() with prayer names and their corresponding time as a Javascript `Date` object.
Returns an array of [`TimeObject`](../api.md#timeobject) with prayer names and their corresponding time as a Javascript `Date` object.

::: info
The array includes the sunrise time object.
Expand All @@ -78,7 +78,7 @@ reactiveCalculator.getAllPrayerTimes() // check the output tab

### `getPrayerTime`

`getPrayerTime` returns a Javascript `Date` object with the name and Adhan time of the specified prayer. Accepts prayer parameter of type `PrayerNamesType`. Use the [`PrayerNames`]() enum for available prayer names.
`getPrayerTime` returns a Javascript `Date` object with the name and Adhan time of the specified prayer. Accepts prayer parameter of type [`PrayerNamesType`](../api.md#prayernamestype). Use the [`PrayerNames`](../api.md#prayernames) enum for available prayer names.

```ts
import { Methods, ReactiveCalculator, PrayerNames } from 'prayer-call'
Expand All @@ -96,7 +96,7 @@ reactiveCalculator.getPrayerTime(PrayerNames.FAJR)

### `getMiddleOfTheNightTime` and `getLastThirdOfTheNightTime`

Returns a [`TimeObject`]() representing the time of the middle and the last third of the night respectively based on the moon. Useful for Qiyam calculations.
Returns a [`TimeObject`](../api.md#timeobject) representing the time of the middle and the last third of the night respectively based on the moon. Useful for Qiyam calculations.

```ts
import { Methods, ReactiveCalculator } from 'prayer-call'
Expand All @@ -116,7 +116,7 @@ reactiveCalculator.getLastThirdOfTheNightTime()

### `adhanObserver`

Returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`]() ie: `Observable<TimeEventObject>`. You can subscribe to the observable for receiving real-time notifications of Adhan events.
Returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`](../api.md#timeeventobject) ie: `Observable<TimeEventObject>`. You can subscribe to the observable for receiving real-time notifications of Adhan events.

```ts
import { Methods, ReactiveCalculator } from 'prayer-call'
Expand Down Expand Up @@ -145,7 +145,7 @@ reactiveCalculator.cleanup()

### `iqamaObserver`

Returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`]() ie: `Observable<TimeEventObject>`. This method can be subscribed to for prayer Iqama times events.
Returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`](../api.md#timeeventobject) ie: `Observable<TimeEventObject>`. This method can be subscribed to for prayer Iqama times events.

```ts
import { Methods, ReactiveCalculator, TimeEventObject } from 'prayer-call'
Expand Down Expand Up @@ -178,7 +178,7 @@ The default time intervals in minutes between Adhan and Iqama are: `{ fajr: 20,

### `qiyamTimesObserver`

This method returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`]() ie: `Observable<TimeEventObject>`. This method can be subscribed to for prayer Qiyam times events. (The middle of the night and the last third of the night).
This method returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`](../api.md#timeeventobject) ie: `Observable<TimeEventObject>`. This method can be subscribed to for prayer Qiyam times events. (The middle of the night and the last third of the night).

```ts
import { Methods, ReactiveCalculator, TimesNames, TimeEventObject } from 'prayer-call'
Expand Down Expand Up @@ -213,7 +213,7 @@ reactiveCalculator.cleanup()

### `prayerEventsObserver`

This method returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`]() ie: `Observable<TimeEventObject>`. This method is a shortcut for subscribing to all prayer events at once (Adhan, Iqama, Qiyam).
This method returns an [`Observable`](https://rxjs.dev/guide/observable) of type [`TimeEventObject`](../api.md#timeeventobject) ie: `Observable<TimeEventObject>`. This method is a shortcut for subscribing to all prayer events at once (Adhan, Iqama, Qiyam).

```ts
import { Methods, ReactiveCalculator, TimeEventObject, EventType } from 'prayer-call'
Expand Down Expand Up @@ -290,7 +290,7 @@ const qiyamSubscription = reactiveCalculator.newQiyamObserver().subscribe({

Returns a `number` representing the Qibla direction in degrees from North.

By default this method will use the initialization coordinates but can optional accept a `CoordinatesObject`.
By default this method will use the initialization coordinates but can optional accept a [`CoordinatesObject`](../api.md#coordinatesobject).

```ts
import { Methods, ReactiveCalculator } from 'prayer-call'
Expand Down Expand Up @@ -343,7 +343,7 @@ calculator.getCalculationOptions()

### `setCalculationOptions`

Allows you to update the calculator's configuration without creating a new instance. Accepts a `newConfig` param of type `Partial<ReactiveCalculationsConfig>`.
Allows you to update the calculator's configuration without creating a new instance. Accepts a `newConfig` param of type [`Partial<ReactiveCalculationsConfig>`](../api.md#reactivecalculationsconfig).

For configuration details, refer to the [Config](../config/config.md) section.

Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `Formatter` class in `prayers-call` provides a flexible way to format dates

## Initialization and Configuration

To begin using the `Formatter` class, you'll need to initialize it. While the class comes with a default configuration, you can customize it by passing an optional `FormatterConfig` object during initialization.
To begin using the `Formatter` class, you'll need to initialize it. While the class comes with a default configuration, you can customize it by passing an optional [`FormatterConfig`](../api.md#formatterconfig) object during initialization.

### Default Configuration

Expand Down Expand Up @@ -100,7 +100,7 @@ formatter.formatDate(date) // 'Tuesday, February 1, 2022 at 12:00 AM'

### `formatePrayers`

To format prayer times, use the formatPrayers method. It accepts an array of [`TimeObject`]() as its only argument. it will return an array of `FormattedTimeObject`.
To format prayer times, use the formatPrayers method. It accepts an array of [`TimeObject`](../api.md#timeobject) as its only argument. it will return an array of [`FormattedTimeObject`](../api.md#formattedtimeobject).

```ts
import { Formatter } from 'prayer-call'
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/hijri.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The `Intl.DateTimeFormat` API support other calendars as well. to get a full lis

### Arabic Display of Dates

To display dates in Arabic, you can specify the locale option in the `FormatterConfig`.
To display dates in Arabic, you can specify the locale option in the [`FormatterConfig`](../api.md#formatterconfig).

```ts
import { Formatter } from 'prayer-call'
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export { AsrTime } from './types/AsrTime'
export { EventType, PrayerNames } from './types/TimeObject'
export { HijriCalendar } from './types/HijriCalendar'
export type {
PrayersTimeObject,
PrayerNamesType,
TimesNamesType,
FormattedTimeObject,
Expand Down
9 changes: 0 additions & 9 deletions src/types/TimeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ export enum TimesNames {
LAST_THIRD_OF_THE_NIGHT = 'lastThirdOfTheNight',
}

export interface PrayersTimeObject {
fajr: Date
sunrise: Date
dhuhr: Date
asr: Date
maghrib: Date
isha: Date
}

export interface FormattedTimeObject {
name: TimesNamesType
time: string
Expand Down

0 comments on commit 0074fea

Please sign in to comment.