Skip to content

Commit

Permalink
update documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Boisselle committed Dec 28, 2020
1 parent 998c66d commit 014181e
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 84 deletions.
108 changes: 60 additions & 48 deletions doc/modules/core/pages/install.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@
[[install-jvm]]
== JVM

=== With Maven

Add the JCenter repository:

[source,xml,subs="attributes"]
----
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
----

Then add the dependency:

[source,xml,subs="attributes"]
----
<dependencies>
<dependency>
<groupId>org.kodein.di</groupId>
<artifactId>kodein-di-jvm</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
----

WARNING: Use `kodein-di-jvm`, as _Kotlin/Multiplatform_ projects does not work with Maven


=== With Gradle

Add the JCenter repository:
Expand All @@ -59,36 +29,48 @@ dependencies {
}
----

[[kotlin-js]]
== JavaScript (Gradle)
[TIP]
====
If you are *NOT* using *Gradle 6+*, you should declare the use of the Gradle Metadata experimental feature
Because _Kodein-DI_ for JavaScript is compiled as a https://github.com/umdjs/umd[UMD module], it can be imported:
[subs="attributes"]
.settings.gradle.kts
----
enableFeaturePreview("GRADLE_METADATA")
----
* In a browser:
** as an AMD module (for example with RequireJS) (See index.html in the demo project).
** Directly in an HTML page with a `<script>` tag (See index2.html in the demo project).
* In NodeJS, as a regular CJS module.
Or, import the JVM binaries with `implementation("org.kodein.di:kodein-di-jvm:{version}")`.
====

=== With Maven

Add the JCenter repository:

[source,groovy,subs="attributes"]
[source,xml,subs="attributes"]
----
buildscript {
repositories {
jcenter()
}
}
&lt;repositories&gt;
&lt;repository&gt;
&lt;id&gt;jcenter&lt;/id&gt;
&lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;
----

Then add the dependency:

[source,groovy,subs="attributes"]
[source,xml,subs="attributes"]
----
dependencies {
compile 'org.kodein.di:kodein-di-js:{version}'
}
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.kodein.di&lt;/groupId&gt;
&lt;artifactId&gt;kodein-di-jvm&lt;/artifactId&gt;
&lt;version&gt;{version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
----

WARNING: Use `kodein-di-jvm`, as _Kotlin/Multiplatform_ projects does not work with Maven

[[kotlin-multiplatform]]
== Kotlin/Multiplatform (Gradle)

Expand All @@ -99,7 +81,7 @@ _Kodein-DI_ uses the new gradle native dependency model.

[TIP]
====
If you are *NOT* using *Gradle 6+*, you should declare the use of the Gralde Metadata experimental feature
If you are *NOT* using *Gradle 6+*, you must declare the use of the Gralde Metadata experimental feature
[subs="attributes"]
.settings.gradle.kts
Expand Down Expand Up @@ -134,3 +116,33 @@ kotlin {
}
}
----

[[kotlin-js]]
== JavaScript (Gradle)

Because _Kodein-DI_ for JavaScript is compiled as a https://github.com/umdjs/umd[UMD module], it can be imported:

* In a browser:
** as an AMD module (for example with RequireJS) (See index.html in the demo project).
** Directly in an HTML page with a `<script>` tag (See index2.html in the demo project).
* In NodeJS, as a regular CJS module.

Add the JCenter repository:

[source,groovy,subs="attributes"]
----
buildscript {
repositories {
jcenter()
}
}
----

Then add the dependency:

[source,groovy,subs="attributes"]
----
dependencies {
compile 'org.kodein.di:kodein-di-js:{version}'
}
----
37 changes: 36 additions & 1 deletion doc/modules/core/pages/using-environment.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ class MySpecialRequest(override val di: DI): Request(), DIAware {
}
----

[NOTE]
====
You can access the container's bindings within a context translator:
[source, kotlin]
.Example:
----
val di = DI {
bind<User>() with scoped(SessionScope).singleton { UserData(session.userId) }
bind<Translator>() with singleton { RequestTranslator() }
registerContextTranslator { r: Request ->
instance<Translator>().translate(r)
}
}
----
====


=== Context finder

Expand All @@ -191,7 +209,24 @@ val di = DI {
}
----

This allows to access a `User` object wihout specifying a context.
This allows to access a `User` object without specifying a context.

[NOTE]
====
You can access the container's bindings within a context finder:
[source, kotlin]
.Example:
----
enum class Env { DEBUG, PRODUCTION }
class CurrentEnv(var env: Env)
val di = DI {
bind() from scoped(EnvironmentScope).singleton { Service(context) }
bind() from singleton { CurrentEnv(Env.PRODUCTION) }
registerContextFinder { instance<CurrentEnv>().env }
}
----
====

TIP: Having an other type of context declared will not block from using a context finder.

Expand Down
126 changes: 106 additions & 20 deletions doc/modules/extension/pages/configurable.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,135 @@ NOTE: Using or not using this is a matter of taste and is neither recommended no

== Install

[[install-jvm]]
=== JVM

==== With Maven
==== With Gradle

[source,xml,subs="attributes"]
[TIP]
====
If you are *NOT* using *Gradle 6+*, you should declare the use of the Gradle Metadata experimental feature
[subs="attributes"]
.settings.gradle.kts
----
&lt;dependency&gt;
&lt;groupId&gt;org.kodein.di&lt;/groupId&gt;
&lt;artifactId&gt;kodein-di-conf-jvm&lt;/artifactId&gt;
&lt;version&gt;{version}&lt;/version&gt;
&lt;/dependency&gt;
enableFeaturePreview("GRADLE_METADATA")
----
IMPORTANT: Do not remove the `kodein-generic-jvm` (or `kodein-erased-jvm`) dependency.
Both dependencies must be declared.
====

==== With Gradle
Add the JCenter repository:

[source,groovy,subs="attributes"]
----
compile 'org.kodein.di:kodein-di-conf-jvm:{version}'
buildscript {
repositories {
jcenter()
}
}
----

IMPORTANT: Do not remove the `kodein-generic-jvm` (or `kodein-erased-jvm`) dependency.
Both dependencies must be declared.
Then add the dependency:

[source,groovy,subs="attributes"]
----
dependencies {
implementation 'org.kodein.di:kodein-conf-di:{version}'
}
----

==== With Maven

Add the JCenter repository:

[source,xml,subs="attributes"]
----
&lt;repositories&gt;
&lt;repository&gt;
&lt;id&gt;jcenter&lt;/id&gt;
&lt;url&gt;https://jcenter.bintray.com&lt;/url&gt;
&lt;/repository&gt;
&lt;/repositories&gt;
----

Then add the dependency:

[source,xml,subs="attributes"]
----
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.kodein.di&lt;/groupId&gt;
&lt;artifactId&gt;kodein-di-jvm&lt;/artifactId&gt;
&lt;version&gt;{version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
----

=== Javascript (Gradle)
WARNING: Use `kodein-di-conf-jvm`, as _Kotlin/Multiplatform_ projects does not work with Maven

[[kotlin-js]]
=== JavaScript (Gradle)

Because _Kodein-DI_ for JavaScript is compiled as a https://github.com/umdjs/umd[UMD module], it can be imported:

* In a browser:
** as an AMD module (for example with RequireJS) (See index.html in the demo project).
** Directly in an HTML page with a `<script>` tag (See index2.html in the demo project).
* In NodeJS, as a regular CJS module.

Add the JCenter repository:

[source,groovy,subs="attributes"]
----
buildscript {
repositories {
jcenter()
}
}
----

Then add the dependency:

[source,groovy,subs="attributes"]
----
compile 'org.kodein.di:kodein-di-conf-js:{version}'
dependencies {
compile 'org.kodein.di:kodein-di-conf-js:{version}'
}
----

IMPORTANT: Do not remove the `kodein-generic-js` (or `kodein-erased-js`) dependency.
Both dependencies must be declared.
[[kotlin-multiplatform]]
=== Kotlin/Multiplatform (Gradle)

NOTE: _Kodein-DI_ supports the following targets: +
androidArm32, androidArm64, iosArm32, iosArm64, iosX64, linuxArm32Hfp, linuxMips32, linuxMipsel32, linuxX64, macosX64, mingwX64

=== Native
_Kodein-DI_ uses the new gradle native dependency model.

- https://dl.bintray.com/kodein-framework/Kodein-DI/native/kodein-di-{version}/kodein-di-conf-{version}.klib[Download kodein-conf-{version}.klib].
- Add the library to your project.
Add the JCenter repository:

[source,groovy,subs="attributes"]
----
buildscript {
repositories {
jcenter()
}
}
----

Then add the dependency:

[source,groovy,subs="attributes"]
----
kotlin {
sourceSets {
commonMain {
dependencies {
implementation "org.kodein.di:kodein-di-conf:{version}"
}
}
}
}
----

== ConfigurableDI

Expand Down
22 changes: 7 additions & 15 deletions doc/modules/extension/pages/jsr330.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ CAUTION: Every-thing that is described here is *a lot less performant* than usin
[[install]]
== Install

=== With Gradle

[source,groovy,subs="attributes"]
----
implementation("org.kodein.di:kodein-di-jxinject-jvm:{version}")
----

=== With Maven

[source,xml,subs="attributes"]
Expand All @@ -33,21 +40,6 @@ CAUTION: Every-thing that is described here is *a lot less performant* than usin
&lt;/dependency&gt;
----

IMPORTANT: Do not remove the "kodein-generic-jvm" (or "kodein-erased-jvm") dependency.
Both dependencies must be declared.


=== With Gradle

[source,groovy,subs="attributes"]
----
compile 'org.kodein.di:kodein-di-jxinject-jvm:{version}'
----

IMPORTANT: Do not remove the "kodein-generic-jvm" (or "kodein-erased-jvm") dependency.
Both dependencies must be declared.


[[import-module]]
=== Import the module.

Expand Down

0 comments on commit 014181e

Please sign in to comment.