-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add multi-lang IDE integration page (#7378)
* docs: Add multi-lang IDE integration page Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix lint errors Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Fix link Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Add feedback Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Update sidebar Signed-off-by: Vikram Vaswani <vikram@dagger.io> * Add feedback Signed-off-by: Vikram Vaswani <vikram@dagger.io> --------- Signed-off-by: Vikram Vaswani <vikram@dagger.io>
- Loading branch information
1 parent
d0ab815
commit f1485c1
Showing
10 changed files
with
142 additions
and
132 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
docs/current_docs/manuals/developer/go/562832-ide-integration.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
docs/current_docs/manuals/developer/ide-integration.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
--- | ||
slug: /manuals/developer/ide-integration | ||
displayed_sidebar: "current" | ||
toc_max_heading_level: 2 | ||
title: "IDE Integration" | ||
--- | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# IDE Integration | ||
|
||
Dagger uses GraphQL as its low-level language-agnostic API query language, and each Dagger SDK generates native code-bindings for all dependencies from this API. This gives you all the benefits of type-checking, code completion and other IDE features for your favorite language when developing Dagger Functions. | ||
|
||
The `dagger develop` command bootstraps a Dagger module template in the selected programming language and sets up or updates all the resources needed to develop a module. After running this command, follow the steps below to have your IDE recognize the Dagger module. | ||
|
||
<Tabs groupId="language"> | ||
<TabItem value="Go"> | ||
To get your IDE to recognize a Dagger Go module, [configure your `go.work` file](./go/882081-module-structure.mdx#go-workspaces) to include the path to your module. | ||
|
||
When you generate a Dagger module for the first time, Dagger will create a `go.mod` file just for the module. If the module exists in a sub-directory of an outer Go project (such as `dagger/`, the default), this might confuse the IDE. | ||
|
||
If there is already a `go.mod` in the parent directory that you would like to use instead, delete the newly-generated `go.mod` and `go.sum` and Dagger will use the parent one instead. This is not advisable if your Dagger module has certain dependencies that are not relevant to your core product, since most consumers will prefer a narrower set of dependencies. | ||
|
||
To keep the generated `go.mod` file and edit your Dagger module in the same IDE session as your project code, one option is to set up a [Go workspace](https://go.dev/doc/tutorial/workspaces): | ||
|
||
```shell | ||
# in the root of your repository | ||
go work init | ||
go work use ./ | ||
go work use ./path/to/mod | ||
``` | ||
|
||
After restarting the IDE, you should be able to use IDE features such as go-to-definition, even when editing `dagger/main.go` from the project root. | ||
|
||
In most cases, `go.work` should not be committed to the repository, so it is advisable to add it to the project's `.gitignore` file: | ||
|
||
```shell | ||
echo go.work >> .gitignore | ||
echo go.work.sum >> .gitignore | ||
``` | ||
|
||
:::tip | ||
You can also choose to omit the local Go files generated by `dagger develop` from your version control system, as they aren't required to run the module. | ||
::: | ||
</TabItem> | ||
<TabItem value="Python"> | ||
To get your IDE to recognize a Dagger Python module and any added Dagger module dependencies in the generated client, follow the steps below for your package manager. | ||
|
||
<Tabs groupId="pytools"> | ||
<TabItem value="pip"> | ||
|
||
Install the Python SDK in a [virtual environment](https://packaging.python.org/en/latest/tutorials/installing-packages/#creating-virtual-environments) from the generated `./sdk` directory, as shown below: | ||
|
||
```shell | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
pip install -e ./sdk | ||
``` | ||
</TabItem> | ||
<TabItem value="Poetry"> | ||
|
||
Add `./sdk` as a development dependency: | ||
|
||
```shell | ||
poetry add -e --group=dev ./sdk | ||
``` | ||
</TabItem> | ||
<TabItem value="Hatch"> | ||
|
||
Install the Python SDK from the generated `./sdk` directory, as shown below: | ||
|
||
```shell | ||
pip install -e ./sdk | ||
``` | ||
|
||
Update `pyproject.toml` to [allow direct references](https://hatch.pypa.io/latest/config/metadata/#allowing-direct-references), and add a [local](https://hatch.pypa.io/latest/config/dependency/#local) dependency: | ||
|
||
```toml | ||
[project] | ||
name = "main" | ||
version = "0.0.0" | ||
|
||
[tool.hatch.envs.dev] | ||
dependencies = [ | ||
"dagger-io @ {root:uri}/sdk", | ||
] | ||
|
||
[tool.hatch.metadata] | ||
allow-direct-references = true | ||
``` | ||
|
||
Confirm it was installed: | ||
|
||
```shell | ||
hatch run dev:pip list | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
For other package managers, check their documentation on how to accomplish the same. | ||
|
||
:::tip | ||
If you place the virtual environment (`.venv`) inside the module, don't forget to add it to `.gitignore` and to `"exclude"` in `dagger.json` to avoid uploading those files to the runtime container unnecessarily. | ||
::: | ||
|
||
:::note | ||
It's important to install the SDK in editable mode (the `-e` in the `pip install` and `poetry add` commands) so you don't have to reinstall it after a `dagger develop`. However, it's always recommended to reinstall the SDK after upgrading Dagger to cover possible dependency changes. | ||
::: | ||
|
||
</TabItem> | ||
<TabItem value="TypeScript"> | ||
|
||
When opening the generated `dagger/src/index.ts` in an IDE, most IDEs will automatically recognize the `@dagger.io/dagger` package, so long as the `tsconfig.json` file has a path configured on it. | ||
|
||
For Dagger modules initialized using `dagger init`, the default template is already configured this way: | ||
|
||
```json | ||
"experimentalDecorators": true, | ||
"paths": { | ||
"@dagger.io/dagger": ["./sdk"] | ||
} | ||
``` | ||
|
||
This configuration doesn't require separate installation of the dependency to enable type-hinting or other IDE features. | ||
|
||
|
||
</TabItem> | ||
</Tabs> |
56 changes: 0 additions & 56 deletions
56
docs/current_docs/manuals/developer/python/742020-ide-integration.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
docs/current_docs/manuals/developer/typescript/629502-ide-integration.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters