Skip to content

Commit

Permalink
docs: Merge separate dependency pages (#7331)
Browse files Browse the repository at this point in the history
Signed-off-by: Vikram Vaswani <vikram@dagger.io>
  • Loading branch information
vikram-dagger committed May 13, 2024
1 parent 8c7ba70 commit a3b0bb1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 49 deletions.
35 changes: 26 additions & 9 deletions docs/current_docs/manuals/developer/dependencies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,41 @@ import TabItem from '@theme/TabItem';

# Dependencies

Modules can call each other. To add a dependency to your module, you can use `dagger install`, as in the following example:

When you add a dependency to your module with `dagger install`, the dependent module will be added to the code-generation routines and can be accessed from your own module's code.
```sh
dagger install github.com/shykes/daggerverse/helloWorld@26f8ed9f1748ec8c9345281add850fd392441990
```

The entrypoint to accessing dependent modules from your own module's code is `dag`, the Dagger client, which is pre-initialized. It contains all the core types (like `Container`, `Directory`, etc.), as well as bindings to any dependencies your module has declared.
This module will be added to your `dagger.json`:

Here is an example:
```json
...
"dependencies": [
{
"name": "helloWorld",
"source": "github.com/shykes/daggerverse/helloWorld@26f8ed9f1748ec8c9345281add850fd392441990"
}
]
```

```shell
dagger install github.com/shykes/daggerverse/helloWorld@26f8ed9f1748ec8c9345281add850fd392441990
You can also use local modules as dependencies. However, they must be stored in a sub-directory of your module. For example:

```sh
dagger install ./path/to/module
```

This module can be accessed from your own module's code, as shown below:
When you add a dependency to your module with `dagger install`, the dependent module will be added to the code-generation routines and can be accessed from your own module's code.

The entrypoint to accessing dependent modules from your own module's code is `dag`, the Dagger client, which is pre-initialized. It contains all the core types (like `Container`, `Directory`, etc.), as well as bindings to any dependencies your module has declared.

Here is an example of accessing the installed `helloWorld` module from your own module's code:

<Tabs groupId="language">
<TabItem value="Go">

```go
func (m *MyModule) HelloWorld(ctx context.Context) (string, error) {
func (m *MyModule) Greeting(ctx context.Context) (string, error) {
return dag.HelloWorld().Message(ctx)
}
```
Expand All @@ -36,7 +53,7 @@ func (m *MyModule) HelloWorld(ctx context.Context) (string, error) {

```python
@function
async def hello_world(self) -> str:
async def greeting(self) -> str:
return await dag.hello_world().message()
```

Expand All @@ -46,7 +63,7 @@ async def hello_world(self) -> str:

```typescript
@func()
async helloWorld(): Promise<string> {
async greeting(): Promise<string> {
return await dag.helloWorld().message()
}
```
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ module.exports = {
"type": "doc",
"id": "manuals/developer/overview/execution-environment"
},
{
"type": "doc",
"id": "manuals/developer/overview/dependencies"
},
{
"type": "doc",
"id": "manuals/developer/secrets"
Expand Down

0 comments on commit a3b0bb1

Please sign in to comment.