Skip to content

Commit

Permalink
docs: Added a site for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mnasyrov committed Mar 26, 2023
1 parent 5312d3d commit c8367f4
Show file tree
Hide file tree
Showing 10 changed files with 1,343 additions and 15 deletions.
15 changes: 5 additions & 10 deletions docs/README.md
Expand Up @@ -272,6 +272,11 @@ export const Greeting: FC = () => {
};
```

# API References

- [`ditox`](ditox/README.md)
- [`ditox-react`](ditox-react/README.md)

# `ditox` package

## General
Expand Down Expand Up @@ -566,11 +571,6 @@ const LOGGER_MODULE = declareModule<LoggerModule>({
const APP_MODULE = declareModuleBinding([LOGGER_MODULE, DATABASE_MODULE]);
```

## API Reference

- [`ditox`](packages/ditox/docs)
- [`ditox-react`](packages/ditox-react/docs)

# ditox-react package

## Overview
Expand Down Expand Up @@ -649,11 +649,6 @@ function App() {
}
```

## API References

- [`ditox`](https://github.com/mnasyrov/ditox/tree/master/packages/ditox#readme)
- [`ditox-react`](./docs)

# License

This project is licensed under the
Expand Down
1 change: 1 addition & 0 deletions docs/ditox-react/.nojekyll
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
353 changes: 353 additions & 0 deletions docs/ditox-react/README.md
@@ -0,0 +1,353 @@
ditox-react

# ditox-react

## Table of contents

### Type Aliases

- [DependencyContainerBinder](README.md#dependencycontainerbinder)
- [DependencyContainerParams](README.md#dependencycontainerparams)

### Component

Binds the module to a new dependency container.

If a parent container is exist, it is connected to the current one by default.
Functions

- [DependencyModule](README.md#dependencymodule)

### Component

Provides a new dependency container to React app

This component creates a new container and provides it down to React children.

If &#x60;binder&#x60; callback is specified, it will be called for a new
container to binds it with dependencies.

If a parent container is exist, it is connected to the current one by default.
For making a new root container specify &#x60;root&#x60; parameter as
&#x60;true&#x60;, and the container will not depend on any parent container.
Functions

- [DependencyContainer](README.md#dependencycontainer)

### Hook

Returns a dependency by token, or &#x60;undefined&#x60; in case the dependency
is not provided. Functions

- [useOptionalDependency](README.md#useoptionaldependency)

### Hook

Returns a dependency by token, or fails with an error. Functions

- [useDependency](README.md#usedependency)

### Hook

Returns a dependency container, or &#x60;undefined&#x60; in case the container
is not provided. Functions

- [useDependencyContainer](README.md#usedependencycontainer)

### Hook

Returns a dependency container. Throws an error in case the container is not
provided. Functions

- [useDependencyContainer](README.md#usedependencycontainer)

## Type Aliases

### DependencyContainerBinder

Ƭ **DependencyContainerBinder**: (`container`: `Container`) => `unknown`

#### Type declaration

▸ (`container`): `unknown`

A callback for binding dependencies to a container

##### Parameters

| Name | Type |
| :---------- | :---------- |
| `container` | `Container` |

##### Returns

`unknown`

#### Defined in

[DependencyContainer.tsx:19](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/DependencyContainer.tsx#L19)

---

### DependencyContainerParams

Ƭ **DependencyContainerParams**: `Object`

Specifies an existed container or options for a new container:

**`Property`**

A callback which setup bindings to the container.

**`Property`**

If `true` then a new container does not depend on any parent containers

#### Type declaration

| Name | Type |
| :--------- | :----------------------------------------------------------------- |
| `binder?` | [`DependencyContainerBinder`](README.md#dependencycontainerbinder) |
| `children` | `ReactNode` |
| `root?` | `boolean` |

#### Defined in

[DependencyContainer.tsx:26](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/DependencyContainer.tsx#L26)

## Component

Binds the module to a new dependency container.

If a parent container is exist, it is connected to the current one by default.
Functions

### DependencyModule

**DependencyModule**(`params`): `ReactElement`

**`Example`**

```tsx
const LOGGER_MODULE: ModuleDeclaration<LoggerModule> = {

function App() {
return (
<DependencyModule module={LOGGER_MODULE}>
<NestedComponent />
</DependencyModule>
);
}
```
#### Parameters
| Name | Type | Description |
| :---------------- | :-------------------------------------------------------------- | :------------------------------------------------------------- |
| `params` | `Object` | - |
| `params.children` | `ReactNode` | - |
| `params.module` | `ModuleDeclaration`<`Module`<`Record`<`string`, `unknown`\>\>\> | Module declaration for binding |
| `params.scope?` | `"scoped"` \| `"singleton"` | Optional scope for binding: `singleton` (default) or `scoped`. |
#### Returns
`ReactElement`
#### Defined in
[DependencyModule.tsx:33](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/DependencyModule.tsx#L33)
---
## Component
Provides a new dependency container to React app
This component creates a new container and provides it down to React children.
If &#x60;binder&#x60; callback is specified, it will be called for a new
container to binds it with dependencies.
If a parent container is exist, it is connected to the current one by default.
For making a new root container specify &#x60;root&#x60; parameter as
&#x60;true&#x60;, and the container will not depend on any parent container.
Functions
### DependencyContainer
▸ **DependencyContainer**(`params`): `ReactElement`
**`Example`**
```tsx
const TOKEN = token();

function appDependencyBinder(container: Container) {
container.bindValue(TOKEN, 'value');
}

function App() {
return (
<DependencyContainer root binder={appDependencyBinder}>
<NestedComponent />
</DependencyContainer>
);
}
```
#### Parameters
| Name | Type |
| :------- | :----------------------------------------------------------------- |
| `params` | [`DependencyContainerParams`](README.md#dependencycontainerparams) |
#### Returns
`ReactElement`
#### Defined in
[DependencyContainer.tsx:68](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/DependencyContainer.tsx#L68)
---
## Hook
Returns a dependency by token, or &#x60;undefined&#x60; in case the dependency
is not provided. Functions
### useOptionalDependency
▸ **useOptionalDependency**<`T`\>(`token`): `T` \| `undefined`
#### Type parameters
| Name |
| :--- |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------------ |
| `token` | `Token`<`T`\> |
#### Returns
`T` \| `undefined`
#### Defined in
[hooks.ts:52](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L52)
---
## Hook
Returns a dependency by token, or fails with an error. Functions
### useDependency
▸ **useDependency**<`T`\>(`token`): `T`
#### Type parameters
| Name |
| :--- |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------------ |
| `token` | `Token`<`T`\> |
#### Returns
`T`
#### Defined in
[hooks.ts:41](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L41)
---
## Hook
Returns a dependency container, or &#x60;undefined&#x60; in case the container
is not provided. Functions
### useDependencyContainer
▸ **useDependencyContainer**(`mode`): `Container`
#### Parameters
| Name | Type |
| :----- | :--------- |
| `mode` | `"strict"` |
#### Returns
`Container`
#### Defined in
[hooks.ts:10](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L10)
▸ **useDependencyContainer**(`mode?`): `Container` \| `undefined`
#### Parameters
| Name | Type |
| :------ | :----------- |
| `mode?` | `"optional"` |
#### Returns
`Container` \| `undefined`
#### Defined in
[hooks.ts:16](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L16)
---
## Hook
Returns a dependency container. Throws an error in case the container is not
provided. Functions
### useDependencyContainer
▸ **useDependencyContainer**(`mode`): `Container`
#### Parameters
| Name | Type |
| :----- | :--------- |
| `mode` | `"strict"` |
#### Returns
`Container`
#### Defined in
[hooks.ts:10](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L10)
▸ **useDependencyContainer**(`mode?`): `Container` \| `undefined`
#### Parameters
| Name | Type |
| :------ | :----------- |
| `mode?` | `"optional"` |
#### Returns
`Container` \| `undefined`
#### Defined in
[hooks.ts:16](https://github.com/mnasyrov/ditox/blob/f2803b1/packages/ditox-react/src/hooks.ts#L16)
1 change: 1 addition & 0 deletions docs/ditox/.nojekyll
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

0 comments on commit c8367f4

Please sign in to comment.